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

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: Rebase ToT 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
« no previous file with comments | « media/audio/audio_util.h ('k') | media/base/seekable_buffer.h » ('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 8caced5204243dd7e1ee1337f6a6e5e7ce9dd386..0ce05fa1d02c08448884be8886ca017e42004f09 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -51,30 +51,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;
@@ -415,52 +391,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.";
- }
-}
-
-// The minimum number of samples in a hardware packet.
-// This value is selected so that we can handle down to 5khz sample rate.
-static const int kMinSamplesPerHardwarePacket = 1024;
-
-// The maximum number of samples in a hardware packet.
-// This value is selected so that we can handle up to 192khz sample rate.
-static const int kMaxSamplesPerHardwarePacket = 64 * 1024;
-
-// This constant governs the hardware audio buffer size, this value should be
-// chosen carefully.
-// This value is selected so that we have 8192 samples for 48khz streams.
-static const int kMillisecondsPerHardwarePacket = 170;
-
-uint32 SelectSamplesPerPacket(int sample_rate) {
- // Select the number of samples that can provide at least
- // |kMillisecondsPerHardwarePacket| worth of audio data.
- int samples = kMinSamplesPerHardwarePacket;
- while (samples <= kMaxSamplesPerHardwarePacket &&
- samples * base::Time::kMillisecondsPerSecond <
- sample_rate * kMillisecondsPerHardwarePacket) {
- samples *= 2;
- }
- return samples;
-}
-
} // namespace media
« no previous file with comments | « media/audio/audio_util.h ('k') | media/base/seekable_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698