diff options
author | Chris Robinson <[email protected]> | 2011-05-03 17:11:07 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-05-03 17:11:07 -0700 |
commit | 679f2480c9a66905b0a03c99e099b59bfd07879d (patch) | |
tree | 186219bf7fc0b39eba0f04b2e4ede23c57a57260 /Alc | |
parent | db7ca2c7ca48026261c59095331ae2a098083c7a (diff) |
Add a device flag for channel config requests
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 4 | ||||
-rw-r--r-- | Alc/alsa.c | 5 | ||||
-rw-r--r-- | Alc/coreaudio.c | 37 | ||||
-rw-r--r-- | Alc/dsound.c | 6 | ||||
-rw-r--r-- | Alc/pulseaudio.c | 2 | ||||
-rw-r--r-- | Alc/winmm.c | 8 |
6 files changed, 59 insertions, 3 deletions
@@ -1369,6 +1369,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, device->Flags |= DEVICE_FREQUENCY_REQUEST; device->Frequency = frequency; + + device->Flags |= DEVICE_CHANNELS_REQUEST; if(DecomposeDevFormat(format, &device->FmtChans, &device->FmtType) == AL_FALSE) { free(device); @@ -2309,6 +2311,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) if(device->Frequency < 8000) device->Frequency = 8000; + if(ConfigValueExists(NULL, "format")) + device->Flags |= DEVICE_CHANNELS_REQUEST; fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16"); if(DecomposeDevFormat(GetFormatFromString(fmt), &device->FmtChans, &device->FmtType) == AL_FALSE) @@ -612,7 +612,12 @@ static ALCboolean alsa_reset_playback(ALCdevice *device) device->FmtChans = DevFmtMono; if((i=psnd_pcm_hw_params_set_channels(data->pcmHandle, p, 1)) < 0) err = "set channels"; + else if((device->Flags&DEVICE_CHANNELS_REQUEST)) + AL_PRINT("Failed to set requested channel config %#x, got mono instead\n", device->FmtChans); } + else if((device->Flags&DEVICE_CHANNELS_REQUEST)) + AL_PRINT("Failed to set requested channel config %#x, got stereo instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; } if(i >= 0 && (i=psnd_pcm_hw_params_set_rate_resample(data->pcmHandle, p, 0)) < 0) { diff --git a/Alc/coreaudio.c b/Alc/coreaudio.c index 2ca9802b..1d086926 100644 --- a/Alc/coreaudio.c +++ b/Alc/coreaudio.c @@ -172,25 +172,62 @@ static ALCboolean ca_reset_playback(ALCdevice *device) switch(streamFormat.mChannelsPerFrame) { case 1: + if((device->Flags&DEVICE_CHANNELS_REQUEST) && + device->FmtChans != DevFmtMono) + { + AL_PRINT("Failed to set requested channel config %#x, got mono instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; + } device->FmtChans = DevFmtMono; break; case 2: + if((device->Flags&DEVICE_CHANNELS_REQUEST) && + device->FmtChans != DevFmtStereo) + { + AL_PRINT("Failed to set requested channel config %#x, got stereo instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; + } device->FmtChans = DevFmtStereo; break; case 4: + if((device->Flags&DEVICE_CHANNELS_REQUEST) && + device->FmtChans != DevFmtQuad) + { + AL_PRINT("Failed to set requested channel config %#x, got quad instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; + } device->FmtChans = DevFmtQuad; break; case 6: + if((device->Flags&DEVICE_CHANNELS_REQUEST) && + device->FmtChans != DevFmtX51) + { + AL_PRINT("Failed to set requested channel config %#x, got 5.1 instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; + } device->FmtChans = DevFmtX51; break; case 7: + if((device->Flags&DEVICE_CHANNELS_REQUEST) && + device->FmtChans != DevFmtX61) + { + AL_PRINT("Failed to set requested channel config %#x, got 6.1 instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; + } device->FmtChans = DevFmtX61; break; case 8: + if((device->Flags&DEVICE_CHANNELS_REQUEST) && + device->FmtChans != DevFmtX71) + { + AL_PRINT("Failed to set requested channel config %#x, got 7.1 instead\n", device->FmtChans); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; + } device->FmtChans = DevFmtX71; break; default: AL_PRINT("Unhandled channel count (%d), using stereo\n", streamFormat.mChannelsPerFrame); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; device->FmtChans = DevFmtStereo; streamFormat.mChannelsPerFrame = 2; break; diff --git a/Alc/dsound.c b/Alc/dsound.c index 6dfbe3d6..e719d0a1 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -354,7 +354,7 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) } hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers); - if(SUCCEEDED(hr) && ConfigValueExists(NULL, "format")) + if(FAILED(hr) || (device->Flags&DEVICE_FREQUENCY_REQUEST)) { switch(device->FmtChans) { @@ -371,7 +371,9 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) speakers = DSSPEAKER_COMBINED(DSSPEAKER_5POINT1, 0); break; case DevFmtX61: - /* ??? */; + /* ??? */ + AL_PRINT("6.1 not supported with DirectSound\n"); + device->Flags &= ~DEVICE_CHANNELS_REQUEST; break; case DevFmtX71: speakers = DSSPEAKER_COMBINED(DSSPEAKER_7POINT1, 0); diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index 0520e627..c92cab52 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -869,7 +869,7 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{ ppa_threaded_mainloop_lock(data->loop); - if(!ConfigValueExists(NULL, "format")) + if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) { pa_operation *o; o = ppa_context_get_sink_info_by_name(data->context, data->device_name, sink_info_callback, device); diff --git a/Alc/winmm.c b/Alc/winmm.c index 348e764f..c985ec0e 100644 --- a/Alc/winmm.c +++ b/Alc/winmm.c @@ -337,7 +337,15 @@ static ALCboolean WinMMOpenPlayback(ALCdevice *pDevice, const ALCchar *deviceNam pDevice->ExtraData = pData; if(pDevice->FmtChans != DevFmtMono) + { + if((pDevice->Flags&DEVICE_CHANNELS_REQUEST) && + pDevice->FmtChans != DevFmtStereo) + { + AL_PRINT("Failed to set requested channel config %#x, got stereo instead\n", pDevice->FmtChans); + pDevice->Flags &= ~DEVICE_CHANNELS_REQUEST; + } pDevice->FmtChans = DevFmtStereo; + } switch(pDevice->FmtType) { case DevFmtByte: |