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

Handles hotplugging and playback device selections during calls in the Windows...

Handles hotplugging and playback device selections during calls in the Windows Audio Session API (WASAPI) integration when acoustic echo cancellation (AEC) is enabled.
parent 0a595aae
No related branches found
No related tags found
No related merge requests found
......@@ -158,7 +158,7 @@ private Format[] getIAudioClientSupportedFormats(int streamIndex)
Format[] superSupportedFormats = super.getSupportedFormats(streamIndex);
/*
* If the capture endpoint device is report to support no Format, then
* If the capture endpoint device reports to support no Format, then
* acoustic echo cancellation (AEC) will surely not work.
*/
if ((superSupportedFormats == null)
......
......@@ -300,7 +300,7 @@ protected void playbackDevicePropertyChange(PropertyChangeEvent ev)
/**
* Notifies this instance about a specific <tt>PropertyChangeEvent</tt>.
* <tt>AbstractAudioRenderer</tt> listens to changes in the values of the
* properties of {@link #audioSystem}
* properties of {@link #audioSystem}.
*
* @param ev the <tt>PropertyChangeEvent</tt> to notify this instance about
*/
......
......@@ -529,7 +529,7 @@ private int maybeIAudioRenderClientWrite(
private void maybeOpenResampler()
{
AudioFormat inFormat = this.inputFormat;
AudioFormat outFormat = dstFormat;
AudioFormat outFormat = this.dstFormat;
// We are able to translate between mono and stereo.
if ((inFormat.getSampleRate() == outFormat.getSampleRate())
......@@ -555,6 +555,44 @@ private void maybeOpenResampler()
outFormat.getDataType());
}
Codec resampler = maybeOpenResampler(inFormat, outFormat);
if (resampler == null)
{
throw new IllegalStateException(
"Failed to open a codec to resample [" + inFormat
+ "] into [" + outFormat + "].");
}
else
{
this.resampler = resampler;
resamplerChannels = outFormat.getChannels();
resamplerSampleSize = WASAPISystem.getSampleSizeInBytes(outFormat);
resamplerFrameSize = resamplerChannels * resamplerSampleSize;
}
}
/**
* Attempts to initialize and open a new <tt>Codec</tt> to resample media
* data from a specific input <tt>AudioFormat</tt> into a specific output
* <tt>AudioFormat</tt>. If no suitable resampler is found, returns
* <tt>null</tt>. If a suitable resampler is found but its initialization or
* opening fails, logs and swallows any <tt>Throwable</tt> and returns
* <tt>null</tt>.
*
* @param inFormat the <tt>AudioFormat</tt> in which the new instance is to
* input media data
* @param outFormat the <tt>AudioFormat</tt> in which the new instance is to
* output media data
* @return a new <tt>Codec</tt> which is able to resample media data from
* the specified <tt>inFormat</tt> into the specified <tt>outFormat</tt> if
* such a resampler could be found, initialized and opened; otherwise,
* <tt>null</tt>
*/
public static Codec maybeOpenResampler(
AudioFormat inFormat,
AudioFormat outFormat)
{
@SuppressWarnings("unchecked")
List<String> classNames
= PlugInManager.getPlugInList(
......@@ -598,19 +636,7 @@ private void maybeOpenResampler()
}
}
}
if (resampler == null)
{
throw new IllegalStateException(
"Failed to open a codec to resample [" + inFormat
+ "] into [" + outFormat + "].");
}
else
{
this.resampler = resampler;
resamplerChannels = outFormat.getChannels();
resamplerSampleSize = WASAPISystem.getSampleSizeInBytes(outFormat);
resamplerFrameSize = resamplerChannels * resamplerSampleSize;
}
return resampler;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment