From ff4031c0ae89be5595055128752138573b8f0dff Mon Sep 17 00:00:00 2001 From: "fbarchard@chromium.org" Date: Tue, 26 Oct 2010 08:04:48 +0000 Subject: 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 --- media/audio/win/waveout_output_win.cc | 58 +++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'media') 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; -- cgit v1.1