Index: content/browser/renderer_host/media/audio_renderer_host.h |
diff --git a/content/browser/renderer_host/media/audio_renderer_host.h b/content/browser/renderer_host/media/audio_renderer_host.h |
index b4e9d3f329a009039635d0fc80ed1d0cba4e7133..3cbd11358fbcd0db4577c88780647e43248929c4 100644 |
--- a/content/browser/renderer_host/media/audio_renderer_host.h |
+++ b/content/browser/renderer_host/media/audio_renderer_host.h |
@@ -51,6 +51,7 @@ |
#include "base/gtest_prod_util.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/shared_memory.h" |
#include "base/process/process.h" |
#include "base/sequenced_task_runner_helpers.h" |
#include "content/browser/renderer_host/media/audio_output_device_enumerator.h" |
@@ -63,6 +64,7 @@ |
#include "media/audio/audio_logging.h" |
#include "media/audio/audio_output_controller.h" |
#include "media/audio/simple_sources.h" |
+#include "media/mojo/interfaces/audio_output.mojom.h" |
#include "url/origin.h" |
namespace media { |
@@ -73,6 +75,9 @@ class AudioParameters; |
namespace content { |
class AudioMirroringManager; |
+class AudioOutputImpl; |
+class AudioOutputStreamImpl; |
+class AudioRendererHost; |
class MediaInternals; |
class MediaStreamManager; |
class MediaStreamUIProxy; |
@@ -80,6 +85,70 @@ class ResourceContext; |
class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
public: |
+class CONTENT_EXPORT AudioEntry |
Henrik Grunell
2016/04/19 15:36:09
Why does it have to be moved to the header?
rchtara
2016/04/21 09:10:18
Because, I'm using the AudioEntry in the audio_out
Henrik Grunell
2016/04/22 08:23:03
Acknowledged.
|
+ : public media::AudioOutputController::EventHandler { |
+ public: |
+ AudioEntry(AudioRendererHost* host, |
+ int stream_id, |
+ int render_frame_id, |
+ const media::AudioParameters& params, |
+ const std::string& output_device_id, |
+ std::unique_ptr<base::SharedMemory> shared_memory, |
+ std::unique_ptr<media::AudioOutputController::SyncReader> reader, |
+ const mojom::AudioOutput::CreateStreamCallback& callback); |
+ |
+ ~AudioEntry() override; |
+ |
+ int stream_id() const { return stream_id_; } |
+ |
+ int render_frame_id() const { return render_frame_id_; } |
+ |
+ media::AudioOutputController* controller() const { |
+ return controller_.get(); |
+ } |
+ |
+ base::SharedMemory* shared_memory() { return shared_memory_.get(); } |
+ |
+ media::AudioOutputController::SyncReader* reader() const { |
+ return reader_.get(); |
+ } |
+ |
+ bool playing() const { return playing_; } |
+ void set_playing(bool playing) { playing_ = playing; } |
+ |
+ void set_stream_ptr(AudioOutputStreamImpl* stream_ptr) { |
+ stream_ptr_ = stream_ptr; |
+ } |
+ void OnError() override; |
+ |
+ private: |
+ friend class AudioRendererHost; |
+ // media::AudioOutputController::EventHandler implementation. |
+ void OnCreated( |
+ const mojom::AudioOutput::CreateStreamCallback& callback) override; |
+ void OnPlaying() override; |
+ void OnPaused() override; |
+ |
+ AudioRendererHost* const host_; |
+ const int stream_id_; |
+ |
+ // The routing ID of the source RenderFrame. |
+ const int render_frame_id_; |
+ |
+ // Shared memory for transmission of the audio data. Used by |reader_|. |
+ const std::unique_ptr<base::SharedMemory> shared_memory_; |
+ |
+ // The synchronous reader to be used by |controller_|. |
+ const std::unique_ptr<media::AudioOutputController::SyncReader> reader_; |
+ |
+ // The AudioOutputController that manages the audio stream. |
+ const scoped_refptr<media::AudioOutputController> controller_; |
+ |
+ bool playing_; |
+ |
+ AudioOutputStreamImpl* stream_ptr_; |
+ }; |
+ |
// Called from UI thread from the owner of this object. |
AudioRendererHost(int render_process_id, |
media::AudioManager* audio_manager, |
@@ -107,6 +176,9 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
bool RenderFrameHasActiveAudio(int render_frame_id) const; |
private: |
+ friend class AudioEntry; |
+ friend class AudioOutputImpl; |
+ friend class AudioOutputStreamImpl; |
friend class AudioRendererHostTest; |
friend class BrowserThread; |
friend class base::DeleteHelper<AudioRendererHost>; |
@@ -115,7 +187,6 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); |
FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); |
- class AudioEntry; |
typedef std::map<int, AudioEntry*> AudioEntryMap; |
// Internal callback type for access requests to output devices. |
@@ -154,7 +225,8 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
// message. |
void OnCreateStream(int stream_id, |
int render_frame_id, |
- const media::AudioParameters& params); |
+ const media::AudioParameters& params, |
+ const mojom::AudioOutput::CreateStreamCallback& callback); |
// Play the audio stream referenced by |stream_id|. |
void OnPlayStream(int stream_id); |
@@ -186,12 +258,15 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
void DoCreateStream(int stream_id, |
int render_frame_id, |
const media::AudioParameters& params, |
- const std::string& device_unique_id); |
+ const std::string& device_unique_id, |
+ const mojom::AudioOutput::CreateStreamCallback& callback); |
// Complete the process of creating an audio stream. This will set up the |
// shared memory or shared socket in low latency mode and send the |
// NotifyStreamCreated message to the peer. |
- void DoCompleteCreation(int stream_id); |
+ void DoCompleteCreation( |
+ int stream_id, |
+ const mojom::AudioOutput::CreateStreamCallback& callback); |
// Send playing/paused status to the renderer. |
void DoNotifyStreamStateChanged(int stream_id, bool is_playing); |
@@ -208,6 +283,11 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
// Send an error message to the renderer, then close the stream. |
void ReportErrorAndClose(int stream_id); |
+ // Send an error message to the renderer, then close the stream. |
+ void ReportErrorAndCloseMojo( |
+ int stream_id, |
+ const mojom::AudioOutput::CreateStreamCallback& callback); |
+ |
// A helper method to look up a AudioEntry identified by |stream_id|. |
// Returns NULL if not found. |
AudioEntry* LookupById(int stream_id); |
@@ -243,6 +323,7 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
media::AudioManager* const audio_manager_; |
AudioMirroringManager* const mirroring_manager_; |
std::unique_ptr<media::AudioLog> audio_log_; |
+ AudioOutputImpl* audio_output_impl_; |
// Used to access to AudioInputDeviceManager. |
MediaStreamManager* media_stream_manager_; |
@@ -267,6 +348,8 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
// host. Reported as UMA stat at shutdown. |
size_t max_simultaneous_streams_; |
+ mojom::AudioOutputStreamPtr stream_ptr_; |
+ |
DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
}; |