A new patch for fixing the alsa restart issue. Submitted by Volker Schroer.
authorTom Rondeau <trondeau@vt.edu>
Wed, 22 Dec 2010 22:41:30 +0000 (17:41 -0500)
committerTom Rondeau <trondeau@vt.edu>
Wed, 22 Dec 2010 22:41:30 +0000 (17:41 -0500)
gr-audio-alsa/src/audio_alsa_sink.cc

index c28e23fea64bfaa06e6800c752d1905e38963a9e..d44a93b3f37a44ccfb3635eeadf3419f6a8b9892 100644 (file)
@@ -221,9 +221,15 @@ audio_alsa_sink::check_topology (int ninputs, int noutputs)
   int nchan = ninputs;
   int err;
 
-  // FIXME check_topology may be called more than once.
+  // 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_mono_to_stereo;
   if (special_case)
     nchan = 2;