Changing the topology of a flow graph with a valve leads to runtime erros
Uaudio_alsa_source[hw:0,0]: snd_pcm_hw_params failed: File descriptor in
bad state
terminate called after throwing an instance of 'std::runtime_error'
what(): check topology failed on audio_alsa_source(2) using
ninputs=0, noutputs=1
This can be avoided by the attached patch.
Depending on the state of stream the parameters are not set or the
stream will be restarted.
So you can even stop and restart the sound input without runtime errors.
Volker
--- audio_alsa_source.cc 2010-12-19 18:13:29.000000000 +0100
+++ audio_alsa_source_new.cc 2010-12-19 18:09:13.000000000 +0100
@@ -219,9 +219,16 @@
unsigned int nchan = noutputs;
int err;
- // FIXME check_topology may be called more than once.
// Ensure that the pcm is in a state where we can still mess with the hw_params
-
+ // Check the state of the stream
+ // Ensure that the pcm is in a state where we can still mess with the hw_params
+ snd_pcm_state_t state;
+ state=snd_pcm_state(d_pcm_handle);
+ if ( state== SND_PCM_STATE_RUNNING)
+ return true; // If stream is running, don't change any parameters
+ else if(state == SND_PCM_STATE_XRUN )
+ snd_pcm_prepare ( d_pcm_handle ); // Prepare stream on underrun, and we can set parameters;
+
bool special_case = nchan == 1 && d_special_case_stereo_to_mono;
if (special_case)
nchan = 2;
_______________________________________________
Patch-gnuradio mailing list
Patch-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/patch-gnuradio