Add a device flag for channel config requests
This commit is contained in:
parent
db7ca2c7ca
commit
679f2480c9
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -527,6 +527,8 @@ struct ALCdevice_struct
|
||||
#define DEVICE_USE_HRTF (1<<1)
|
||||
// Frequency was requested by the app or config file
|
||||
#define DEVICE_FREQUENCY_REQUEST (1<<2)
|
||||
// Channel configuration was requested by the config file
|
||||
#define DEVICE_CHANNELS_REQUEST (1<<2)
|
||||
|
||||
|
||||
struct ALCcontext_struct
|
||||
|
Loading…
x
Reference in New Issue
Block a user