aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/backends/portaudio.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index 03e54d14..14cfab7c 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -120,6 +120,7 @@ static ALCboolean pa_load(void)
typedef struct {
PaStream *stream;
+ PaStreamParameters params;
ALuint update_size;
RingBuffer *ring;
@@ -158,7 +159,6 @@ static int pa_capture_cb(const void *inputBuffer, void *outputBuffer,
static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
- PaStreamParameters outParams;
pa_data *data;
PaError err;
@@ -172,42 +172,43 @@ static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName)
device->ExtraData = data;
- outParams.device = -1;
- if(!ConfigValueInt("port", "device", &outParams.device) || outParams.device < 0)
- outParams.device = Pa_GetDefaultOutputDevice();
- outParams.suggestedLatency = (device->UpdateSize*device->NumUpdates) /
- (float)device->Frequency;
- outParams.hostApiSpecificStreamInfo = NULL;
+ data->params.device = -1;
+ if(!ConfigValueInt("port", "device", &data->params.device) ||
+ data->params.device < 0)
+ data->params.device = Pa_GetDefaultOutputDevice();
+ data->params.suggestedLatency = (device->UpdateSize*device->NumUpdates) /
+ (float)device->Frequency;
+ data->params.hostApiSpecificStreamInfo = NULL;
- outParams.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2);
+ data->params.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2);
retry_open:
switch(device->FmtType)
{
case DevFmtByte:
- outParams.sampleFormat = paInt8;
+ data->params.sampleFormat = paInt8;
break;
case DevFmtUByte:
- outParams.sampleFormat = paUInt8;
+ data->params.sampleFormat = paUInt8;
break;
case DevFmtUShort:
device->FmtType = DevFmtShort;
/* fall-through */
case DevFmtShort:
- outParams.sampleFormat = paInt16;
+ data->params.sampleFormat = paInt16;
break;
case DevFmtUInt:
device->FmtType = DevFmtInt;
/* fall-through */
case DevFmtInt:
- outParams.sampleFormat = paInt32;
+ data->params.sampleFormat = paInt32;
break;
case DevFmtFloat:
- outParams.sampleFormat = paFloat32;
+ data->params.sampleFormat = paFloat32;
break;
}
- err = Pa_OpenStream(&data->stream, NULL, &outParams, device->Frequency,
+ err = Pa_OpenStream(&data->stream, NULL, &data->params, device->Frequency,
device->UpdateSize, paNoFlag, pa_callback, device);
if(err != paNoError)
{
@@ -222,20 +223,20 @@ retry_open:
return ALC_INVALID_VALUE;
}
- if((ALuint)outParams.channelCount != ChannelsFromDevFmt(device->FmtChans))
+ if((ALuint)data->params.channelCount != ChannelsFromDevFmt(device->FmtChans))
{
- if(outParams.channelCount != 1 && outParams.channelCount != 2)
+ if(data->params.channelCount != 1 && data->params.channelCount != 2)
{
- ERR("Unhandled channel count: %u\n", outParams.channelCount);
+ ERR("Unhandled channel count: %u\n", data->params.channelCount);
Pa_CloseStream(data->stream);
device->ExtraData = NULL;
free(data);
return ALC_INVALID_VALUE;
}
if((device->Flags&DEVICE_CHANNELS_REQUEST))
- ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(device->FmtChans), outParams.channelCount);
+ ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(device->FmtChans), data->params.channelCount);
device->Flags &= ~DEVICE_CHANNELS_REQUEST;
- device->FmtChans = ((outParams.channelCount==1) ? DevFmtMono : DevFmtStereo);
+ device->FmtChans = ((data->params.channelCount==1) ? DevFmtMono : DevFmtStereo);
}
SetDefaultChannelOrder(device);
@@ -297,7 +298,6 @@ static void pa_stop_playback(ALCdevice *device)
static ALCenum pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
- PaStreamParameters inParams;
ALuint frame_size;
pa_data *data;
PaError err;
@@ -316,37 +316,38 @@ static ALCenum pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
if(data->ring == NULL)
goto error;
- inParams.device = -1;
- if(!ConfigValueInt("port", "capture", &inParams.device) || inParams.device < 0)
- inParams.device = Pa_GetDefaultOutputDevice();
- inParams.suggestedLatency = 0.0f;
- inParams.hostApiSpecificStreamInfo = NULL;
+ data->params.device = -1;
+ if(!ConfigValueInt("port", "capture", &data->params.device) ||
+ data->params.device < 0)
+ data->params.device = Pa_GetDefaultOutputDevice();
+ data->params.suggestedLatency = 0.0f;
+ data->params.hostApiSpecificStreamInfo = NULL;
switch(device->FmtType)
{
case DevFmtByte:
- inParams.sampleFormat = paInt8;
+ data->params.sampleFormat = paInt8;
break;
case DevFmtUByte:
- inParams.sampleFormat = paUInt8;
+ data->params.sampleFormat = paUInt8;
break;
case DevFmtShort:
- inParams.sampleFormat = paInt16;
+ data->params.sampleFormat = paInt16;
break;
case DevFmtInt:
- inParams.sampleFormat = paInt32;
+ data->params.sampleFormat = paInt32;
break;
case DevFmtFloat:
- inParams.sampleFormat = paFloat32;
+ data->params.sampleFormat = paFloat32;
break;
case DevFmtUInt:
case DevFmtUShort:
ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType));
goto error;
}
- inParams.channelCount = ChannelsFromDevFmt(device->FmtChans);
+ data->params.channelCount = ChannelsFromDevFmt(device->FmtChans);
- err = Pa_OpenStream(&data->stream, &inParams, NULL, device->Frequency,
+ err = Pa_OpenStream(&data->stream, &data->params, NULL, device->Frequency,
paFramesPerBufferUnspecified, paNoFlag, pa_capture_cb, device);
if(err != paNoError)
{