summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 08:04:48 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 08:04:48 +0000
commitff4031c0ae89be5595055128752138573b8f0dff (patch)
tree0efc8925970501e2f8d758b8439a832604eed80e /media
parent23008931def55538924463d817f9d7a983a4cb34 (diff)
downloadchromium_src-ff4031c0ae89be5595055128752138573b8f0dff.zip
chromium_src-ff4031c0ae89be5595055128752138573b8f0dff.tar.gz
chromium_src-ff4031c0ae89be5595055128752138573b8f0dff.tar.bz2
audio use table for channels to mask to allow more of the surround options
BUG=60361 TEST=play audio with N channels and it should come out the proper speakers Review URL: http://codereview.chromium.org/4081001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/win/waveout_output_win.cc58
1 files changed, 39 insertions, 19 deletions
diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc
index 27b3e03..2c3d5c4 100644
--- a/media/audio/win/waveout_output_win.cc
+++ b/media/audio/win/waveout_output_win.cc
@@ -41,6 +41,42 @@ WAVEHDR* GetNextBuffer(WAVEHDR* current) {
} // namespace
+// See Also
+// http://www.thx.com/consumer/home-entertainment/home-theater/surround-sound-speaker-set-up/
+// http://en.wikipedia.org/wiki/Surround_sound
+
+const int kMaxChannelsToMask = 8;
+const unsigned int kChannelsToMask[kMaxChannelsToMask + 1] = {
+ 0,
+ // 1 = Mono
+ SPEAKER_FRONT_CENTER,
+ // 2 = Stereo
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
+ // 3 = Stereo + Center
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER,
+ // 4 = Quad
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
+ SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT,
+ // 5 = 5.0
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER |
+ SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT,
+ // 6 = 5.1
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
+ SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY |
+ SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT,
+ // 7 = 6.1
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
+ SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY |
+ SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT |
+ SPEAKER_BACK_CENTER,
+ // 8 = 7.1
+ SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
+ SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY |
+ SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT |
+ SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ // TODO(fbarchard): Add additional masks for 7.2 and beyond.
+};
+
PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream(
AudioManagerWin* manager, AudioParameters params, int num_buffers,
UINT device_id)
@@ -65,26 +101,10 @@ PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream(
format_.Format.wBitsPerSample) / 8;
format_.Format.nAvgBytesPerSec = format_.Format.nBlockAlign *
format_.Format.nSamplesPerSec;
- // This mask handles 6.1
- if (params.channels == 7) {
- format_.dwChannelMask = SPEAKER_FRONT_LEFT |
- SPEAKER_FRONT_RIGHT |
- SPEAKER_FRONT_CENTER |
- SPEAKER_LOW_FREQUENCY |
- SPEAKER_BACK_LEFT |
- SPEAKER_BACK_RIGHT |
- SPEAKER_BACK_CENTER;
+ if (params.channels > kMaxChannelsToMask) {
+ format_.dwChannelMask = kChannelsToMask[kMaxChannelsToMask];
} else {
- // This mask handles mono, stereo, 5.1, 7.1
- // TODO(fbarchard): Support masks for other channel layouts.
- format_.dwChannelMask = SPEAKER_FRONT_LEFT |
- SPEAKER_FRONT_RIGHT |
- SPEAKER_FRONT_CENTER |
- SPEAKER_LOW_FREQUENCY |
- SPEAKER_BACK_LEFT |
- SPEAKER_BACK_RIGHT |
- SPEAKER_SIDE_LEFT |
- SPEAKER_SIDE_RIGHT;
+ format_.dwChannelMask = kChannelsToMask[params.channels];
}
format_.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
format_.Samples.wValidBitsPerSample = params.bits_per_sample;