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

Commit 0732335

Browse files
Mikhail PozdnyakovRaphael Kubo da Costa
Mikhail Pozdnyakov
authored and
Raphael Kubo da Costa
committed
Fix calling of AudioOutputStream::AudioSourceCallback API
Before this change calling of AudioOutputStream::AudioSourceCallback method without stream position ended up in an empty implementation. BUG=XWALK-6703
1 parent 586346c commit 0732335

11 files changed

+27
-47
lines changed

media/audio/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ source_set("audio") {
6464
"audio_input_device.h",
6565
"audio_input_ipc.cc",
6666
"audio_input_ipc.h",
67-
"audio_io.cc",
6867
"audio_io.h",
6968
"audio_manager.cc",
7069
"audio_manager.h",

media/audio/audio_io.cc

Lines changed: 0 additions & 24 deletions
This file was deleted.

media/audio/audio_io.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,12 @@ class MEDIA_EXPORT AudioOutputStream {
6868
// the number of frames it filled. |total_bytes_delay| contains current
6969
// number of bytes of delay buffered by the AudioOutputStream.
7070
// |frames_skipped| contains the number of frames skipped by the consumer.
71-
virtual int OnMoreData(AudioBus* dest,
72-
uint32_t total_bytes_delay,
73-
uint32_t frames_skipped);
74-
// An alternate version which provides also device stream position,
75-
// by default it just invokes the above method.
71+
// |device_position| if provided, contains position of currently audible
72+
// signal.
7673
virtual int OnMoreData(AudioBus* dest,
7774
uint32_t total_bytes_delay,
7875
uint32_t frames_skipped,
79-
const StreamPosition& device_position);
76+
const StreamPosition& device_position = {0, 0}) = 0;
8077

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

media/audio/audio_output_controller.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void AudioOutputController::DoPlay() {
164164
return;
165165

166166
// Ask for first packet.
167-
sync_reader_->UpdatePendingBytes(0, 0);
167+
sync_reader_->UpdatePendingBytes(0, 0, {0, 0});
168168

169169
state_ = kPlaying;
170170

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

222223
handler_->OnPaused();
223224
}

media/audio/audio_output_controller.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ class MEDIA_EXPORT AudioOutputController
9090
// frames has been skipped by the renderer (typically the OS). The renderer
9191
// source can handle this appropriately depending on the type of source. An
9292
// ordinary file playout would ignore this.
93-
virtual void UpdatePendingBytes(
94-
uint32_t bytes,
95-
uint32_t frames_skipped,
96-
const StreamPosition& position = StreamPosition()) = 0;
93+
virtual void UpdatePendingBytes(uint32_t bytes,
94+
uint32_t frames_skipped,
95+
const StreamPosition& position) = 0;
9796

9897
// Attempts to completely fill |dest|, zeroing |dest| if the request can not
9998
// be fulfilled (due to timeout).

media/audio/audio_output_stream_sink.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ OutputDevice* AudioOutputStreamSink::GetOutputDevice() {
7979

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

media/audio/audio_output_stream_sink.h

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

5051
private:

media/audio/simple_sources.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ SineWaveAudioSource::~SineWaveAudioSource() {
113113
// but it is efficient enough for our simple needs.
114114
int SineWaveAudioSource::OnMoreData(AudioBus* audio_bus,
115115
uint32_t total_bytes_delay,
116-
uint32_t frames_skipped) {
116+
uint32_t frames_skipped,
117+
const StreamPosition& position) {
117118
base::AutoLock auto_lock(time_lock_);
118119
callbacks_++;
119120

@@ -198,7 +199,8 @@ void FileSource::LoadWavFile(const base::FilePath& path_to_wav_file) {
198199

199200
int FileSource::OnMoreData(AudioBus* audio_bus,
200201
uint32_t total_bytes_delay,
201-
uint32_t frames_skipped) {
202+
uint32_t frames_skipped,
203+
const StreamPosition& position) {
202204
// Load the file if we haven't already. This load needs to happen on the
203205
// audio thread, otherwise we'll run on the UI thread on Mac for instance.
204206
// This will massively delay the first OnMoreData, but we'll catch up.
@@ -248,7 +250,8 @@ BeepingSource::~BeepingSource() {
248250

249251
int BeepingSource::OnMoreData(AudioBus* audio_bus,
250252
uint32_t total_bytes_delay,
251-
uint32_t frames_skipped) {
253+
uint32_t frames_skipped,
254+
const StreamPosition& position) {
252255
// Accumulate the time from the last beep.
253256
interval_from_last_beep_ += base::TimeTicks::Now() - last_callback_time_;
254257

media/audio/simple_sources.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class MEDIA_EXPORT SineWaveAudioSource
3535
// Implementation of AudioSourceCallback.
3636
int OnMoreData(AudioBus* audio_bus,
3737
uint32_t total_bytes_delay,
38-
uint32_t frames_skipped) override;
38+
uint32_t frames_skipped,
39+
const StreamPosition& position) override;
3940
void OnError(AudioOutputStream* stream) override;
4041

4142
// The number of OnMoreData() and OnError() calls respectively.
@@ -62,7 +63,8 @@ class MEDIA_EXPORT FileSource : public AudioOutputStream::AudioSourceCallback,
6263
// Implementation of AudioSourceCallback.
6364
int OnMoreData(AudioBus* audio_bus,
6465
uint32_t total_bytes_delay,
65-
uint32_t frames_skipped) override;
66+
uint32_t frames_skipped,
67+
const StreamPosition& position) override;
6668
void OnError(AudioOutputStream* stream) override;
6769

6870
private:
@@ -95,7 +97,8 @@ class BeepingSource : public AudioOutputStream::AudioSourceCallback {
9597
// Implementation of AudioSourceCallback.
9698
int OnMoreData(AudioBus* audio_bus,
9799
uint32_t total_bytes_delay,
98-
uint32_t frames_skipped) override;
100+
uint32_t frames_skipped,
101+
const StreamPosition& position) override;
99102
void OnError(AudioOutputStream* stream) override;
100103

101104
static void BeepOnce();

media/audio/sounds/audio_stream_handler.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class AudioStreamHandler::AudioStreamContainer
111111
// Following methods could be called from *ANY* thread.
112112
int OnMoreData(AudioBus* dest,
113113
uint32_t /* total_bytes_delay */,
114-
uint32_t /* frames_skipped */) override {
114+
uint32_t /* frames_skipped */,
115+
const StreamPosition& /* position */) override {
115116
base::AutoLock al(state_lock_);
116117
size_t bytes_written = 0;
117118

media/media.gyp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
'audio/audio_input_device.h',
135135
'audio/audio_input_ipc.cc',
136136
'audio/audio_input_ipc.h',
137-
'audio/audio_io.cc',
138137
'audio/audio_io.h',
139138
'audio/audio_manager.cc',
140139
'audio/audio_manager.h',

0 commit comments

Comments
 (0)