Skip to content
Snippets Groups Projects
Commit cfe766cd authored by Lyubomir Marinov's avatar Lyubomir Marinov
Browse files

Fixes a dealock in the Windows Audio Session API (WASAPI) backend. Reported by Ingo Bauersachs.

parent 2b5119b0
No related branches found
No related tags found
No related merge requests found
...@@ -1169,7 +1169,12 @@ private AudioFormat doConnectInSourceMode( ...@@ -1169,7 +1169,12 @@ private AudioFormat doConnectInSourceMode(
@Override @Override
protected Format doGetFormat() protected Format doGetFormat()
{ {
return (format == null) ? super.doGetFormat() : format; synchronized (this)
{
if (format != null)
return format;
}
return super.doGetFormat();
} }
/** /**
...@@ -1342,6 +1347,30 @@ private AudioFormat findClosestMatchCaptureSupportedFormat( ...@@ -1342,6 +1347,30 @@ private AudioFormat findClosestMatchCaptureSupportedFormat(
NativelySupportedAudioFormat.class); NativelySupportedAudioFormat.class);
} }
/**
* {@inheritDoc}
*
* Overrides the super implementation to avoid a deadlock with
* {@link #stop()}. The <tt>stop()</tt> method is generally invoked with a
* certain synchronization root locked, the implementation of
* <tt>WASAPIStream</tt> waits for {@link #processThread} to quit but
* <tt>processThread</tt> indirectly invokes
* {@link AbstractPushBufferStream#getFormat()} which in turn results in an
* attempt to lock the mentioned synchronization root i.e. the thread
* invoking the <tt>stop()</tt> method and <tt>processThread</tt> fall into
* a deadlock.
*/
@Override
public Format getFormat()
{
synchronized (this)
{
if (format != null)
return format;
}
return super.getFormat();
}
/** /**
* Gets the <tt>MediaLocator</tt> of this instance which identifies the * Gets the <tt>MediaLocator</tt> of this instance which identifies the
* audio endpoint device this <tt>SourceStream</tt> is to capture data from. * audio endpoint device this <tt>SourceStream</tt> is to capture data from.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment