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

Commit 49772a4

Browse files
author
Raphael Kubo da Costa
authored
Merge pull request #388 from rakuco/revert-webaudio-patches-xwalk-7030
Revert AudioDestinationNode.devicePosition commits
2 parents b53bd1c + 7807ac7 commit 49772a4

33 files changed

+43
-252
lines changed

content/browser/renderer_host/media/audio_sync_reader.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ AudioSyncReader::~AudioSyncReader() {
107107

108108
// media::AudioOutputController::SyncReader implementations.
109109
void AudioSyncReader::UpdatePendingBytes(uint32_t bytes,
110-
uint32_t frames_skipped,
111-
const media::StreamPosition& device_position) {
110+
uint32_t frames_skipped) {
112111
// Increase the number of skipped frames stored in shared memory. We don't
113112
// send it over the socket since sending more than 4 bytes might lead to being
114113
// descheduled. The reading side will zero it when consumed.
@@ -121,7 +120,6 @@ void AudioSyncReader::UpdatePendingBytes(uint32_t bytes,
121120
output_bus_->Zero();
122121

123122
socket_->Send(&bytes, sizeof(bytes));
124-
socket_->Send(&device_position, sizeof(device_position));
125123
++buffer_index_;
126124
}
127125

content/browser/renderer_host/media/audio_sync_reader.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ class AudioSyncReader : public media::AudioOutputController::SyncReader {
3939
~AudioSyncReader() override;
4040

4141
// media::AudioOutputController::SyncReader implementations.
42-
void UpdatePendingBytes(
43-
uint32_t bytes,
44-
uint32_t frames_skipped,
45-
const media::StreamPosition& position) override;
42+
void UpdatePendingBytes(uint32_t bytes, uint32_t frames_skipped) override;
4643
void Read(media::AudioBus* dest) override;
4744
void Close() override;
4845

content/renderer/media/renderer_webaudiodevice_impl.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ double RendererWebAudioDeviceImpl::sampleRate() {
102102

103103
int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest,
104104
uint32_t frames_delayed,
105-
uint32_t frames_skipped,
106-
const media::StreamPosition& position) {
105+
uint32_t frames_skipped) {
107106
#if defined(OS_ANDROID)
108107
if (is_first_buffer_after_silence_) {
109108
DCHECK(!is_using_null_audio_sink_);
@@ -121,15 +120,9 @@ int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest,
121120
// TODO(xians): Remove the following |web_audio_source_data| after
122121
// changing the blink interface.
123122
WebVector<float*> web_audio_source_data(static_cast<size_t>(0));
124-
125-
double seconds = position.ticks
126-
/ static_cast<double>(base::Time::kMicrosecondsPerSecond);
127-
StreamPosition device_position(static_cast<size_t>(position.frames),
128-
seconds);
129123
client_callback_->render(web_audio_source_data,
130124
web_audio_dest_data,
131-
dest->frames(),
132-
device_position);
125+
dest->frames());
133126

134127
#if defined(OS_ANDROID)
135128
const bool is_zero = dest->AreFramesZero();

content/renderer/media/renderer_webaudiodevice_impl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "base/macros.h"
1212
#include "base/memory/ref_counted.h"
1313
#include "base/threading/thread_checker.h"
14-
#include "media/audio/audio_io.h"
1514
#include "media/base/audio_parameters.h"
1615
#include "media/base/audio_renderer_sink.h"
1716
#include "third_party/WebKit/public/platform/WebAudioDevice.h"
@@ -46,8 +45,7 @@ class RendererWebAudioDeviceImpl
4645
// AudioRendererSink::RenderCallback implementation.
4746
int Render(media::AudioBus* dest,
4847
uint32_t frames_delayed,
49-
uint32_t frames_skipped,
50-
const media::StreamPosition& position) override;
48+
uint32_t frames_skipped) override;
5149

5250
void OnRenderError() override;
5351

media/audio/audio_device_thread.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ void AudioDeviceThread::Thread::Run() {
175175
if (bytes_read != sizeof(pending_data))
176176
break;
177177

178-
StreamPosition device_position = { 0, 0 };
179-
bytes_read = socket_.Receive(&device_position, sizeof(device_position));
180-
if (bytes_read != sizeof(device_position))
181-
break;
182-
183178
// std::numeric_limits<uint32_t>::max() is a special signal which is
184179
// returned after the browser stops the output device in response to a
185180
// renderer side request.
@@ -191,7 +186,7 @@ void AudioDeviceThread::Thread::Run() {
191186
if (pending_data != std::numeric_limits<uint32_t>::max()) {
192187
base::AutoLock auto_lock(callback_lock_);
193188
if (callback_)
194-
callback_->Process(pending_data, device_position);
189+
callback_->Process(pending_data);
195190
}
196191

197192
// The usage of |synchronized_buffers_| differs between input and output

media/audio/audio_device_thread.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "base/memory/shared_memory.h"
1313
#include "base/sync_socket.h"
1414
#include "base/synchronization/lock.h"
15-
#include "media/audio/audio_io.h"
1615
#include "media/base/audio_parameters.h"
1716
#include "media/base/media_export.h"
1817

@@ -22,7 +21,6 @@ class MessageLoop;
2221

2322
namespace media {
2423
class AudioBus;
25-
struct StreamPosition;
2624

2725
// Data transfer between browser and render process uses a combination
2826
// of sync sockets and shared memory. To read from the socket and render
@@ -54,9 +52,7 @@ class MEDIA_EXPORT AudioDeviceThread {
5452
virtual void MapSharedMemory() = 0;
5553

5654
// Called whenever we receive notifications about pending input data.
57-
virtual void Process(
58-
uint32_t pending_data,
59-
const StreamPosition& position) = 0;
55+
virtual void Process(uint32_t pending_data) = 0;
6056

6157
protected:
6258
// Protected so that derived classes can access directly.

media/audio/audio_input_device.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AudioInputDevice::AudioThreadCallback
4141
void MapSharedMemory() override;
4242

4343
// Called whenever we receive notifications about pending data.
44-
void Process(uint32_t pending_data, const StreamPosition& position) override;
44+
void Process(uint32_t pending_data) override;
4545

4646
private:
4747
int current_segment_id_;
@@ -302,9 +302,7 @@ void AudioInputDevice::AudioThreadCallback::MapSharedMemory() {
302302
}
303303
}
304304

305-
void AudioInputDevice::AudioThreadCallback::Process(
306-
uint32_t pending_data,
307-
const StreamPosition& position) {
305+
void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
308306
// The shared memory represents parameters, size of the data buffer and the
309307
// actual data buffer containing audio data. Map the memory into this
310308
// structure and parse out parameters and the data area.

media/audio/audio_io.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@
4949

5050
namespace media {
5151

52-
struct MEDIA_EXPORT StreamPosition {
53-
int64_t frames;
54-
int64_t ticks; // Obtained from base::TimeTicks::ToInternalValue().
55-
};
56-
5752
class MEDIA_EXPORT AudioOutputStream {
5853
public:
5954
// Audio sources must implement AudioSourceCallback. This interface will be
@@ -68,12 +63,9 @@ class MEDIA_EXPORT AudioOutputStream {
6863
// the number of frames it filled. |total_bytes_delay| contains current
6964
// number of bytes of delay buffered by the AudioOutputStream.
7065
// |frames_skipped| contains the number of frames skipped by the consumer.
71-
// |device_position| if provided, contains position of currently audible
72-
// signal.
7366
virtual int OnMoreData(AudioBus* dest,
7467
uint32_t total_bytes_delay,
75-
uint32_t frames_skipped,
76-
const StreamPosition& device_position = {0, 0}) = 0;
68+
uint32_t frames_skipped) = 0;
7769

7870
// There was an error while playing a buffer. Audio source cannot be
7971
// destroyed yet. No direct action needed by the AudioStream, but it is

media/audio/audio_output_controller.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void AudioOutputController::DoPlay() {
172172
return;
173173

174174
// Ask for first packet.
175-
sync_reader_->UpdatePendingBytes(0, 0, {0, 0});
175+
sync_reader_->UpdatePendingBytes(0, 0);
176176

177177
state_ = kPlaying;
178178

@@ -225,8 +225,7 @@ void AudioOutputController::DoPause() {
225225
// Let the renderer know we've stopped. Necessary to let PPAPI clients know
226226
// audio has been shutdown. TODO(dalecurtis): This stinks. PPAPI should have
227227
// a better way to know when it should exit PPB_Audio_Shared::Run().
228-
sync_reader_->UpdatePendingBytes(std::numeric_limits<uint32_t>::max(), 0,
229-
{0, 0});
228+
sync_reader_->UpdatePendingBytes(std::numeric_limits<uint32_t>::max(), 0);
230229

231230
handler_->OnPaused();
232231
}
@@ -294,8 +293,7 @@ void AudioOutputController::DoReportError() {
294293

295294
int AudioOutputController::OnMoreData(AudioBus* dest,
296295
uint32_t total_bytes_delay,
297-
uint32_t frames_skipped,
298-
const StreamPosition& device_position) {
296+
uint32_t frames_skipped) {
299297
TRACE_EVENT0("audio", "AudioOutputController::OnMoreData");
300298

301299
// Indicate that we haven't wedged (at least not indefinitely, WedgeCheck()
@@ -309,8 +307,7 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
309307

310308
const int frames = dest->frames();
311309
sync_reader_->UpdatePendingBytes(
312-
total_bytes_delay + frames * params_.GetBytesPerFrame(), frames_skipped,
313-
device_position);
310+
total_bytes_delay + frames * params_.GetBytesPerFrame(), frames_skipped);
314311

315312
if (will_monitor_audio_levels())
316313
power_monitor_.Scan(*dest, frames);

media/audio/audio_output_controller.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ class MEDIA_EXPORT AudioOutputController
9393
// source can handle this appropriately depending on the type of source. An
9494
// ordinary file playout would ignore this.
9595
virtual void UpdatePendingBytes(uint32_t bytes,
96-
uint32_t frames_skipped,
97-
const StreamPosition& position) = 0;
96+
uint32_t frames_skipped) = 0;
9897

9998
// Attempts to completely fill |dest|, zeroing |dest| if the request can not
10099
// be fulfilled (due to timeout).
@@ -166,8 +165,7 @@ class MEDIA_EXPORT AudioOutputController
166165
// AudioSourceCallback implementation.
167166
int OnMoreData(AudioBus* dest,
168167
uint32_t total_bytes_delay,
169-
uint32_t frames_skipped,
170-
const StreamPosition& device_position) override;
168+
uint32_t frames_skipped) override;
171169
void OnError(AudioOutputStream* stream) override;
172170

173171
// AudioDeviceListener implementation. When called AudioOutputController will

media/audio/audio_output_device.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AudioOutputDevice::AudioThreadCallback
3939
void MapSharedMemory() override;
4040

4141
// Called whenever we receive notifications about pending data.
42-
void Process(uint32_t pending_data, const StreamPosition& position) override;
42+
void Process(uint32_t pending_data) override;
4343

4444
private:
4545
AudioRendererSink::RenderCallback* render_callback_;
@@ -445,9 +445,7 @@ void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
445445
}
446446

447447
// Called whenever we receive notifications about pending data.
448-
void AudioOutputDevice::AudioThreadCallback::Process(
449-
uint32_t pending_data,
450-
const StreamPosition& position) {
448+
void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
451449
// Convert the number of pending bytes in the render buffer into frames.
452450
double frames_delayed = static_cast<double>(pending_data) / bytes_per_frame_;
453451

@@ -477,7 +475,7 @@ void AudioOutputDevice::AudioThreadCallback::Process(
477475
// the shared memory the Render() call is writing directly into the shared
478476
// memory.
479477
render_callback_->Render(output_bus_.get(), std::round(frames_delayed),
480-
frames_skipped, position);
478+
frames_skipped);
481479
}
482480

483481
} // namespace media

media/audio/audio_output_resampler.cc

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class OnMoreDataConverter
3333
// AudioSourceCallback interface.
3434
int OnMoreData(AudioBus* dest,
3535
uint32_t total_bytes_delay,
36-
uint32_t frames_skipped,
37-
const StreamPosition& position) override;
36+
uint32_t frames_skipped) override;
3837
void OnError(AudioOutputStream* stream) override;
3938

4039
// Sets |source_callback_|. If this is not a new object, then Stop() must be
@@ -74,9 +73,6 @@ class OnMoreDataConverter
7473
// stream has been stopped.
7574
bool error_occurred_;
7675

77-
// Information about last recodred stream output position.
78-
StreamPosition device_position_;
79-
8076
DISALLOW_COPY_AND_ASSIGN(OnMoreDataConverter);
8177
};
8278

@@ -353,8 +349,7 @@ OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params,
353349
source_callback_(nullptr),
354350
input_bytes_per_second_(input_params.GetBytesPerSecond()),
355351
audio_converter_(input_params, output_params, false),
356-
error_occurred_(false),
357-
device_position_() {}
352+
error_occurred_(false) {}
358353

359354
OnMoreDataConverter::~OnMoreDataConverter() {
360355
// Ensure Stop() has been called so we don't end up with an AudioOutputStream
@@ -381,9 +376,7 @@ void OnMoreDataConverter::Stop() {
381376

382377
int OnMoreDataConverter::OnMoreData(AudioBus* dest,
383378
uint32_t total_bytes_delay,
384-
uint32_t frames_skipped,
385-
const StreamPosition& position) {
386-
device_position_ = position;
379+
uint32_t frames_skipped) {
387380
current_total_bytes_delay_ = total_bytes_delay;
388381
audio_converter_.Convert(dest);
389382

@@ -402,10 +395,8 @@ double OnMoreDataConverter::ProvideInput(AudioBus* dest,
402395
buffer_delay.InSecondsF() * input_bytes_per_second_));
403396

404397
// Retrieve data from the original callback.
405-
const int frames = source_callback_->OnMoreData(dest,
406-
new_total_bytes_delay,
407-
0,
408-
device_position_);
398+
const int frames =
399+
source_callback_->OnMoreData(dest, new_total_bytes_delay, 0);
409400

410401
// Zero any unfilled frames if anything was filled, otherwise we'll just
411402
// return a volume of zero and let AudioConverter drop the output.

media/audio/audio_output_stream_sink.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ OutputDeviceInfo AudioOutputStreamSink::GetOutputDeviceInfo() {
7979

8080
int AudioOutputStreamSink::OnMoreData(AudioBus* dest,
8181
uint32_t total_bytes_delay,
82-
uint32_t frames_skipped,
83-
const StreamPosition& position) {
82+
uint32_t frames_skipped) {
8483
// Note: Runs on the audio thread created by the OS.
8584
base::AutoLock al(callback_lock_);
8685
if (!active_render_callback_)

media/audio/audio_output_stream_sink.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class MEDIA_EXPORT AudioOutputStreamSink
4444
// AudioSourceCallback implementation.
4545
int OnMoreData(AudioBus* dest,
4646
uint32_t total_bytes_delay,
47-
uint32_t frames_skipped,
48-
const StreamPosition& position) override;
47+
uint32_t frames_skipped) override;
4948
void OnError(AudioOutputStream* stream) override;
5049

5150
private:

media/audio/simple_sources.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ SineWaveAudioSource::~SineWaveAudioSource() {
117117
// but it is efficient enough for our simple needs.
118118
int SineWaveAudioSource::OnMoreData(AudioBus* audio_bus,
119119
uint32_t total_bytes_delay,
120-
uint32_t frames_skipped,
121-
const StreamPosition& position) {
120+
uint32_t frames_skipped) {
122121
base::AutoLock auto_lock(time_lock_);
123122
callbacks_++;
124123

@@ -203,8 +202,7 @@ void FileSource::LoadWavFile(const base::FilePath& path_to_wav_file) {
203202

204203
int FileSource::OnMoreData(AudioBus* audio_bus,
205204
uint32_t total_bytes_delay,
206-
uint32_t frames_skipped,
207-
const StreamPosition& position) {
205+
uint32_t frames_skipped) {
208206
// Load the file if we haven't already. This load needs to happen on the
209207
// audio thread, otherwise we'll run on the UI thread on Mac for instance.
210208
// This will massively delay the first OnMoreData, but we'll catch up.
@@ -254,8 +252,7 @@ BeepingSource::~BeepingSource() {
254252

255253
int BeepingSource::OnMoreData(AudioBus* audio_bus,
256254
uint32_t total_bytes_delay,
257-
uint32_t frames_skipped,
258-
const StreamPosition& position) {
255+
uint32_t frames_skipped) {
259256
// Accumulate the time from the last beep.
260257
interval_from_last_beep_ += base::TimeTicks::Now() - last_callback_time_;
261258

media/audio/simple_sources.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class MEDIA_EXPORT SineWaveAudioSource
3737
// Implementation of AudioSourceCallback.
3838
int OnMoreData(AudioBus* audio_bus,
3939
uint32_t total_bytes_delay,
40-
uint32_t frames_skipped,
41-
const StreamPosition& position) override;
40+
uint32_t frames_skipped) override;
4241
void OnError(AudioOutputStream* stream) override;
4342

4443
// The number of OnMoreData() and OnError() calls respectively.
@@ -65,8 +64,7 @@ class MEDIA_EXPORT FileSource : public AudioOutputStream::AudioSourceCallback,
6564
// Implementation of AudioSourceCallback.
6665
int OnMoreData(AudioBus* audio_bus,
6766
uint32_t total_bytes_delay,
68-
uint32_t frames_skipped,
69-
const StreamPosition& position) override;
67+
uint32_t frames_skipped) override;
7068
void OnError(AudioOutputStream* stream) override;
7169

7270
private:
@@ -99,8 +97,7 @@ class BeepingSource : public AudioOutputStream::AudioSourceCallback {
9997
// Implementation of AudioSourceCallback.
10098
int OnMoreData(AudioBus* audio_bus,
10199
uint32_t total_bytes_delay,
102-
uint32_t frames_skipped,
103-
const StreamPosition& position) override;
100+
uint32_t frames_skipped) override;
104101
void OnError(AudioOutputStream* stream) override;
105102

106103
static void BeepOnce();

0 commit comments

Comments
 (0)