summaryrefslogtreecommitdiffstats
path: root/media/audio
diff options
context:
space:
mode:
authorvrk@chromium.org <vrk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-06 00:48:37 +0000
committervrk@chromium.org <vrk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-06 00:48:37 +0000
commite4eccfdae7c8b34056e7b61450b0be30825fc5d2 (patch)
treef5090ba1d0d83f9df413ddf370eb12acbec8e7d2 /media/audio
parent8e248501d06d6536bdc8f37d20d8c600f848485b (diff)
downloadchromium_src-e4eccfdae7c8b34056e7b61450b0be30825fc5d2.zip
chromium_src-e4eccfdae7c8b34056e7b61450b0be30825fc5d2.tar.gz
chromium_src-e4eccfdae7c8b34056e7b61450b0be30825fc5d2.tar.bz2
Fix muted audio when playback rate != 1.0 or 0.0
Rewrites the logic in AudioRendererAlgorithmBase to be able to output audio at any point of a sped-up/slowed down window, instead of only outputting audio in full multiples of windows. BUG=108239 TEST=media_unittests, manual testing on video test matrix Review URL: http://codereview.chromium.org/9395057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r--media/audio/audio_util.cc72
-rw-r--r--media/audio/audio_util.h5
2 files changed, 0 insertions, 77 deletions
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index 8caced5..0ce05fa 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
diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h
index 51d707a..e2f57fa 100644
--- a/media/audio/audio_util.h
+++ b/media/audio/audio_util.h
@@ -118,11 +118,6 @@ MEDIA_EXPORT bool IsWASAPISupported();
#endif // defined(OS_WIN)
-// Crossfades |bytes_to_crossfade| bytes of data in |dest| with the
-// data in |src|. Assumes there is room in |dest| and enough data in |src|.
-MEDIA_EXPORT void Crossfade(int bytes_to_crossfade, int number_of_channels,
- int bytes_per_channel, const uint8* src,
- uint8* dest);
} // namespace media
#endif // MEDIA_AUDIO_AUDIO_UTIL_H_