Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Unified Diff: media/audio/audio_util.cc

Issue 12082111: Delete AudioOutputMixer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix .gyp Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_util.h ('k') | media/audio/audio_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index 4c446dd8012bb1e9cb1d45ac119aa0c3d1341f3e..7342801f570414847cfacd810c7ac0fc144b46b6 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -70,20 +70,6 @@ static void AdjustVolume(Format* buf_out,
}
}
-static const int kChannel_L = 0;
-static const int kChannel_R = 1;
-static const int kChannel_C = 2;
-
-template<class Fixed, int min_value, int max_value>
-static int AddSaturated(int val, int adder) {
- Fixed sum = static_cast<Fixed>(val) + static_cast<Fixed>(adder);
- if (sum > max_value)
- return max_value;
- if (sum < min_value)
- return min_value;
- return static_cast<int>(sum);
-}
-
// AdjustVolume() does an in place audio sample change.
bool AdjustVolume(void* buf,
size_t buflen,
@@ -122,72 +108,6 @@ bool AdjustVolume(void* buf,
return false;
}
-// TODO(enal): use template specialization and size-specific intrinsics.
-// Call is on the time-critical path, and by using SSE/AVX
-// instructions we can speed things up by ~4-8x, more for the case
-// when we have to adjust volume as well.
-template<class Format, class Fixed, int min_value, int max_value, int bias>
-static void MixStreams(Format* dst, Format* src, int count, float volume) {
- if (volume == 0.0f)
- return;
- if (volume == 1.0f) {
- // Most common case -- no need to adjust volume.
- for (int i = 0; i < count; ++i) {
- Fixed value = AddSaturated<Fixed, min_value, max_value>(dst[i] - bias,
- src[i] - bias);
- dst[i] = static_cast<Format>(value + bias);
- }
- } else {
- // General case -- have to adjust volume before mixing.
- const int fixed_volume = static_cast<int>(volume * 65536);
- for (int i = 0; i < count; ++i) {
- Fixed adjusted_src = ScaleChannel<Fixed>(src[i] - bias, fixed_volume);
- Fixed value = AddSaturated<Fixed, min_value, max_value>(dst[i] - bias,
- adjusted_src);
- dst[i] = static_cast<Format>(value + bias);
- }
- }
-}
-
-void MixStreams(void* dst,
- void* src,
- size_t buflen,
- int bytes_per_sample,
- float volume) {
- DCHECK(dst);
- DCHECK(src);
- DCHECK_GE(volume, 0.0f);
- DCHECK_LE(volume, 1.0f);
- switch (bytes_per_sample) {
- case 1:
- MixStreams<uint8, int32, kint8min, kint8max, 128>(
- static_cast<uint8*>(dst),
- static_cast<uint8*>(src),
- buflen,
- volume);
- break;
- case 2:
- DCHECK_EQ(0u, buflen % 2);
- MixStreams<int16, int32, kint16min, kint16max, 0>(
- static_cast<int16*>(dst),
- static_cast<int16*>(src),
- buflen / 2,
- volume);
- break;
- case 4:
- DCHECK_EQ(0u, buflen % 4);
- MixStreams<int32, int64, kint32min, kint32max, 0>(
- static_cast<int32*>(dst),
- static_cast<int32*>(src),
- buflen / 4,
- volume);
- break;
- default:
- NOTREACHED() << "Illegal bytes per sample";
- break;
- }
-}
-
int GetAudioHardwareSampleRate() {
#if defined(OS_MACOSX)
// Hardware sample-rate on the Mac can be configured, so we must query.
« no previous file with comments | « media/audio/audio_util.h ('k') | media/audio/audio_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698