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

Unified Diff: media/audio/audio_util.cc

Issue 9395057: Fix muted audio when playback rate != 1.0 or 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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
Index: media/audio/audio_util.cc
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index b4b8751885b570b2ebdabb30ae78f6122e7ca20a..6c5680d1a28d584b618b65aaab98843b5dbb5d6d 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -49,30 +49,6 @@ static void AdjustVolume(Format* buf_out,
}
}
-// Type is the datatype of a data point in the waveform (i.e. uint8, int16,
-// int32, etc).
-template <class Type>
-static void DoCrossfade(int bytes_to_crossfade, int number_of_channels,
- int bytes_per_channel, const Type* src, Type* dest) {
- DCHECK_EQ(sizeof(Type), static_cast<size_t>(bytes_per_channel));
- int number_of_samples =
- bytes_to_crossfade / (bytes_per_channel * number_of_channels);
-
- const Type* dest_end = dest + number_of_samples * number_of_channels;
- const Type* src_end = src + number_of_samples * number_of_channels;
-
- for (int i = 0; i < number_of_samples; ++i) {
- double crossfade_ratio = static_cast<double>(i) / number_of_samples;
- for (int j = 0; j < number_of_channels; ++j) {
- DCHECK_LT(dest, dest_end);
- DCHECK_LT(src, src_end);
- *dest = (*dest) * (1.0 - crossfade_ratio) + (*src) * crossfade_ratio;
- ++src;
- ++dest;
- }
- }
-}
-
static const int kChannel_L = 0;
static const int kChannel_R = 1;
static const int kChannel_C = 2;
@@ -413,27 +389,4 @@ bool IsWASAPISupported() {
#endif
-void Crossfade(int bytes_to_crossfade, int number_of_channels,
- int bytes_per_channel, const uint8* src, uint8* dest) {
- // TODO(vrk): The type punning below is no good!
- switch (bytes_per_channel) {
- case 4:
- DoCrossfade(bytes_to_crossfade, number_of_channels, bytes_per_channel,
- reinterpret_cast<const int32*>(src),
- reinterpret_cast<int32*>(dest));
- break;
- case 2:
- DoCrossfade(bytes_to_crossfade, number_of_channels, bytes_per_channel,
- reinterpret_cast<const int16*>(src),
- reinterpret_cast<int16*>(dest));
- break;
- case 1:
- DoCrossfade(bytes_to_crossfade, number_of_channels, bytes_per_channel,
- src, dest);
- break;
- default:
- NOTREACHED() << "Unsupported audio bit depth in crossfade.";
- }
-}
-
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698