diff options
author | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 16:10:48 +0000 |
---|---|---|
committer | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 16:10:48 +0000 |
commit | c11c8c6f35a3614b43e5b75731f819f4c5f1f207 (patch) | |
tree | 314acdfb5106a69e19feba493ae89dc7541737d9 /media | |
parent | 768708171bb6c8dec34509c11460d3bc355a3e81 (diff) | |
download | chromium_src-c11c8c6f35a3614b43e5b75731f819f4c5f1f207.zip chromium_src-c11c8c6f35a3614b43e5b75731f819f4c5f1f207.tar.gz chromium_src-c11c8c6f35a3614b43e5b75731f819f4c5f1f207.tar.bz2 |
enable folding code for 6.1 and 7.1 surround sound.
BUG=54423
TEST=audio unittest and http://fbarchard0-w.ad.corp.google.com/testmatrix/gromit/gromit8.webm
Review URL: http://codereview.chromium.org/3353022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/audio_util.cc | 10 | ||||
-rw-r--r-- | media/audio/audio_util_unittest.cc | 15 | ||||
-rw-r--r-- | media/audio/linux/alsa_output.cc | 4 | ||||
-rw-r--r-- | media/audio/win/audio_manager_win.cc | 6 | ||||
-rw-r--r-- | media/audio/win/waveout_output_win.h | 2 |
5 files changed, 25 insertions, 12 deletions
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index 9f4e6da..e3e94cd 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -59,9 +59,9 @@ static int AddChannel(int val, template<class Format, class Fixed, int min_value, int max_value, int bias> static void FoldChannels(Format* buf_out, - int sample_count, - const float volume, - int channels) { + int sample_count, + const float volume, + int channels) { Format* buf_in = buf_out; const int center_volume = static_cast<int>(volume * 0.707f * 65536); const int fixed_volume = static_cast<int>(volume * 65536); @@ -100,7 +100,7 @@ bool AdjustVolume(void* buf, memset(buf, 0, buflen); return true; } - if (channels > 0 && channels <= 6 && bytes_per_sample > 0) { + if (channels > 0 && channels <= 8 && bytes_per_sample > 0) { int sample_count = buflen / bytes_per_sample; const int fixed_volume = static_cast<int>(volume * 65536); if (bytes_per_sample == 1) { @@ -130,7 +130,7 @@ bool FoldChannels(void* buf, float volume) { DCHECK(buf); DCHECK(volume >= 0.0f && volume <= 1.0f); - if (channels >= 5 && channels <= 6 && bytes_per_sample > 0) { + if (channels > 2 && channels <= 8 && bytes_per_sample > 0) { int sample_count = buflen / (channels * bytes_per_sample); if (bytes_per_sample == 1) { FoldChannels<uint8, int32, -128, 127, 128>( diff --git a/media/audio/audio_util_unittest.cc b/media/audio/audio_util_unittest.cc index 6d5ad74..ae653c6 100644 --- a/media/audio/audio_util_unittest.cc +++ b/media/audio/audio_util_unittest.cc @@ -123,6 +123,21 @@ TEST(AudioUtilTest, FoldChannels_s32) { EXPECT_EQ(0, expected_test); } +// Fold 7.1 +TEST(AudioUtilTest, FoldChannels71_s16) { + // Test FoldChannels() on 16 bit samples. + int16 samples_s16[8] = { 1, 3, 12, 7, 13, 17, 30, 40 }; + int16 expected_s16[2] = { static_cast<int16>(12 * .707 + 1), + static_cast<int16>(12 * .707 + 3) }; + bool result_s16 = media::FoldChannels(samples_s16, sizeof(samples_s16), + 8, // channels. + sizeof(samples_s16[0]), + 1.00f); + EXPECT_EQ(true, result_s16); + int expected_test = memcmp(samples_s16, expected_s16, sizeof(expected_s16)); + EXPECT_EQ(0, expected_test); +} + // This mimics 1 second of audio at 48000 samples per second. // Running the unittest will produce timing. TEST(AudioUtilTest, DISABLED_FoldChannels_s16_benchmark) { diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index 422f91ba..98eaf14 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -771,12 +771,12 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) { // For the kDefaultDevice device, we can only reliably depend on 2-channel // output to have the correct ordering according to Lennart. For the channel - // formats that we know how to downmix from (5 channel to 6 channel), setup + // formats that we know how to downmix from (3 channel to 8 channel), setup // downmixing. // // TODO(ajwong): We need a SupportsFolding() function. uint32 default_channels = channels_; - if (default_channels >= 5 && default_channels <= 6) { + if (default_channels > 2 && default_channels <= 8) { should_downmix_ = true; default_channels = 2; } diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc index 2e65879..3d5c137 100644 --- a/media/audio/win/audio_manager_win.cc +++ b/media/audio/win/audio_manager_win.cc @@ -17,12 +17,10 @@ namespace { -// Up to 6 channels can be passed to the driver. +// Up to 8 channels can be passed to the driver. // This should work, given the right drivers, but graceful error handling is // needed. -// In theory 7.1 could also be supported, but it has not been tested. -// TODO(sergeyu): Test that 7.1 audio works. -const int kWinMaxChannels = 6; +const int kWinMaxChannels = 8; const int kWinMaxInputChannels = 2; const int kMaxSamplesPerPacket = media::Limits::kMaxSampleRate; diff --git a/media/audio/win/waveout_output_win.h b/media/audio/win/waveout_output_win.h index 7b87e4e..7bee81e 100644 --- a/media/audio/win/waveout_output_win.h +++ b/media/audio/win/waveout_output_win.h @@ -89,7 +89,7 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream { // Volume level from 0 to 1. float volume_; - // Channels from 0 to 6. + // Channels from 0 to 8. const int channels_; // Number of bytes yet to be played in the hardware buffer. |