diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn index 54c86dfa35415..8892e76c4c917 100644 --- a/media/audio/BUILD.gn +++ b/media/audio/BUILD.gn @@ -64,7 +64,6 @@ source_set("audio") { "audio_input_device.h", "audio_input_ipc.cc", "audio_input_ipc.h", - "audio_io.cc", "audio_io.h", "audio_manager.cc", "audio_manager.h", diff --git a/media/audio/audio_io.cc b/media/audio/audio_io.cc deleted file mode 100644 index 64ffc87fe8040..0000000000000 --- a/media/audio/audio_io.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/audio/audio_io.h" - -namespace media { - -int AudioOutputStream::AudioSourceCallback::OnMoreData( - AudioBus* dest, - uint32_t total_bytes_delay, - uint32_t frames_skipped) { - return 0; -} - -int AudioOutputStream::AudioSourceCallback::OnMoreData( - AudioBus* dest, - uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& device_position) { - return OnMoreData(dest, total_bytes_delay, frames_skipped); -} - -} // namespace media diff --git a/media/audio/audio_io.h b/media/audio/audio_io.h index 2d8d3c8ab7f3e..f80c4139b9eed 100644 --- a/media/audio/audio_io.h +++ b/media/audio/audio_io.h @@ -68,15 +68,12 @@ class MEDIA_EXPORT AudioOutputStream { // the number of frames it filled. |total_bytes_delay| contains current // number of bytes of delay buffered by the AudioOutputStream. // |frames_skipped| contains the number of frames skipped by the consumer. - virtual int OnMoreData(AudioBus* dest, - uint32_t total_bytes_delay, - uint32_t frames_skipped); - // An alternate version which provides also device stream position, - // by default it just invokes the above method. + // |device_position| if provided, contains position of currently audible + // signal. virtual int OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, uint32_t frames_skipped, - const StreamPosition& device_position); + const StreamPosition& device_position = {0, 0}) = 0; // There was an error while playing a buffer. Audio source cannot be // destroyed yet. No direct action needed by the AudioStream, but it is diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc index ec0b4605317da..e561a40ecb76d 100644 --- a/media/audio/audio_output_controller.cc +++ b/media/audio/audio_output_controller.cc @@ -164,7 +164,7 @@ void AudioOutputController::DoPlay() { return; // Ask for first packet. - sync_reader_->UpdatePendingBytes(0, 0); + sync_reader_->UpdatePendingBytes(0, 0, {0, 0}); state_ = kPlaying; @@ -217,7 +217,8 @@ void AudioOutputController::DoPause() { // Let the renderer know we've stopped. Necessary to let PPAPI clients know // audio has been shutdown. TODO(dalecurtis): This stinks. PPAPI should have // a better way to know when it should exit PPB_Audio_Shared::Run(). - sync_reader_->UpdatePendingBytes(std::numeric_limits::max(), 0); + sync_reader_->UpdatePendingBytes(std::numeric_limits::max(), 0, + {0, 0}); handler_->OnPaused(); } diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h index cc0c445341bbe..729a645b6f2ec 100644 --- a/media/audio/audio_output_controller.h +++ b/media/audio/audio_output_controller.h @@ -90,10 +90,9 @@ class MEDIA_EXPORT AudioOutputController // frames has been skipped by the renderer (typically the OS). The renderer // source can handle this appropriately depending on the type of source. An // ordinary file playout would ignore this. - virtual void UpdatePendingBytes( - uint32_t bytes, - uint32_t frames_skipped, - const StreamPosition& position = StreamPosition()) = 0; + virtual void UpdatePendingBytes(uint32_t bytes, + uint32_t frames_skipped, + const StreamPosition& position) = 0; // Attempts to completely fill |dest|, zeroing |dest| if the request can not // be fulfilled (due to timeout). diff --git a/media/audio/audio_output_stream_sink.cc b/media/audio/audio_output_stream_sink.cc index 460dedecf05c9..bc8b7d1d5d3c9 100644 --- a/media/audio/audio_output_stream_sink.cc +++ b/media/audio/audio_output_stream_sink.cc @@ -79,7 +79,8 @@ OutputDevice* AudioOutputStreamSink::GetOutputDevice() { int AudioOutputStreamSink::OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped) { + uint32_t frames_skipped, + const StreamPosition& position) { // Note: Runs on the audio thread created by the OS. base::AutoLock al(callback_lock_); if (!active_render_callback_) diff --git a/media/audio/audio_output_stream_sink.h b/media/audio/audio_output_stream_sink.h index 9981a6641ea90..2e08d3911ccf3 100644 --- a/media/audio/audio_output_stream_sink.h +++ b/media/audio/audio_output_stream_sink.h @@ -44,7 +44,8 @@ class MEDIA_EXPORT AudioOutputStreamSink // AudioSourceCallback implementation. int OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped) override; + uint32_t frames_skipped, + const StreamPosition& position) override; void OnError(AudioOutputStream* stream) override; private: diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc index 6aee89fabefaf..1f1834a79b31c 100644 --- a/media/audio/simple_sources.cc +++ b/media/audio/simple_sources.cc @@ -113,7 +113,8 @@ SineWaveAudioSource::~SineWaveAudioSource() { // but it is efficient enough for our simple needs. int SineWaveAudioSource::OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped) { + uint32_t frames_skipped, + const StreamPosition& position) { base::AutoLock auto_lock(time_lock_); callbacks_++; @@ -198,7 +199,8 @@ void FileSource::LoadWavFile(const base::FilePath& path_to_wav_file) { int FileSource::OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped) { + uint32_t frames_skipped, + const StreamPosition& position) { // Load the file if we haven't already. This load needs to happen on the // audio thread, otherwise we'll run on the UI thread on Mac for instance. // This will massively delay the first OnMoreData, but we'll catch up. @@ -248,7 +250,8 @@ BeepingSource::~BeepingSource() { int BeepingSource::OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped) { + uint32_t frames_skipped, + const StreamPosition& position) { // Accumulate the time from the last beep. interval_from_last_beep_ += base::TimeTicks::Now() - last_callback_time_; diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h index 4f153e6566fbd..8769475c2578f 100644 --- a/media/audio/simple_sources.h +++ b/media/audio/simple_sources.h @@ -35,7 +35,8 @@ class MEDIA_EXPORT SineWaveAudioSource // Implementation of AudioSourceCallback. int OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped) override; + uint32_t frames_skipped, + const StreamPosition& position) override; void OnError(AudioOutputStream* stream) override; // The number of OnMoreData() and OnError() calls respectively. @@ -62,7 +63,8 @@ class MEDIA_EXPORT FileSource : public AudioOutputStream::AudioSourceCallback, // Implementation of AudioSourceCallback. int OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped) override; + uint32_t frames_skipped, + const StreamPosition& position) override; void OnError(AudioOutputStream* stream) override; private: @@ -95,7 +97,8 @@ class BeepingSource : public AudioOutputStream::AudioSourceCallback { // Implementation of AudioSourceCallback. int OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped) override; + uint32_t frames_skipped, + const StreamPosition& position) override; void OnError(AudioOutputStream* stream) override; static void BeepOnce(); diff --git a/media/audio/sounds/audio_stream_handler.cc b/media/audio/sounds/audio_stream_handler.cc index 56d1b94b28b18..b06e7f0ce30bb 100644 --- a/media/audio/sounds/audio_stream_handler.cc +++ b/media/audio/sounds/audio_stream_handler.cc @@ -111,7 +111,8 @@ class AudioStreamHandler::AudioStreamContainer // Following methods could be called from *ANY* thread. int OnMoreData(AudioBus* dest, uint32_t /* total_bytes_delay */, - uint32_t /* frames_skipped */) override { + uint32_t /* frames_skipped */, + const StreamPosition& /* position */) override { base::AutoLock al(state_lock_); size_t bytes_written = 0; diff --git a/media/media.gyp b/media/media.gyp index 2b9365fcdbfe1..84f3e7b812744 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -134,7 +134,6 @@ 'audio/audio_input_device.h', 'audio/audio_input_ipc.cc', 'audio/audio_input_ipc.h', - 'audio/audio_io.cc', 'audio/audio_io.h', 'audio/audio_manager.cc', 'audio/audio_manager.h',