diff options
author | Kurt Korbatits <kurt.korbatits@nokia.com> | 2010-06-24 02:23:34 (GMT) |
---|---|---|
committer | Kurt Korbatits <kurt.korbatits@nokia.com> | 2010-06-24 02:23:34 (GMT) |
commit | 5aa3b45acf810f444487d0904a9c84be8687623d (patch) | |
tree | 1cb8010fa047a61569f5022c126867dd0b6259d1 /src/multimedia | |
parent | efefdf4412707991f28e1a65675dda5b03ab8a7d (diff) | |
download | Qt-5aa3b45acf810f444487d0904a9c84be8687623d.zip Qt-5aa3b45acf810f444487d0904a9c84be8687623d.tar.gz Qt-5aa3b45acf810f444487d0904a9c84be8687623d.tar.bz2 |
Added surround sound support to win32 low-level audio backend.
Task-number:QTBUG-11586
Reviewed-by:Andrew den Exter
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 5 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_win32_p.cpp | 54 |
2 files changed, 50 insertions, 9 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 465bc98..4e6b2df 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -374,6 +374,11 @@ void QAudioDeviceInfoInternal::updateLists() #endif channelz.append(1); channelz.append(2); + if (mode == QAudio::AudioOutput) { + channelz.append(4); + channelz.append(6); + channelz.append(8); + } byteOrderz.append(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 533583a..513c16c 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -52,6 +52,10 @@ #include "qaudiooutput_win32_p.h" +#include <audiodefs.h> + +#define _KSDATAFORMAT_SUBTYPE_PCM (GUID) {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}} + //#define DEBUG_AUDIO 1 QT_BEGIN_NAMESPACE @@ -258,15 +262,47 @@ bool QAudioOutputPrivate::open() } } - if(waveOutOpen(&hWaveOut, devId, &wfx, - (DWORD_PTR)&waveOutProc, - (DWORD_PTR) this, - CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioOutput: open error"); - return false; + if ( settings.channels() <= 2) { + if(waveOutOpen(&hWaveOut, devId, &wfx, + (DWORD_PTR)&waveOutProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error"); + return false; + } + } else { + WAVEFORMATEXTENSIBLE wfex; + wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + wfex.Format.nChannels = settings.channels(); + wfex.Format.wBitsPerSample = settings.sampleSize(); + wfex.Format.nSamplesPerSec = settings.frequency(); + wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8; + wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign; + wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample; + wfex.SubFormat=_KSDATAFORMAT_SUBTYPE_PCM; + wfex.Format.cbSize=22; + + wfex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + if (settings.channels() >= 4) + wfex.dwChannelMask |= SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; + if (settings.channels() >= 6) + wfex.dwChannelMask |= SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; + if (settings.channels() == 8) + wfex.dwChannelMask |= SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; + + if(waveOutOpen(&hWaveOut, devId, &wfex.Format, + (DWORD_PTR)&waveOutProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error"); + return false; + } } totalTimeValue = 0; |