| Index: content/renderer/media/audio_renderer_impl.h
|
| ===================================================================
|
| --- content/renderer/media/audio_renderer_impl.h (revision 120523)
|
| +++ content/renderer/media/audio_renderer_impl.h (working copy)
|
| @@ -19,6 +19,7 @@
|
|
|
| #include <vector>
|
|
|
| +#include "base/atomicops.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| @@ -77,12 +78,19 @@
|
| void DoPause();
|
| void DoSeek();
|
|
|
| + // Methods called on IO thread ----------------------------------------------
|
| + void DoSignalEndOfStream(base::subtle::AtomicWord stream_id);
|
| +
|
| // media::AudioRendererSink::RenderCallback implementation.
|
| virtual size_t Render(const std::vector<float*>& audio_data,
|
| size_t number_of_frames,
|
| size_t audio_delay_milliseconds) OVERRIDE;
|
| virtual void OnError() OVERRIDE;
|
|
|
| + // Returns delay in ms before call to OnRenderEndOfStream().
|
| + // Made virtual so test can override.
|
| + virtual int64 OnRenderEndOfStreamDelay();
|
| +
|
| // Accessors used by tests.
|
| base::Time earliest_end_time() const {
|
| return earliest_end_time_;
|
| @@ -113,6 +121,9 @@
|
| // Set to true when OnInitialize() is called.
|
| bool is_initialized_;
|
|
|
| + // Set to true when we post delayed task to signal 'ended' event.
|
| + bool ended_event_scheduled_;
|
| +
|
| // We're supposed to know amount of audio data OS or hardware buffered, but
|
| // that is not always so -- on my Linux box
|
| // AudioBuffersState::hardware_delay_bytes never reaches 0.
|
| @@ -131,6 +142,19 @@
|
|
|
| AudioParameters audio_parameters_;
|
|
|
| + // Use message loop proxy, not message loop itself, to avoid crash
|
| + // because of message loop that ended while we are still playing.
|
| + // We don't need complex shutdown operations, just not posting tasks
|
| + // is enough, so we can use message loop proxy.
|
| + scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
|
| +
|
| + // Stream id -- necessary because there is no way to cancel scheduled task.
|
| + // We want be sure we are still playing the same stream when delayed task is
|
| + // called. If seek or pause happened after scheduling but before task was
|
| + // called, there would be mismatch between expected and actual ids and delayed
|
| + // task would not do anything.
|
| + base::subtle::AtomicWord stream_id_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
|
| };
|
|
|
|
|