mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-07-29 12:12:25 -04:00
FCD Streaming.
This commit is contained in:
parent
46dcbe6db7
commit
21578a555e
@ -7,16 +7,27 @@
|
|||||||
|
|
||||||
bool FCDThread::OpenSource(const char* cardname)
|
bool FCDThread::OpenSource(const char* cardname)
|
||||||
{
|
{
|
||||||
|
snd_pcm_hw_params_t* params;
|
||||||
//fcd_rate = FCDPP_RATE;
|
//fcd_rate = FCDPP_RATE;
|
||||||
//fcd_channels =2;
|
//fcd_channels =2;
|
||||||
//fcd_format = SND_PCM_SFMT_U16_LE;
|
//fcd_format = SND_PCM_SFMT_U16_LE;
|
||||||
fcd_stream = SND_PCM_STREAM_PLAYBACK;
|
snd_pcm_stream_t fcd_stream = SND_PCM_STREAM_CAPTURE;
|
||||||
|
|
||||||
if (fcd_handle)
|
if (fcd_handle)
|
||||||
return false;
|
return false;
|
||||||
if ( snd_pcm_open( &fcd_handle, cardname, fcd_stream, 1 ) < 0 )
|
if ( snd_pcm_open( &fcd_handle, cardname, fcd_stream, 0 ) < 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
snd_pcm_hw_params_alloca(¶ms);
|
||||||
|
if ( snd_pcm_hw_params_any(fcd_handle, params) < 0 )
|
||||||
|
qCritical("Funcube Dongle read settings failed");
|
||||||
|
else if ( snd_pcm_hw_params(fcd_handle, params) < 0 )
|
||||||
|
qCritical("Funcube Dongle write settings failed");
|
||||||
|
// TODO: check actual samplerate, may be crippled firmware
|
||||||
|
|
||||||
|
if ( snd_pcm_start(fcd_handle) < 0 )
|
||||||
|
qCritical("Funcube Dongle stream start failed");
|
||||||
|
else qDebug("Funcube stream started");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +43,7 @@ void FCDThread::set_center_freq(double freq)
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void FCDThread::work(int n_items)
|
int FCDThread::work(int n_items)
|
||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
SampleVector::iterator it;
|
SampleVector::iterator it;
|
||||||
@ -40,9 +51,10 @@ void FCDThread::work(int n_items)
|
|||||||
|
|
||||||
it = m_convertBuffer.begin();
|
it = m_convertBuffer.begin();
|
||||||
out = (void *)&it[0];
|
out = (void *)&it[0];
|
||||||
l = snd_pcm_readi(fcd_handle, out, (snd_pcm_uframes_t)n_items);
|
l = snd_pcm_mmap_readi(fcd_handle, out, (snd_pcm_uframes_t)n_items);
|
||||||
if (l > 0)
|
if (l > 0)
|
||||||
m_sampleFifo->write(it, it + l);
|
m_sampleFifo->write(it, it + l);
|
||||||
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,9 +44,11 @@ void FCDThread::run()
|
|||||||
m_running = true;
|
m_running = true;
|
||||||
if ( !OpenSource("hw:CARD=V20") )
|
if ( !OpenSource("hw:CARD=V20") )
|
||||||
return;
|
return;
|
||||||
|
// TODO: fallback to original fcd
|
||||||
|
|
||||||
while(m_running) {
|
while(m_running) {
|
||||||
work(BLOCKSIZE);
|
if ( work(BLOCKSIZE) < 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
CloseSource();
|
CloseSource();
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,10 @@ public:
|
|||||||
bool OpenSource(const char *filename);
|
bool OpenSource(const char *filename);
|
||||||
void CloseSource();
|
void CloseSource();
|
||||||
void set_center_freq(double freq);
|
void set_center_freq(double freq);
|
||||||
void work(int n_items);
|
int work(int n_items);
|
||||||
private:
|
private:
|
||||||
snd_pcm_format_t fcd_format;
|
snd_pcm_format_t fcd_format;
|
||||||
snd_pcm_t* fcd_handle = NULL;
|
snd_pcm_t* fcd_handle = NULL;
|
||||||
snd_pcm_stream_t fcd_stream;
|
|
||||||
|
|
||||||
QMutex m_startWaitMutex;
|
QMutex m_startWaitMutex;
|
||||||
QWaitCondition m_startWaiter;
|
QWaitCondition m_startWaiter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user