Add a device request flag for the sample type

This commit is contained in:
Chris Robinson 2012-02-15 16:26:32 -08:00
parent 2ab0e3521c
commit fecd679f33
2 changed files with 19 additions and 6 deletions

View File

@ -1176,10 +1176,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
oldChans = device->FmtChans;
oldType = device->FmtType;
TRACE("Format pre-setup: %s%s, %s, %uhz%s, %u update size x%d\n",
TRACE("Format pre-setup: %s%s, %s%s, %uhz%s, %u update size x%d\n",
DevFmtChannelsString(device->FmtChans),
(device->Flags&DEVICE_CHANNELS_REQUEST)?" (requested)":"",
DevFmtTypeString(device->FmtType), device->Frequency,
DevFmtTypeString(device->FmtType),
(device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)?" (requested)":"",
device->Frequency,
(device->Flags&DEVICE_FREQUENCY_REQUEST)?" (requested)":"",
device->UpdateSize, device->NumUpdates);
if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
@ -1195,6 +1197,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
DevFmtChannelsString(device->FmtChans));
device->Flags &= ~DEVICE_CHANNELS_REQUEST;
}
if(device->FmtType != oldType && (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST))
{
ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType),
DevFmtTypeString(device->FmtType));
device->Flags &= ~DEVICE_SAMPLE_TYPE_REQUEST;
}
if(device->Frequency != oldFreq && (device->Flags&DEVICE_FREQUENCY_REQUEST))
{
ERR("Failed to set %uhz, got %uhz instead\n", oldFreq, device->Frequency);
@ -1644,7 +1652,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
device->Flags |= DEVICE_FREQUENCY_REQUEST;
device->Frequency = frequency;
device->Flags |= DEVICE_CHANNELS_REQUEST;
device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_SAMPLE_TYPE_REQUEST;
if(DecomposeDevFormat(format, &device->FmtChans, &device->FmtType) == AL_FALSE)
{
DeleteCriticalSection(&device->Mutex);
@ -2487,8 +2495,10 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
{
if(!(device->Flags&DEVICE_CHANNELS_REQUEST))
device->FmtChans = formats[i].channels;
if(!(device->Flags&DEVICE_SAMPLE_TYPE_REQUEST))
device->FmtType = formats[i].type;
device->Flags |= DEVICE_CHANNELS_REQUEST;
device->Flags |= DEVICE_CHANNELS_REQUEST |
DEVICE_SAMPLE_TYPE_REQUEST;
break;
}
}
@ -2519,7 +2529,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
break;
}
}
if(!(device->Flags&DEVICE_CHANNELS_REQUEST))
if(i == sizeof(chanlist)/sizeof(chanlist[0]))
ERR("Unsupported channels: %s\n", fmt);
}
if(ConfigValueStr(NULL, "sample-type", &fmt))
@ -2543,6 +2553,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
if(strcasecmp(chanlist[i].name, fmt) == 0)
{
device->FmtType = chanlist[i].type;
device->Flags |= DEVICE_SAMPLE_TYPE_REQUEST;
break;
}
}

View File

@ -630,6 +630,8 @@ struct ALCdevice_struct
#define DEVICE_FREQUENCY_REQUEST (1<<1)
// Channel configuration was requested by the config file
#define DEVICE_CHANNELS_REQUEST (1<<2)
// Sample type was requested by the config file
#define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
// Specifies if the device is currently running
#define DEVICE_RUNNING (1<<31)