From 7807ac714edc9d9a822a5c43ab3c85a5b7aebeb0 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Wed, 5 Oct 2016 11:46:08 +0200 Subject: [PATCH] Revert AudioDestinationNode.devicePosition commits This reverts the following commits: * 2b2cbc8c ("[Windows] Implementation of 'AudioDestinationNode.devicePosition' attribute") * 43d41bf6 ("Fix calling of AudioOutputStream::AudioSourceCallback API") * fd8c95a5 ("Remove unused private field device_position_") This code was added when Crosswalk was being used as an alternative implementation for some changes to the WebAudio spec: * https://github.com/WebAudio/web-audio-api/issues/12 * https://github.com/WebAudio/web-audio-api/pull/754 The spec has since been changed and upstream Chromium is being adapted, so there is no need to keep these patches in Crosswalk any longer. Additionally, this code in its present form has caused serious regressions in WebRTC support (the WebRTC Crosswalk sample did not produce any sound). Thanks to Michael Walton for the investigation leading to this commit. BUG=XWALK-7030 BUG=XWALK-7225 --- .../renderer_host/media/audio_sync_reader.cc | 4 +-- .../renderer_host/media/audio_sync_reader.h | 5 +-- .../media/renderer_webaudiodevice_impl.cc | 11 ++----- .../media/renderer_webaudiodevice_impl.h | 4 +-- media/audio/audio_device_thread.cc | 7 +--- media/audio/audio_device_thread.h | 6 +--- media/audio/audio_input_device.cc | 6 ++-- media/audio/audio_io.h | 10 +----- media/audio/audio_output_controller.cc | 11 +++---- media/audio/audio_output_controller.h | 6 ++-- media/audio/audio_output_device.cc | 8 ++--- media/audio/audio_output_resampler.cc | 19 +++-------- media/audio/audio_output_stream_sink.cc | 3 +- media/audio/audio_output_stream_sink.h | 3 +- media/audio/simple_sources.cc | 9 ++--- media/audio/simple_sources.h | 9 ++--- media/audio/sounds/audio_stream_handler.cc | 3 +- .../audio/win/audio_low_latency_output_win.cc | 25 ++------------ .../audio/win/audio_low_latency_output_win.h | 2 -- media/base/BUILD.gn | 1 - media/base/audio_renderer_sink.cc | 24 -------------- media/base/audio_renderer_sink.h | 12 ++----- media/media.gyp | 1 - .../WebKit/Source/modules/modules.gypi | 3 -- .../modules/webaudio/AudioDestinationNode.cpp | 33 +------------------ .../modules/webaudio/AudioDestinationNode.h | 11 +------ .../modules/webaudio/AudioDestinationNode.idl | 1 - .../modules/webaudio/AudioTimestamp.idl | 10 ------ .../platform/audio/AudioDestination.cpp | 8 ++--- .../Source/platform/audio/AudioDestination.h | 4 +-- .../Source/platform/audio/AudioIOCallback.h | 5 +-- .../platform/exported/WebAudioDevice.cpp | 19 ----------- .../WebKit/public/platform/WebAudioDevice.h | 12 ------- 33 files changed, 43 insertions(+), 252 deletions(-) delete mode 100644 media/base/audio_renderer_sink.cc delete mode 100644 third_party/WebKit/Source/modules/webaudio/AudioTimestamp.idl diff --git a/content/browser/renderer_host/media/audio_sync_reader.cc b/content/browser/renderer_host/media/audio_sync_reader.cc index 106c4a4cd2c80..943cedb4d0b6a 100644 --- a/content/browser/renderer_host/media/audio_sync_reader.cc +++ b/content/browser/renderer_host/media/audio_sync_reader.cc @@ -107,8 +107,7 @@ AudioSyncReader::~AudioSyncReader() { // media::AudioOutputController::SyncReader implementations. void AudioSyncReader::UpdatePendingBytes(uint32_t bytes, - uint32_t frames_skipped, - const media::StreamPosition& device_position) { + uint32_t frames_skipped) { // Increase the number of skipped frames stored in shared memory. We don't // send it over the socket since sending more than 4 bytes might lead to being // descheduled. The reading side will zero it when consumed. @@ -121,7 +120,6 @@ void AudioSyncReader::UpdatePendingBytes(uint32_t bytes, output_bus_->Zero(); socket_->Send(&bytes, sizeof(bytes)); - socket_->Send(&device_position, sizeof(device_position)); ++buffer_index_; } diff --git a/content/browser/renderer_host/media/audio_sync_reader.h b/content/browser/renderer_host/media/audio_sync_reader.h index b0ce3069e8a92..05c68e9d2c1fa 100644 --- a/content/browser/renderer_host/media/audio_sync_reader.h +++ b/content/browser/renderer_host/media/audio_sync_reader.h @@ -39,10 +39,7 @@ class AudioSyncReader : public media::AudioOutputController::SyncReader { ~AudioSyncReader() override; // media::AudioOutputController::SyncReader implementations. - void UpdatePendingBytes( - uint32_t bytes, - uint32_t frames_skipped, - const media::StreamPosition& position) override; + void UpdatePendingBytes(uint32_t bytes, uint32_t frames_skipped) override; void Read(media::AudioBus* dest) override; void Close() override; diff --git a/content/renderer/media/renderer_webaudiodevice_impl.cc b/content/renderer/media/renderer_webaudiodevice_impl.cc index f55984e44956f..a9fba3b4e21ec 100644 --- a/content/renderer/media/renderer_webaudiodevice_impl.cc +++ b/content/renderer/media/renderer_webaudiodevice_impl.cc @@ -102,8 +102,7 @@ double RendererWebAudioDeviceImpl::sampleRate() { int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest, uint32_t frames_delayed, - uint32_t frames_skipped, - const media::StreamPosition& position) { + uint32_t frames_skipped) { #if defined(OS_ANDROID) if (is_first_buffer_after_silence_) { DCHECK(!is_using_null_audio_sink_); @@ -121,15 +120,9 @@ int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest, // TODO(xians): Remove the following |web_audio_source_data| after // changing the blink interface. WebVector web_audio_source_data(static_cast(0)); - - double seconds = position.ticks - / static_cast(base::Time::kMicrosecondsPerSecond); - StreamPosition device_position(static_cast(position.frames), - seconds); client_callback_->render(web_audio_source_data, web_audio_dest_data, - dest->frames(), - device_position); + dest->frames()); #if defined(OS_ANDROID) const bool is_zero = dest->AreFramesZero(); diff --git a/content/renderer/media/renderer_webaudiodevice_impl.h b/content/renderer/media/renderer_webaudiodevice_impl.h index fc08d6a34c5b7..48e7fad2d6a17 100644 --- a/content/renderer/media/renderer_webaudiodevice_impl.h +++ b/content/renderer/media/renderer_webaudiodevice_impl.h @@ -11,7 +11,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/threading/thread_checker.h" -#include "media/audio/audio_io.h" #include "media/base/audio_parameters.h" #include "media/base/audio_renderer_sink.h" #include "third_party/WebKit/public/platform/WebAudioDevice.h" @@ -46,8 +45,7 @@ class RendererWebAudioDeviceImpl // AudioRendererSink::RenderCallback implementation. int Render(media::AudioBus* dest, uint32_t frames_delayed, - uint32_t frames_skipped, - const media::StreamPosition& position) override; + uint32_t frames_skipped) override; void OnRenderError() override; diff --git a/media/audio/audio_device_thread.cc b/media/audio/audio_device_thread.cc index 3e03baf3af989..20874599e68f5 100644 --- a/media/audio/audio_device_thread.cc +++ b/media/audio/audio_device_thread.cc @@ -175,11 +175,6 @@ void AudioDeviceThread::Thread::Run() { if (bytes_read != sizeof(pending_data)) break; - StreamPosition device_position = { 0, 0 }; - bytes_read = socket_.Receive(&device_position, sizeof(device_position)); - if (bytes_read != sizeof(device_position)) - break; - // std::numeric_limits::max() is a special signal which is // returned after the browser stops the output device in response to a // renderer side request. @@ -191,7 +186,7 @@ void AudioDeviceThread::Thread::Run() { if (pending_data != std::numeric_limits::max()) { base::AutoLock auto_lock(callback_lock_); if (callback_) - callback_->Process(pending_data, device_position); + callback_->Process(pending_data); } // The usage of |synchronized_buffers_| differs between input and output diff --git a/media/audio/audio_device_thread.h b/media/audio/audio_device_thread.h index af2b2ccb3ac99..61e5e8724ddc2 100644 --- a/media/audio/audio_device_thread.h +++ b/media/audio/audio_device_thread.h @@ -12,7 +12,6 @@ #include "base/memory/shared_memory.h" #include "base/sync_socket.h" #include "base/synchronization/lock.h" -#include "media/audio/audio_io.h" #include "media/base/audio_parameters.h" #include "media/base/media_export.h" @@ -22,7 +21,6 @@ class MessageLoop; namespace media { class AudioBus; -struct StreamPosition; // Data transfer between browser and render process uses a combination // of sync sockets and shared memory. To read from the socket and render @@ -54,9 +52,7 @@ class MEDIA_EXPORT AudioDeviceThread { virtual void MapSharedMemory() = 0; // Called whenever we receive notifications about pending input data. - virtual void Process( - uint32_t pending_data, - const StreamPosition& position) = 0; + virtual void Process(uint32_t pending_data) = 0; protected: // Protected so that derived classes can access directly. diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc index 00f6593b43227..fc6b39285ad36 100644 --- a/media/audio/audio_input_device.cc +++ b/media/audio/audio_input_device.cc @@ -41,7 +41,7 @@ class AudioInputDevice::AudioThreadCallback void MapSharedMemory() override; // Called whenever we receive notifications about pending data. - void Process(uint32_t pending_data, const StreamPosition& position) override; + void Process(uint32_t pending_data) override; private: int current_segment_id_; @@ -302,9 +302,7 @@ void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { } } -void AudioInputDevice::AudioThreadCallback::Process( - uint32_t pending_data, - const StreamPosition& position) { +void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { // The shared memory represents parameters, size of the data buffer and the // actual data buffer containing audio data. Map the memory into this // structure and parse out parameters and the data area. diff --git a/media/audio/audio_io.h b/media/audio/audio_io.h index f80c4139b9eed..66ff3f2dc98cf 100644 --- a/media/audio/audio_io.h +++ b/media/audio/audio_io.h @@ -49,11 +49,6 @@ namespace media { -struct MEDIA_EXPORT StreamPosition { - int64_t frames; - int64_t ticks; // Obtained from base::TimeTicks::ToInternalValue(). -}; - class MEDIA_EXPORT AudioOutputStream { public: // Audio sources must implement AudioSourceCallback. This interface will be @@ -68,12 +63,9 @@ 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. - // |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 = {0, 0}) = 0; + uint32_t frames_skipped) = 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 1fa639a9351a8..f8523f037f378 100644 --- a/media/audio/audio_output_controller.cc +++ b/media/audio/audio_output_controller.cc @@ -172,7 +172,7 @@ void AudioOutputController::DoPlay() { return; // Ask for first packet. - sync_reader_->UpdatePendingBytes(0, 0, {0, 0}); + sync_reader_->UpdatePendingBytes(0, 0); state_ = kPlaying; @@ -225,8 +225,7 @@ 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, - {0, 0}); + sync_reader_->UpdatePendingBytes(std::numeric_limits::max(), 0); handler_->OnPaused(); } @@ -294,8 +293,7 @@ void AudioOutputController::DoReportError() { int AudioOutputController::OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& device_position) { + uint32_t frames_skipped) { TRACE_EVENT0("audio", "AudioOutputController::OnMoreData"); // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck() @@ -309,8 +307,7 @@ int AudioOutputController::OnMoreData(AudioBus* dest, const int frames = dest->frames(); sync_reader_->UpdatePendingBytes( - total_bytes_delay + frames * params_.GetBytesPerFrame(), frames_skipped, - device_position); + total_bytes_delay + frames * params_.GetBytesPerFrame(), frames_skipped); if (will_monitor_audio_levels()) power_monitor_.Scan(*dest, frames); diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h index 233a5aa4bcf16..1f5c358ae3ced 100644 --- a/media/audio/audio_output_controller.h +++ b/media/audio/audio_output_controller.h @@ -93,8 +93,7 @@ class MEDIA_EXPORT AudioOutputController // 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) = 0; + uint32_t frames_skipped) = 0; // Attempts to completely fill |dest|, zeroing |dest| if the request can not // be fulfilled (due to timeout). @@ -166,8 +165,7 @@ class MEDIA_EXPORT AudioOutputController // AudioSourceCallback implementation. int OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& device_position) override; + uint32_t frames_skipped) override; void OnError(AudioOutputStream* stream) override; // AudioDeviceListener implementation. When called AudioOutputController will diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc index 2d472ea27e321..c8e23697f537a 100644 --- a/media/audio/audio_output_device.cc +++ b/media/audio/audio_output_device.cc @@ -39,7 +39,7 @@ class AudioOutputDevice::AudioThreadCallback void MapSharedMemory() override; // Called whenever we receive notifications about pending data. - void Process(uint32_t pending_data, const StreamPosition& position) override; + void Process(uint32_t pending_data) override; private: AudioRendererSink::RenderCallback* render_callback_; @@ -445,9 +445,7 @@ void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { } // Called whenever we receive notifications about pending data. -void AudioOutputDevice::AudioThreadCallback::Process( - uint32_t pending_data, - const StreamPosition& position) { +void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) { // Convert the number of pending bytes in the render buffer into frames. double frames_delayed = static_cast(pending_data) / bytes_per_frame_; @@ -477,7 +475,7 @@ void AudioOutputDevice::AudioThreadCallback::Process( // the shared memory the Render() call is writing directly into the shared // memory. render_callback_->Render(output_bus_.get(), std::round(frames_delayed), - frames_skipped, position); + frames_skipped); } } // namespace media diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc index 0d6c34b407289..f3b24cd86596d 100644 --- a/media/audio/audio_output_resampler.cc +++ b/media/audio/audio_output_resampler.cc @@ -33,8 +33,7 @@ class OnMoreDataConverter // AudioSourceCallback interface. int OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) override; + uint32_t frames_skipped) override; void OnError(AudioOutputStream* stream) override; // Sets |source_callback_|. If this is not a new object, then Stop() must be @@ -74,9 +73,6 @@ class OnMoreDataConverter // stream has been stopped. bool error_occurred_; - // Information about last recodred stream output position. - StreamPosition device_position_; - DISALLOW_COPY_AND_ASSIGN(OnMoreDataConverter); }; @@ -353,8 +349,7 @@ OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, source_callback_(nullptr), input_bytes_per_second_(input_params.GetBytesPerSecond()), audio_converter_(input_params, output_params, false), - error_occurred_(false), - device_position_() {} + error_occurred_(false) {} OnMoreDataConverter::~OnMoreDataConverter() { // Ensure Stop() has been called so we don't end up with an AudioOutputStream @@ -381,9 +376,7 @@ void OnMoreDataConverter::Stop() { int OnMoreDataConverter::OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) { - device_position_ = position; + uint32_t frames_skipped) { current_total_bytes_delay_ = total_bytes_delay; audio_converter_.Convert(dest); @@ -402,10 +395,8 @@ double OnMoreDataConverter::ProvideInput(AudioBus* dest, buffer_delay.InSecondsF() * input_bytes_per_second_)); // Retrieve data from the original callback. - const int frames = source_callback_->OnMoreData(dest, - new_total_bytes_delay, - 0, - device_position_); + const int frames = + source_callback_->OnMoreData(dest, new_total_bytes_delay, 0); // Zero any unfilled frames if anything was filled, otherwise we'll just // return a volume of zero and let AudioConverter drop the output. diff --git a/media/audio/audio_output_stream_sink.cc b/media/audio/audio_output_stream_sink.cc index 7ef5a4c5db72b..3acc6a8947ede 100644 --- a/media/audio/audio_output_stream_sink.cc +++ b/media/audio/audio_output_stream_sink.cc @@ -79,8 +79,7 @@ OutputDeviceInfo AudioOutputStreamSink::GetOutputDeviceInfo() { int AudioOutputStreamSink::OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) { + uint32_t frames_skipped) { // 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 7866a2131f54f..d8656ee6faad9 100644 --- a/media/audio/audio_output_stream_sink.h +++ b/media/audio/audio_output_stream_sink.h @@ -44,8 +44,7 @@ class MEDIA_EXPORT AudioOutputStreamSink // AudioSourceCallback implementation. int OnMoreData(AudioBus* dest, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) override; + uint32_t frames_skipped) override; void OnError(AudioOutputStream* stream) override; private: diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc index ccf7ef3c11b81..582fdcb8f4a52 100644 --- a/media/audio/simple_sources.cc +++ b/media/audio/simple_sources.cc @@ -117,8 +117,7 @@ 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, - const StreamPosition& position) { + uint32_t frames_skipped) { base::AutoLock auto_lock(time_lock_); callbacks_++; @@ -203,8 +202,7 @@ 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, - const StreamPosition& position) { + uint32_t frames_skipped) { // 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. @@ -254,8 +252,7 @@ BeepingSource::~BeepingSource() { int BeepingSource::OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) { + uint32_t frames_skipped) { // 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 a5992c0c2bb3f..4bf644377fdbf 100644 --- a/media/audio/simple_sources.h +++ b/media/audio/simple_sources.h @@ -37,8 +37,7 @@ class MEDIA_EXPORT SineWaveAudioSource // Implementation of AudioSourceCallback. int OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) override; + uint32_t frames_skipped) override; void OnError(AudioOutputStream* stream) override; // The number of OnMoreData() and OnError() calls respectively. @@ -65,8 +64,7 @@ class MEDIA_EXPORT FileSource : public AudioOutputStream::AudioSourceCallback, // Implementation of AudioSourceCallback. int OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) override; + uint32_t frames_skipped) override; void OnError(AudioOutputStream* stream) override; private: @@ -99,8 +97,7 @@ class BeepingSource : public AudioOutputStream::AudioSourceCallback { // Implementation of AudioSourceCallback. int OnMoreData(AudioBus* audio_bus, uint32_t total_bytes_delay, - uint32_t frames_skipped, - const StreamPosition& position) override; + uint32_t frames_skipped) 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 bf91463ddcf6f..74f7d70fc47e0 100644 --- a/media/audio/sounds/audio_stream_handler.cc +++ b/media/audio/sounds/audio_stream_handler.cc @@ -111,8 +111,7 @@ class AudioStreamHandler::AudioStreamContainer // Following methods could be called from *ANY* thread. int OnMoreData(AudioBus* dest, uint32_t /* total_bytes_delay */, - uint32_t /* frames_skipped */, - const StreamPosition& /* position */) override { + uint32_t /* frames_skipped */) override { base::AutoLock al(state_lock_); size_t bytes_written = 0; diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc index 6aaf5e1cfcbbc..9fa035d80ba6a 100644 --- a/media/audio/win/audio_low_latency_output_win.cc +++ b/media/audio/win/audio_low_latency_output_win.cc @@ -71,7 +71,6 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, share_mode_(GetShareMode()), num_written_frames_(0), source_(NULL), - hns_units_to_perf_count_(0.0), audio_bus_(AudioBus::Create(params)) { DCHECK(manager_); @@ -128,14 +127,6 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, // Create the event which will be set in Stop() when capturing shall stop. stop_render_event_.Set(CreateEvent(NULL, FALSE, FALSE, NULL)); DCHECK(stop_render_event_.IsValid()); - - LARGE_INTEGER performance_frequency; - if (QueryPerformanceFrequency(&performance_frequency)) { - hns_units_to_perf_count_ = - (static_cast(performance_frequency.QuadPart) / 10000000.0); - } else { - DLOG(ERROR) << "High-resolution performance counters are not supported."; - } } WASAPIAudioOutputStream::~WASAPIAudioOutputStream() { @@ -520,11 +511,8 @@ bool WASAPIAudioOutputStream::RenderAudioFromSource(UINT64 device_frequency) { // can typically be utilized by an acoustic echo-control (AEC) // unit at the render side. UINT64 position = 0; - UINT64 qpc_position = 0; uint32_t audio_delay_bytes = 0; - StreamPosition device_position = { 0, 0 }; - - hr = audio_clock_->GetPosition(&position, &qpc_position); + hr = audio_clock_->GetPosition(&position, NULL); if (SUCCEEDED(hr)) { // Stream position of the sample that is currently playing // through the speaker. @@ -541,22 +529,13 @@ bool WASAPIAudioOutputStream::RenderAudioFromSource(UINT64 device_frequency) { // render client using the OnMoreData() callback. audio_delay_bytes = (pos_last_sample_written_frames - pos_sample_playing_frames) * format_.Format.nBlockAlign; - if (hns_units_to_perf_count_) { - device_position.frames = pos_sample_playing_frames; - device_position.ticks = - base::TimeTicks::FromQPCValue( - qpc_position * hns_units_to_perf_count_).ToInternalValue(); - } } // Read a data packet from the registered client source and // deliver a delay estimate in the same callback to the client. int frames_filled = - source_->OnMoreData(audio_bus_.get(), - audio_delay_bytes, - 0, - device_position); + source_->OnMoreData(audio_bus_.get(), audio_delay_bytes, 0); uint32_t num_filled_bytes = frames_filled * format_.Format.nBlockAlign; DCHECK_LE(num_filled_bytes, packet_size_bytes_); diff --git a/media/audio/win/audio_low_latency_output_win.h b/media/audio/win/audio_low_latency_output_win.h index 52fe6cc079e54..97d81b93fc614 100644 --- a/media/audio/win/audio_low_latency_output_win.h +++ b/media/audio/win/audio_low_latency_output_win.h @@ -239,8 +239,6 @@ class MEDIA_EXPORT WASAPIAudioOutputStream : // This event will be signaled when rendering shall stop. base::win::ScopedHandle stop_render_event_; - double hns_units_to_perf_count_; - // Container for retrieving data from AudioSourceCallback::OnMoreData(). std::unique_ptr audio_bus_; diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn index ad0054cba0e86..4984921dc1372 100644 --- a/media/base/BUILD.gn +++ b/media/base/BUILD.gn @@ -61,7 +61,6 @@ source_set("base") { "audio_renderer_mixer.h", "audio_renderer_mixer_input.cc", "audio_renderer_mixer_input.h", - "audio_renderer_sink.cc", "audio_renderer_sink.h", "audio_shifter.cc", "audio_shifter.h", diff --git a/media/base/audio_renderer_sink.cc b/media/base/audio_renderer_sink.cc deleted file mode 100644 index a308e189c14c8..0000000000000 --- a/media/base/audio_renderer_sink.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/base/audio_renderer_sink.h" - -namespace media { - -int AudioRendererSink::RenderCallback::Render( - AudioBus* dest, - uint32_t audio_delay_milliseconds, - uint32_t frames_skipped) { - return 0; -} - -int AudioRendererSink::RenderCallback::Render( - AudioBus* dest, - uint32_t audio_delay_milliseconds, - uint32_t frames_skipped, - const StreamPosition& device_position) { - return Render(dest, audio_delay_milliseconds, frames_skipped); -} - -} // namespace media diff --git a/media/base/audio_renderer_sink.h b/media/base/audio_renderer_sink.h index 669eeede33ce3..b0b5f26a729d3 100644 --- a/media/base/audio_renderer_sink.h +++ b/media/base/audio_renderer_sink.h @@ -18,8 +18,6 @@ namespace media { -struct StreamPosition; - // AudioRendererSink is an interface representing the end-point for // rendered audio. An implementation is expected to // periodically call Render() on a callback object. @@ -27,20 +25,14 @@ struct StreamPosition; class AudioRendererSink : public base::RefCountedThreadSafe { public: - class MEDIA_EXPORT RenderCallback { + class RenderCallback { public: // Attempts to completely fill all channels of |dest|, returns actual // number of frames filled. |frames_skipped| contains the number of frames // the consumer has skipped, if any. virtual int Render(AudioBus* dest, uint32_t frames_delayed, - uint32_t frames_skipped); - // An alternate version which provides also device stream position, - // by default it just invokes the above method. - virtual int Render(AudioBus* dest, - uint32_t audio_delay_milliseconds, - uint32_t frames_skipped, - const StreamPosition& device_position); + uint32_t frames_skipped) = 0; // Signals an error has occurred. virtual void OnRenderError() = 0; diff --git a/media/media.gyp b/media/media.gyp index feb14c68aecda..c455cd5ab8125 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -278,7 +278,6 @@ 'base/audio_renderer_mixer.h', 'base/audio_renderer_mixer_input.cc', 'base/audio_renderer_mixer_input.h', - 'base/audio_renderer_sink.cc', 'base/audio_renderer_sink.h', 'base/audio_shifter.cc', 'base/audio_shifter.h', diff --git a/third_party/WebKit/Source/modules/modules.gypi b/third_party/WebKit/Source/modules/modules.gypi index 9e1b880eec5fb..567f5c0dc6dff 100644 --- a/third_party/WebKit/Source/modules/modules.gypi +++ b/third_party/WebKit/Source/modules/modules.gypi @@ -527,7 +527,6 @@ 'storage/StorageEventInit.idl', 'vr/VRFieldOfViewInit.idl', 'vr/VRLayer.idl', - 'webaudio/AudioTimestamp.idl', 'webaudio/PeriodicWaveConstraints.idl', 'webgl/WebGLContextAttributes.idl', 'webgl/WebGLContextEventInit.idl', @@ -718,8 +717,6 @@ '<(blink_modules_output_dir)/vr/VRFieldOfViewInit.h', '<(blink_modules_output_dir)/vr/VRLayer.cpp', '<(blink_modules_output_dir)/vr/VRLayer.h', - '<(blink_modules_output_dir)/webaudio/AudioTimestamp.cpp', - '<(blink_modules_output_dir)/webaudio/AudioTimestamp.h', '<(blink_modules_output_dir)/webaudio/PeriodicWaveConstraints.cpp', '<(blink_modules_output_dir)/webaudio/PeriodicWaveConstraints.h', '<(blink_modules_output_dir)/webgl/WebGLContextAttributes.cpp', diff --git a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.cpp b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.cpp index e57078922af45..f5eea247a774b 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.cpp +++ b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.cpp @@ -23,14 +23,9 @@ */ #include "modules/webaudio/AudioDestinationNode.h" - -#include "core/frame/LocalDOMWindow.h" -#include "core/timing/DOMWindowPerformance.h" -#include "core/timing/Performance.h" #include "modules/webaudio/AbstractAudioContext.h" #include "modules/webaudio/AudioNodeInput.h" #include "modules/webaudio/AudioNodeOutput.h" -#include "modules/webaudio/AudioTimestamp.h" #include "platform/audio/AudioUtilities.h" #include "platform/audio/DenormalDisabler.h" #include "wtf/Atomics.h" @@ -49,13 +44,8 @@ AudioDestinationHandler::~AudioDestinationHandler() ASSERT(!isInitialized()); } -void AudioDestinationHandler::render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFrames, const StreamPosition& device_position) +void AudioDestinationHandler::render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFrames) { - { - MutexLocker locker(m_mutex); - m_device_position = device_position; - } - // We don't want denormals slowing down any of the audio processing // since they can very seriously hurt performance. // This will take care of all AudioNodes because they all process within this scope. @@ -115,11 +105,6 @@ void AudioDestinationHandler::render(AudioBus* sourceBus, AudioBus* destinationB releaseStore(&m_currentSampleFrame, newSampleFrame); } -WebAudioDevice::StreamPosition AudioDestinationHandler::devicePosition() const { - MutexLocker locker(m_mutex); - return m_device_position; -} - // ---------------------------------------------------------------- AudioDestinationNode::AudioDestinationNode(AbstractAudioContext& context) @@ -137,21 +122,5 @@ unsigned long AudioDestinationNode::maxChannelCount() const return audioDestinationHandler().maxChannelCount(); } -static double toPerformanceTime(ExecutionContext* context, double seconds) -{ - LocalDOMWindow* window = context ? context->executingWindow() : nullptr; - Performance* performance = window ? DOMWindowPerformance::performance(*window) : nullptr; - return performance ? performance->monotonicTimeToDOMHighResTimeStamp(seconds) : 0.0; -} - -void AudioDestinationNode::devicePosition(blink::AudioTimestamp& result) const { - WebAudioDevice::StreamPosition devicePosition = audioDestinationHandler().devicePosition(); - double contextTime = devicePosition.frames / static_cast(audioDestinationHandler().sampleRate()); - result.setContextTime(contextTime); - double performanceTime = devicePosition.seconds ? toPerformanceTime(context()->getExecutionContext(), devicePosition.seconds) - : 0.0; - result.setPerformanceTime(performanceTime); -} - } // namespace blink diff --git a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h index 390633f81c851..a25e598b53617 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h +++ b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h @@ -30,13 +30,11 @@ #include "platform/audio/AudioBus.h" #include "platform/audio/AudioIOCallback.h" #include "platform/audio/AudioSourceProvider.h" -#include "wtf/ThreadingPrimitives.h" namespace blink { class AudioBus; class AbstractAudioContext; -class AudioTimestamp; class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { public: @@ -48,7 +46,7 @@ class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { // The audio hardware calls render() to get the next render quantum of audio into destinationBus. // It will optionally give us local/live audio input in sourceBus (if it's not 0). - void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFrames, const StreamPosition& device_position) final; + void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFrames) final; size_t currentSampleFrame() const { return acquireLoad(&m_currentSampleFrame); } double currentTime() const { return currentSampleFrame() / static_cast(sampleRate()); } @@ -58,8 +56,6 @@ class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { virtual void startRendering() = 0; virtual void stopRendering() = 0; - StreamPosition devicePosition() const; - protected: // LocalAudioInputProvider allows us to expose an AudioSourceProvider for local/live audio input. // If there is local/live audio input, we call set() with the audio input data every render quantum. @@ -92,9 +88,6 @@ class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { // Counts the number of sample-frames processed by the destination. size_t m_currentSampleFrame; - StreamPosition m_device_position; - mutable Mutex m_mutex; - LocalAudioInputProvider m_localAudioInputProvider; }; @@ -105,8 +98,6 @@ class AudioDestinationNode : public AudioNode { unsigned long maxChannelCount() const; - virtual void devicePosition(blink::AudioTimestamp& result) const; - protected: AudioDestinationNode(AbstractAudioContext&); }; diff --git a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.idl b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.idl index bf0c096ff9b4b..f638bb2f8470f 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.idl @@ -24,5 +24,4 @@ interface AudioDestinationNode : AudioNode { readonly attribute unsigned long maxChannelCount; - readonly attribute AudioTimestamp devicePosition; }; diff --git a/third_party/WebKit/Source/modules/webaudio/AudioTimestamp.idl b/third_party/WebKit/Source/modules/webaudio/AudioTimestamp.idl deleted file mode 100644 index 44d912f456fa6..0000000000000 --- a/third_party/WebKit/Source/modules/webaudio/AudioTimestamp.idl +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 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. - -[ - Conditional=WEB_AUDIO -] dictionary AudioTimestamp { - double contextTime; - DOMHighResTimeStamp performanceTime; -}; diff --git a/third_party/WebKit/Source/platform/audio/AudioDestination.cpp b/third_party/WebKit/Source/platform/audio/AudioDestination.cpp index faa3368b0a94b..53c329f641c17 100644 --- a/third_party/WebKit/Source/platform/audio/AudioDestination.cpp +++ b/third_party/WebKit/Source/platform/audio/AudioDestination.cpp @@ -146,12 +146,8 @@ unsigned long AudioDestination::maxChannelCount() return static_cast(Platform::current()->audioHardwareOutputChannels()); } -void AudioDestination::render(const WebVector& sourceData, - const WebVector& audioData, - size_t numberOfFrames, - const StreamPosition& position) +void AudioDestination::render(const WebVector& sourceData, const WebVector& audioData, size_t numberOfFrames) { - m_device_position = position; bool isNumberOfChannelsGood = audioData.size() == m_numberOfOutputChannels; if (!isNumberOfChannelsGood) { ASSERT_NOT_REACHED(); @@ -187,7 +183,7 @@ void AudioDestination::provideInput(AudioBus* bus, size_t framesToProcess) sourceBus = m_inputBus.get(); } - m_callback.render(sourceBus, bus, framesToProcess, m_device_position); + m_callback.render(sourceBus, bus, framesToProcess); } } // namespace blink diff --git a/third_party/WebKit/Source/platform/audio/AudioDestination.h b/third_party/WebKit/Source/platform/audio/AudioDestination.h index 3ed1f314ae7ff..70b4780e72f6b 100644 --- a/third_party/WebKit/Source/platform/audio/AudioDestination.h +++ b/third_party/WebKit/Source/platform/audio/AudioDestination.h @@ -50,7 +50,6 @@ class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback, USING_FAST_MALLOC(AudioDestination); WTF_MAKE_NONCOPYABLE(AudioDestination); public: - using StreamPosition = WebAudioDevice::StreamPosition; AudioDestination(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate, const PassRefPtr&); ~AudioDestination() override; @@ -65,7 +64,7 @@ class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback, float sampleRate() const { return m_sampleRate; } // WebAudioDevice::RenderCallback - void render(const WebVector& sourceData, const WebVector& audioData, size_t numberOfFrames, const StreamPosition& position) override; + void render(const WebVector& sourceData, const WebVector& audioData, size_t numberOfFrames) override; // AudioSourceProvider void provideInput(AudioBus*, size_t framesToProcess) override; @@ -92,7 +91,6 @@ class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback, OwnPtr m_inputFifo; OwnPtr m_fifo; - StreamPosition m_device_position; }; } // namespace blink diff --git a/third_party/WebKit/Source/platform/audio/AudioIOCallback.h b/third_party/WebKit/Source/platform/audio/AudioIOCallback.h index 08d81b6e3c04a..fa59684f66c23 100644 --- a/third_party/WebKit/Source/platform/audio/AudioIOCallback.h +++ b/third_party/WebKit/Source/platform/audio/AudioIOCallback.h @@ -29,8 +29,6 @@ #ifndef AudioIOCallback_h #define AudioIOCallback_h -#include "public/platform/WebAudioDevice.h" - namespace blink { class AudioBus; @@ -38,10 +36,9 @@ class AudioBus; // Abstract base-class for isochronous audio I/O client. class AudioIOCallback { public: - using StreamPosition = WebAudioDevice::StreamPosition; // render() is called periodically to get the next render quantum of audio into destinationBus. // Optional audio input is given in sourceBus (if it's not 0). - virtual void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t framesToProcess, const StreamPosition& device_position) = 0; + virtual void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t framesToProcess) = 0; virtual ~AudioIOCallback() { } }; diff --git a/third_party/WebKit/Source/platform/exported/WebAudioDevice.cpp b/third_party/WebKit/Source/platform/exported/WebAudioDevice.cpp index 76cd80547fa49..f01ab439ca05a 100644 --- a/third_party/WebKit/Source/platform/exported/WebAudioDevice.cpp +++ b/third_party/WebKit/Source/platform/exported/WebAudioDevice.cpp @@ -26,29 +26,10 @@ namespace blink { -WebAudioDevice::StreamPosition::StreamPosition() - : frames(0) - , seconds(0) -{ -} - -WebAudioDevice::StreamPosition::StreamPosition(size_t frames, double seconds) - : frames(frames) - , seconds(seconds) -{ -} - void WebAudioDevice::RenderCallback::render(const WebVector& sourceData, const WebVector& destinationData, size_t numberOfFrames) { } -void WebAudioDevice::RenderCallback::render(const WebVector& sourceData, - const WebVector& destinationData, - size_t numberOfFrames, - const StreamPosition& device_position) { - render(sourceData, destinationData, numberOfFrames); -} - WebAudioDevice::RenderCallback::~RenderCallback() { } diff --git a/third_party/WebKit/public/platform/WebAudioDevice.h b/third_party/WebKit/public/platform/WebAudioDevice.h index 84fd554dc366e..d27483bc32a9c 100644 --- a/third_party/WebKit/public/platform/WebAudioDevice.h +++ b/third_party/WebKit/public/platform/WebAudioDevice.h @@ -38,21 +38,9 @@ namespace blink { class WebAudioDevice { public: - struct BLINK_PLATFORM_EXPORT StreamPosition { - StreamPosition(); - StreamPosition(size_t frames, double seconds); - size_t frames; - double seconds; - }; - class BLINK_PLATFORM_EXPORT RenderCallback { public: virtual void render(const WebVector& sourceData, const WebVector& destinationData, size_t numberOfFrames); - // An alternate version which provides also device stream position, by default it just invokes the above method. - virtual void render(const WebVector& sourceData, - const WebVector& destinationData, - size_t numberOfFrames, - const StreamPosition& device_position); protected: virtual ~RenderCallback();