aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/winmm.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-12-04 19:50:00 -0800
committerChris Robinson <[email protected]>2010-12-04 19:50:00 -0800
commit88e3a2277235fe173d4d0ff3f10c0becdc9c82cd (patch)
tree3cfad0017b809fc08e69cc9ec99fe622d26a2606 /Alc/winmm.c
parent191803ad53c156d3f056b649c76e441042a385fb (diff)
Separate device format into 'channel config' and 'sample type' components
Diffstat (limited to 'Alc/winmm.c')
-rw-r--r--Alc/winmm.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 8688b7b0..ee21e71e 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -194,7 +194,7 @@ static DWORD WINAPI PlaybackThreadProc(LPVOID lpParameter)
ALuint FrameSize;
MSG msg;
- FrameSize = aluFrameSizeFromFormat(pDevice->Format);
+ FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType);
while(GetMessage(&msg, NULL, 0, 0))
{
@@ -272,7 +272,7 @@ static DWORD WINAPI CaptureThreadProc(LPVOID lpParameter)
ALuint FrameSize;
MSG msg;
- FrameSize = aluFrameSizeFromFormat(pDevice->Format);
+ FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType);
while(GetMessage(&msg, NULL, 0, 0))
{
@@ -336,25 +336,26 @@ static ALCboolean WinMMOpenPlayback(ALCdevice *pDevice, const ALCchar *deviceNam
}
pDevice->ExtraData = pData;
- if(aluChannelsFromFormat(pDevice->Format) >= 2)
+ if(pDevice->FmtChans != DevFmtMono)
+ pDevice->FmtChans = DevFmtStereo;
+ switch(pDevice->FmtType)
{
- if(aluBytesFromFormat(pDevice->Format) >= 2)
- pDevice->Format = AL_FORMAT_STEREO16;
- else
- pDevice->Format = AL_FORMAT_STEREO8;
- }
- else
- {
- if(aluBytesFromFormat(pDevice->Format) >= 2)
- pDevice->Format = AL_FORMAT_MONO16;
- else
- pDevice->Format = AL_FORMAT_MONO8;
+ case DevFmtByte:
+ pDevice->FmtType = DevFmtUByte;
+ break;
+ case DevFmtUShort:
+ case DevFmtFloat:
+ pDevice->FmtType = DevFmtShort;
+ break;
+ case DevFmtUByte:
+ case DevFmtShort:
+ break;
}
memset(&wfexFormat, 0, sizeof(WAVEFORMATEX));
wfexFormat.wFormatTag = WAVE_FORMAT_PCM;
- wfexFormat.nChannels = aluChannelsFromFormat(pDevice->Format);
- wfexFormat.wBitsPerSample = aluBytesFromFormat(pDevice->Format) * 8;
+ wfexFormat.nChannels = ChannelsFromDevFmt(pDevice->FmtChans);
+ wfexFormat.wBitsPerSample = BytesFromDevFmt(pDevice->FmtType) * 8;
wfexFormat.nBlockAlign = wfexFormat.wBitsPerSample *
wfexFormat.nChannels / 8;
wfexFormat.nSamplesPerSec = pDevice->Frequency;
@@ -433,7 +434,7 @@ static ALCboolean WinMMResetPlayback(ALCdevice *device)
// Create 4 Buffers
lBufferSize = device->UpdateSize*device->NumUpdates / 4;
- lBufferSize *= aluFrameSizeFromFormat(device->Format);
+ lBufferSize *= FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
BufferData = calloc(4, lBufferSize);
for(i = 0;i < 4;i++)
@@ -533,10 +534,17 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
}
pDevice->ExtraData = pData;
+ if((pDevice->FmtChans != DevFmtMono && pDevice->FmtChans != DevFmtStereo) ||
+ (pDevice->FmtType != DevFmtUByte && pDevice->FmtType != DevFmtShort))
+ {
+ alcSetError(pDevice, ALC_INVALID_ENUM);
+ goto failure;
+ }
+
memset(&wfexCaptureFormat, 0, sizeof(WAVEFORMATEX));
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
- wfexCaptureFormat.nChannels = aluChannelsFromFormat(pDevice->Format);
- wfexCaptureFormat.wBitsPerSample = aluBytesFromFormat(pDevice->Format) * 8;
+ wfexCaptureFormat.nChannels = ChannelsFromDevFmt(pDevice->FmtChans);
+ wfexCaptureFormat.wBitsPerSample = BytesFromDevFmt(pDevice->FmtType) * 8;
wfexCaptureFormat.nBlockAlign = wfexCaptureFormat.wBitsPerSample *
wfexCaptureFormat.nChannels / 8;
wfexCaptureFormat.nSamplesPerSec = pDevice->Frequency;