Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert AudioDestinationNode.devicePosition commits
Browse files Browse the repository at this point in the history
This reverts the following commits:
* 2b2cbc8 ("[Windows] Implementation of 'AudioDestinationNode.devicePosition' attribute")
* 43d41bf ("Fix calling of AudioOutputStream::AudioSourceCallback API")
* fd8c95a ("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:
* WebAudio/web-audio-api#12
* WebAudio/web-audio-api#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 <[email protected]> for the investigation
leading to this commit.

BUG=XWALK-7030
BUG=XWALK-7225
  • Loading branch information
Raphael Kubo da Costa committed Oct 5, 2016
1 parent b53bd1c commit 7807ac7
Show file tree
Hide file tree
Showing 33 changed files with 43 additions and 252 deletions.
4 changes: 1 addition & 3 deletions content/browser/renderer_host/media/audio_sync_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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_;
}

Expand Down
5 changes: 1 addition & 4 deletions content/browser/renderer_host/media/audio_sync_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 2 additions & 9 deletions content/renderer/media/renderer_webaudiodevice_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand All @@ -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<float*> web_audio_source_data(static_cast<size_t>(0));

double seconds = position.ticks
/ static_cast<double>(base::Time::kMicrosecondsPerSecond);
StreamPosition device_position(static_cast<size_t>(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();
Expand Down
4 changes: 1 addition & 3 deletions content/renderer/media/renderer_webaudiodevice_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down
7 changes: 1 addition & 6 deletions media/audio/audio_device_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>::max() is a special signal which is
// returned after the browser stops the output device in response to a
// renderer side request.
Expand All @@ -191,7 +186,7 @@ void AudioDeviceThread::Thread::Run() {
if (pending_data != std::numeric_limits<uint32_t>::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
Expand Down
6 changes: 1 addition & 5 deletions media/audio/audio_device_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions media/audio/audio_input_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 1 addition & 9 deletions media/audio/audio_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions media/audio/audio_output_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<uint32_t>::max(), 0,
{0, 0});
sync_reader_->UpdatePendingBytes(std::numeric_limits<uint32_t>::max(), 0);

handler_->OnPaused();
}
Expand Down Expand Up @@ -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()
Expand All @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions media/audio/audio_output_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions media/audio/audio_output_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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<double>(pending_data) / bytes_per_frame_;

Expand Down Expand Up @@ -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
19 changes: 5 additions & 14 deletions media/audio/audio_output_resampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
};

Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions media/audio/audio_output_stream_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down
3 changes: 1 addition & 2 deletions media/audio/audio_output_stream_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 3 additions & 6 deletions media/audio/simple_sources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_++;

Expand Down Expand Up @@ -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.
Expand Down Expand 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_;

Expand Down
9 changes: 3 additions & 6 deletions media/audio/simple_sources.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 7807ac7

Please sign in to comment.