Created
November 5, 2010 13:15
Revisions
-
csete revised this gist
Dec 8, 2010 . 1 changed file with 18 additions and 28 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,32 +1,22 @@ diff --git a/gr-audio-alsa/src/audio_alsa_sink.cc b/gr-audio-alsa/src/audio_alsa_sink.cc index d6b7f84..38ed86b 100644 --- a/gr-audio-alsa/src/audio_alsa_sink.cc +++ b/gr-audio-alsa/src/audio_alsa_sink.cc @@ -219,9 +219,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; -
csete revised this gist
Nov 5, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ index d6b7f84..4c8df3d 100644 static bool CHATTY_DEBUG = false; +// flag to skip calling snd_pcm_hw_params when graph is reconfigured (c.f. FIXME) +static bool s_first_time = true; + -
csete created this gist
Nov 5, 2010 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ diff --git a/gr-audio-alsa/src/audio_alsa_sink.cc b/gr-audio-alsa/src/audio_alsa_sink.cc index d6b7f84..4c8df3d 100644 --- a/gr-audio-alsa/src/audio_alsa_sink.cc +++ b/gr-audio-alsa/src/audio_alsa_sink.cc @@ -35,6 +35,9 @@ static bool CHATTY_DEBUG = false; +// flag to skip calling snd_pcm_hw_params when graphs is reconfigured (c.f. FIXME) +static bool s_first_time = true; + static snd_pcm_format_t acceptable_formats[] = { // these are in our preferred order... @@ -234,10 +237,13 @@ audio_alsa_sink::check_topology (int ninputs, int noutputs) } // set the parameters into the driver... - err = snd_pcm_hw_params(d_pcm_handle, d_hw_params); - if (err < 0){ - output_error_msg ("snd_pcm_hw_params failed", err); - return false; + if (s_first_time) { + err = snd_pcm_hw_params(d_pcm_handle, d_hw_params); + s_first_time = false; + if (err < 0){ + output_error_msg ("snd_pcm_hw_params failed", err); + return false; + } } // get current s/w params