Init supported audio formats in portaudio after the devices are inited and the default values are extracted.

cusax-fix
Damian Minkov 16 years ago
parent 210f4d7f69
commit cb33984f35

@ -606,6 +606,7 @@ else if(name.equals(AUDIO_SYSTEM_PORTAUDIO))
this.audioPlaybackDevice = captureDeviceInfo;
setDeviceToRenderer(audioPlaybackDevice);
removeJavaSoundRenderer();
initPortAudioRenderer();
break;
}
}

@ -66,9 +66,6 @@ public class PortAudioAuto
CaptureDeviceManager.commit();
// Enables Portaudio Renderer
DeviceConfiguration.initPortAudioRenderer();
// now add it as available audio system to DeviceConfiguration
DeviceConfiguration.addAudioSystem(
DeviceConfiguration.AUDIO_SYSTEM_PORTAUDIO);

@ -133,19 +133,30 @@ public void run()
{
if (portAudioStream == 0)
{
int deviceIndex =
PortAudioStream.getDeviceIndexFromLocator(
audioNotifier.getDeviceConfiguration().
getAudioNotifyDevice().getLocator());
long devInfo = PortAudio.Pa_GetDeviceInfo(deviceIndex);
int maxOutChannels =
PortAudio.PaDeviceInfo_getMaxOutputChannels(devInfo);
if(maxOutChannels > 2)
maxOutChannels = 2;
double sampleRate =
PortAudio.PaDeviceInfo_getDefaultSampleRate(devInfo);
long streamParameters
= PortAudio.PaStreamParameters_new(
PortAudioStream.getDeviceIndexFromLocator(
audioNotifier.getDeviceConfiguration().
getAudioNotifyDevice().getLocator()),
2,
deviceIndex,
maxOutChannels,
PortAudio.SAMPLE_FORMAT_INT16);
portAudioStream
= PortAudio.Pa_OpenStream(
0,
streamParameters,
48000,
sampleRate,
PortAudio.FRAMES_PER_BUFFER_UNSPECIFIED,
PortAudio.STREAM_FLAGS_NO_FLAG,
null);

@ -24,25 +24,16 @@ public class PortAudioRenderer
private static final String name = "PortAudio Renderer";
private static AudioFormat audioFormat =
new AudioFormat(
AudioFormat.LINEAR,
48000,
16,
2,
AudioFormat.LITTLE_ENDIAN,
AudioFormat.SIGNED,
16,
Format.NOT_SPECIFIED,
Format.byteArray);
/**
* Will be inited after the device is set.
*/
private static AudioFormat audioFormat = null;
/**
* The supported input formats.
* The supported input formats. The Inputformats are
* changed after the device is set.
*/
public static Format[] supportedInputFormats = new Format[]
{
audioFormat
};
public static Format[] supportedInputFormats = new Format[]{};
private Object [] controls = new Object[0];
private AudioFormat inputFormat;
@ -249,12 +240,34 @@ public Object getControl(String controlType)
/**
* Used to set the device index used by the renderer common for all
* instances of it.
* instances of it. Change the format corresponding the device which
* will be used.
* @param locator the locator containing the device index.
*/
public static void setDevice(MediaLocator locator)
{
deviceIndex = PortAudioStream.getDeviceIndexFromLocator(locator);
long device = PortAudio.Pa_GetDeviceInfo(deviceIndex);
int maxOutputChannels =
PortAudio.PaDeviceInfo_getMaxOutputChannels(device);
if(maxOutputChannels > 2)
maxOutputChannels = 2;
double defaultSampleRate =
PortAudio.PaDeviceInfo_getDefaultSampleRate(device);
audioFormat =
new AudioFormat(
AudioFormat.LINEAR,
defaultSampleRate,
16,
maxOutputChannels,
AudioFormat.LITTLE_ENDIAN,
AudioFormat.SIGNED,
16,
Format.NOT_SPECIFIED,
Format.byteArray);
supportedInputFormats = new Format[]{audioFormat};
}
/**

Loading…
Cancel
Save