Problem with valve and audio sink

Hi all,

I get an runtime error, when switching a valve.

I saw a similar problem some months ago, but the setup was different.

My setup is quite easy:

A signal source ( cosine, float ) connected to a audio sink.
The same signal source is connected to a valve and the valve is
connected to a scope sink.

The valve is switched by a checkbox.

Switching the valve leads to

audio_alsa_sink[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_sink(1) using ninputs=1,
noutputs=0

I wonder how the valve affects the audio sink.

Any ideas ?

Thanks in advance

Volker

try running the same fix with the static variable, this problem will
show up even with simple setups because it’s in the alsa audio source
block. even though the fix works i wouldn’t recommend it for long term
solution because it’s a hack. you can look into the FIXME section of
the code to make a more permenant solution.

al

To: Discuss-gnuradio [email protected]

terminate called after throwing an instance of ‘std::runtime_error’

Actually, I’ve been working on a good fix for this–it’s been “in
testing” for the last 30 days or so,
I’ll perhaps submit it to Tom R, and see where it goes from there.

Introducing a static variable helps in my case, but in other situations
it might still fail.

In between I had a deeper look to the source and I propose a solution
depending on the state of the stream.

— audio_alsa_sink.cc 2010-12-07 14:05:30.000000000 +0100
+++ audio_alsa_sink_new.cc 2010-12-07 14:06:42.000000000 +0100
@@ -219,9 +219,15 @@
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;

Thank you

Volker