I modified something for the USB earphone issue.

hustxyj hustxyj at sina.com
Mon Jun 9 05:16:46 PDT 2014

Hi all:


I sent an email about the hot-plug issue about USB earphone before. These
days, I trace the log, and found that when I plugged out the device, it came
to an endless loop in gst_directsound_sink_write; calculate_freesize was
called everytime. So, if gst_element_set_state was called in another thread,
gst_directsound_sink_reset triggered, Which may blocked, due to
GST_DSOUND_LOCK (dsoundsink).


I added a variable "reset" in GstDirectSoundSink to indicate the reset of a
sink. It will be set true before GST_DSOUND_LOCK (dsoundsink) in

static void

gst_directsound_sink_reset (GstAudioSink * asink)


  GstDirectSoundSink *dsoundsink;

  LPVOID pLockedBuffer = NULL;

  DWORD dwSizeBuffer = 0;


  dsoundsink = GST_DIRECTSOUND_SINK (asink);


  dsoundsink->reset = TRUE;


  GST_DSOUND_LOCK (dsoundsink);





In the calculate_freesize loop, modified as below:

if (SUCCEEDED (hRes) && (dwStatus & DSBSTATUS_PLAYING) &&

 goto calculate_freesize;

else {

  dsoundsink->first_buffer_after_reset = FALSE;

  dsoundsink->reset = FALSE;

  GST_DSOUND_UNLOCK (dsoundsink);

  return 0; 



After modified, the stuck issue was gone. I want to ask you guys, if this is
a good idea or a bad one. If bad, do you have any other solutions?

PS: I haven't looked deep into the logic of calculate_freesize loop. So
maybe there is a better way to break the loop which I have not found.






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140609/b7d4c0dd/attachment.html>

More information about the gstreamer-devel mailing list