Jörg Höhle : winecoreaudio: Make supported format test more restrictive.
Alexandre Julliard
julliard at winehq.org
Wed Sep 16 16:01:12 CDT 2009
Module: wine
Branch: master
Commit: 89fe38ca9e917fb8c4b12f5a725cf86e78c5347c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=89fe38ca9e917fb8c4b12f5a725cf86e78c5347c
Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date: Fri Sep 11 07:43:45 2009 +0200
winecoreaudio: Make supported format test more restrictive.
---
dlls/winecoreaudio.drv/audio.c | 42 +++++++++++++++++----------------------
1 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/dlls/winecoreaudio.drv/audio.c b/dlls/winecoreaudio.drv/audio.c
index 10b66d0..8c42815 100644
--- a/dlls/winecoreaudio.drv/audio.c
+++ b/dlls/winecoreaudio.drv/audio.c
@@ -431,6 +431,22 @@ static DWORD bytes_to_mmtime(LPMMTIME lpTime, DWORD position,
return MMSYSERR_NOERROR;
}
+static BOOL supportedFormat(LPWAVEFORMATEX wf)
+{
+ if (wf->nSamplesPerSec == 0)
+ return FALSE;
+
+ if (wf->wFormatTag == WAVE_FORMAT_PCM) {
+ if (wf->nChannels >= 1 && wf->nChannels <= 2) {
+ if (wf->wBitsPerSample==8||wf->wBitsPerSample==16)
+ return TRUE;
+ }
+ } else
+ WARN("only WAVE_FORMAT_PCM supported\n");
+
+ return FALSE;
+}
+
/**************************************************************************
* CoreAudio_GetDevCaps [internal]
*/
@@ -793,10 +809,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
lpDesc->lpFormat->nSamplesPerSec, lpDesc->lpFormat->wBitsPerSample);
- if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM ||
- lpDesc->lpFormat->nChannels == 0 ||
- lpDesc->lpFormat->nSamplesPerSec == 0
- )
+ if (!supportedFormat(lpDesc->lpFormat))
{
WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%d wBitsPerSample=%d !\n",
lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
@@ -893,14 +906,6 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwo->waveDesc = *lpDesc;
memcpy(&wwo->format, lpDesc->lpFormat, sizeof(PCMWAVEFORMAT));
-
- if (wwo->format.wBitsPerSample == 0) {
- WARN("Resetting zeroed wBitsPerSample\n");
- wwo->format.wBitsPerSample = 8 *
- (wwo->format.wf.nAvgBytesPerSec /
- wwo->format.wf.nSamplesPerSec) /
- wwo->format.wf.nChannels;
- }
wwo->dwPlayedTotal = 0;
wwo->dwWrittenTotal = 0;
@@ -1884,9 +1889,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
lpDesc->lpFormat->nSamplesPerSec, lpDesc->lpFormat->wBitsPerSample);
- if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM ||
- lpDesc->lpFormat->nChannels == 0 ||
- lpDesc->lpFormat->nSamplesPerSec == 0 ||
+ if (!supportedFormat(lpDesc->lpFormat) ||
lpDesc->lpFormat->nSamplesPerSec != AudioUnit_GetInputDeviceSampleRate()
)
{
@@ -1920,15 +1923,6 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwi->waveDesc = *lpDesc;
memcpy(&wwi->format, lpDesc->lpFormat, sizeof(PCMWAVEFORMAT));
- if (wwi->format.wBitsPerSample == 0)
- {
- WARN("Resetting zeroed wBitsPerSample\n");
- wwi->format.wBitsPerSample = 8 *
- (wwi->format.wf.nAvgBytesPerSec /
- wwi->format.wf.nSamplesPerSec) /
- wwi->format.wf.nChannels;
- }
-
wwi->dwTotalRecorded = 0;
wwi->trace_on = TRACE_ON(wave);
More information about the wine-cvs
mailing list