1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-03 14:34:57 -04:00

Open FCD.

This commit is contained in:
John Greb
2014-11-30 21:59:06 +00:00
parent beda489261
commit 46dcbe6db7
7 changed files with 63 additions and 13 deletions
+1 -1
View File
@@ -13,7 +13,6 @@ set(rtlsdr_HEADERS
fcdinput.h
fcdplugin.h
fcdthread.h
fcdsource.h
)
set(fcd_FORMS
@@ -43,6 +42,7 @@ add_library(inputfcd SHARED
target_link_libraries(inputfcd
${QT_LIBRARIES}
asound
sdrbase
)
+48
View File
@@ -0,0 +1,48 @@
/* (C)2015 John Greb
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public Licence version 3.
*/
#include "fcdthread.h"
bool FCDThread::OpenSource(const char* cardname)
{
//fcd_rate = FCDPP_RATE;
//fcd_channels =2;
//fcd_format = SND_PCM_SFMT_U16_LE;
fcd_stream = SND_PCM_STREAM_PLAYBACK;
if (fcd_handle)
return false;
if ( snd_pcm_open( &fcd_handle, cardname, fcd_stream, 1 ) < 0 )
return false;
return true;
}
void FCDThread::CloseSource()
{
if (fcd_handle)
snd_pcm_close( fcd_handle );
fcd_handle = NULL;
}
void FCDThread::set_center_freq(double freq)
{
//TODO
}
void FCDThread::work(int n_items)
{
int l;
SampleVector::iterator it;
void *out;
it = m_convertBuffer.begin();
out = (void *)&it[0];
l = snd_pcm_readi(fcd_handle, out, (snd_pcm_uframes_t)n_items);
if (l > 0)
m_sampleFifo->write(it, it + l);
}
+1 -2
View File
@@ -42,8 +42,7 @@ void FCDThread::stopWork()
void FCDThread::run()
{
m_running = true;
OpenSource("/dev/dsp");
if (fd < 0)
if ( !OpenSource("hw:CARD=V20") )
return;
while(m_running) {
+7 -9
View File
@@ -23,8 +23,9 @@
#include <QWaitCondition>
#include "dsp/samplefifo.h"
#include "dsp/inthalfbandfilter.h"
#include <alsa/asoundlib.h>
#define SAMPLERATE 192000
#define FCDPP_RATE 192000
#define BLOCKSIZE 8192
class FCDThread : public QThread {
@@ -35,17 +36,14 @@ public:
~FCDThread();
void stopWork();
void OpenSource(const char *filename);
bool OpenSource(const char *filename);
void CloseSource();
void set_center_freq(double freq);
int work(int n_items);
void work(int n_items);
private:
int fd;
struct fcd_buffer *buffers;
unsigned int n_buffers;
void *recebuf_ptr;
unsigned int recebuf_len;
unsigned int recebuf_mmap_index;
snd_pcm_format_t fcd_format;
snd_pcm_t* fcd_handle = NULL;
snd_pcm_stream_t fcd_stream;
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;