summaryrefslogtreecommitdiff
path: root/chromium/media/audio/win/audio_low_latency_output_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/media/audio/win/audio_low_latency_output_win.cc')
-rw-r--r--chromium/media/audio/win/audio_low_latency_output_win.cc50
1 files changed, 46 insertions, 4 deletions
diff --git a/chromium/media/audio/win/audio_low_latency_output_win.cc b/chromium/media/audio/win/audio_low_latency_output_win.cc
index c3a4facf84d..5767a6bafa1 100644
--- a/chromium/media/audio/win/audio_low_latency_output_win.cc
+++ b/chromium/media/audio/win/audio_low_latency_output_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -89,6 +89,7 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(
manager_(manager),
glitch_reporter_(SystemGlitchReporter::StreamType::kRender),
format_(),
+ params_(params),
opened_(false),
volume_(1.0),
packet_size_frames_(0),
@@ -102,6 +103,10 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(
source_(nullptr),
log_callback_(std::move(log_callback)) {
DCHECK(manager_);
+#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
+ if (params.format() == AudioParameters::AUDIO_BITSTREAM_DTS)
+ DCHECK_EQ(GetShareMode(), AUDCLNT_SHAREMODE_EXCLUSIVE);
+#endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
// The empty string is used to indicate a default device and the
// |device_role_| member controls whether that's the default or default
@@ -138,13 +143,28 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(
format_.Samples.wValidBitsPerSample = format->wBitsPerSample;
format_.dwChannelMask = CoreAudioUtil::GetChannelConfig(device_id, eRender);
format_.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
- SendLogMessage("%s => (audio engine format=[%s])", __func__,
- CoreAudioUtil::WaveFormatToString(&format_).c_str());
// Store size (in different units) of audio packets which we expect to
// get from the audio endpoint device in each render event.
packet_size_frames_ = params.frames_per_buffer();
packet_size_bytes_ = params.GetBytesPerBuffer(kSampleFormatF32);
+
+#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
+ if (params.format() == AudioParameters::AUDIO_BITSTREAM_DTS) {
+ format_.SubFormat = KSDATAFORMAT_SUBTYPE_IEC61937_DTS;
+ format->wBitsPerSample = 16;
+ format->nChannels = 2;
+ format_.dwChannelMask = KSAUDIO_SPEAKER_STEREO;
+ format_.Samples.wValidBitsPerSample = format->wBitsPerSample;
+ format->nBlockAlign = (format->wBitsPerSample / 8) * format->nChannels;
+ format->nAvgBytesPerSec = format->nSamplesPerSec * format->nBlockAlign;
+ packet_size_frames_ = 512;
+ packet_size_bytes_ = params.GetBytesPerBuffer(kSampleFormatS16);
+ }
+#endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
+ SendLogMessage("%s => (audio engine format=[%s])", __func__,
+ CoreAudioUtil::WaveFormatToString(&format_).c_str());
+
SendLogMessage("%s => (packet size=[%zu bytes/%zu audio frames/%.3f ms])",
__func__, packet_size_bytes_, packet_size_frames_,
params.GetBufferDuration().InMillisecondsF());
@@ -462,6 +482,10 @@ void WASAPIAudioOutputStream::Close() {
void WASAPIAudioOutputStream::Flush() {}
void WASAPIAudioOutputStream::SetVolume(double volume) {
+#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
+ if (params_.format() == AudioParameters::AUDIO_BITSTREAM_DTS)
+ return;
+#endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
SendLogMessage("%s({volume=%.2f})", __func__, volume);
float volume_float = static_cast<float>(volume);
if (volume_float < 0.0f || volume_float > 1.0f) {
@@ -707,11 +731,29 @@ bool WASAPIAudioOutputStream::RenderAudioFromSource(UINT64 device_frequency) {
// Read a data packet from the registered client source and
// deliver a delay estimate in the same callback to the client.
+#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
+ if (params_.format() == AudioParameters::AUDIO_BITSTREAM_DTS) {
+ std::unique_ptr<AudioBus> audio_bus(
+ AudioBus::WrapMemory(params_, audio_data));
+ audio_bus_->set_is_bitstream_format(true);
+ int frames_filled =
+ source_->OnMoreData(delay, delay_timestamp, 0, audio_bus.get());
+
+ // During pause/seek, keep the pipeline filled with zero'ed frames.
+ if (!frames_filled)
+ memset(audio_data, 0, packet_size_frames_);
+
+ // Release the buffer space acquired in the GetBuffer() call.
+ // Render silence if we were not able to fill up the buffer totally.
+ audio_render_client_->ReleaseBuffer(packet_size_frames_, 0);
+ num_written_frames_ += packet_size_frames_;
+ return true;
+ }
+#endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
int frames_filled =
source_->OnMoreData(delay, delay_timestamp, 0, audio_bus_.get());
uint32_t num_filled_bytes = frames_filled * format_.Format.nBlockAlign;
DCHECK_LE(num_filled_bytes, packet_size_bytes_);
-
audio_bus_->Scale(volume_);
// We skip clipping since that occurs at the shared memory boundary.