diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-24 20:02:57 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-24 20:02:57 (GMT) |
commit | bb8582f4dbc129feb756371845de58ea1580565d (patch) | |
tree | 42d58f5edd5c2cd0e62a3cf054624bf1da2c742d | |
parent | e5935fb92f89ab88daa0060465e665a626bfa88b (diff) | |
parent | 98d176d2fc27500392bde401c9715888b53eb918 (diff) | |
download | Qt-bb8582f4dbc129feb756371845de58ea1580565d.zip Qt-bb8582f4dbc129feb756371845de58ea1580565d.tar.gz Qt-bb8582f4dbc129feb756371845de58ea1580565d.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging:
Fixed compile error introduced by win32 surround sound support change.
Added surround sound support to alsa low-level audio backend.
Added surround sound support to win32 low-level audio backend.
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 46 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 5 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 5 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_win32_p.cpp | 95 |
4 files changed, 142 insertions, 9 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 36270a7..f663dd2 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -62,6 +62,8 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode device = QLatin1String(dev); this->mode = mode; + + checkSurround(); } QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() @@ -389,6 +391,9 @@ void QAudioDeviceInfoInternal::updateLists() } channelz.append(1); channelz.append(2); + if (surround40) channelz.append(4); + if (surround51) channelz.append(6); + if (surround71) channelz.append(8); sizez.append(8); sizez.append(16); sizez.append(32); @@ -483,4 +488,45 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() return devices.first(); } +void QAudioDeviceInfoInternal::checkSurround() +{ + QList<QByteArray> devices; + surround40 = false; + surround51 = false; + surround71 = false; + + void **hints, **n; + char *name, *descr, *io; + + if(snd_device_name_hint(-1, "pcm", &hints) < 0) + return; + + n = hints; + + while (*n != NULL) { + name = snd_device_name_get_hint(*n, "NAME"); + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + if((name != NULL) && (descr != NULL)) { + QString deviceName = QLatin1String(name); + if (mode == QAudio::AudioOutput) { + if(deviceName.contains(QLatin1String("surround40"))) + surround40 = true; + if(deviceName.contains(QLatin1String("surround51"))) + surround51 = true; + if(deviceName.contains(QLatin1String("surround71"))) + surround71 = true; + } + } + if(name != NULL) + free(name); + if(descr != NULL) + free(descr); + if(io != NULL) + free(io); + ++n; + } + snd_device_name_free_hint(hints); +} + QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 6f9a459..8525980 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -98,6 +98,11 @@ private: bool open(); void close(); + void checkSurround(); + bool surround40; + bool surround51; + bool surround71; + QString device; QAudio::Mode mode; QAudioFormat nearest; 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..56de4ee 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -52,6 +52,51 @@ #include "qaudiooutput_win32_p.h" +#ifndef SPEAKER_FRONT_LEFT + #define SPEAKER_FRONT_LEFT 0x00000001 + #define SPEAKER_FRONT_RIGHT 0x00000002 + #define SPEAKER_FRONT_CENTER 0x00000004 + #define SPEAKER_LOW_FREQUENCY 0x00000008 + #define SPEAKER_BACK_LEFT 0x00000010 + #define SPEAKER_BACK_RIGHT 0x00000020 + #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 + #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 + #define SPEAKER_BACK_CENTER 0x00000100 + #define SPEAKER_SIDE_LEFT 0x00000200 + #define SPEAKER_SIDE_RIGHT 0x00000400 + #define SPEAKER_TOP_CENTER 0x00000800 + #define SPEAKER_TOP_FRONT_LEFT 0x00001000 + #define SPEAKER_TOP_FRONT_CENTER 0x00002000 + #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 + #define SPEAKER_TOP_BACK_LEFT 0x00008000 + #define SPEAKER_TOP_BACK_CENTER 0x00010000 + #define SPEAKER_TOP_BACK_RIGHT 0x00020000 + #define SPEAKER_RESERVED 0x7FFC0000 + #define SPEAKER_ALL 0x80000000 +#endif + +#ifndef _WAVEFORMATEXTENSIBLE_ + + #define _WAVEFORMATEXTENSIBLE_ + typedef struct + { + WAVEFORMATEX Format; // Base WAVEFORMATEX data + union + { + WORD wValidBitsPerSample; // Valid bits in each sample container + WORD wSamplesPerBlock; // Samples per block of audio data; valid + // if wBitsPerSample=0 (but rarely used). + WORD wReserved; // Zero if neither case above applies. + } Samples; + DWORD dwChannelMask; // Positions of the audio channels + GUID SubFormat; // Format identifier GUID + } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE, *LPPWAVEFORMATEXTENSIBLE; + typedef const WAVEFORMATEXTENSIBLE* LPCWAVEFORMATEXTENSIBLE; + +#endif + +#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 +303,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; |