Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.h

Issue 1930393002: Switch stream creation and closing in Chrome audio rendering from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + tests in progress Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 4f2747be94790027c10675da740f38ef16530e7b..c28410caedbb71c21cb93a8d6ecd670fc12f0dd6 100644
--- a/content/browser/renderer_host/media/audio_renderer_host.h
+++ b/content/browser/renderer_host/media/audio_renderer_host.h
@@ -51,10 +51,12 @@
#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"
#include "content/common/content_export.h"
+#include "media/mojo/interfaces/audio_output.mojom.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
@@ -73,6 +75,8 @@ class AudioParameters;
namespace content {
class AudioMirroringManager;
+class AudioOutputImpl;
+class AudioOutputStreamImpl;
class MediaInternals;
class MediaStreamManager;
class MediaStreamUIProxy;
@@ -88,6 +92,18 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
MediaStreamManager* media_stream_manager,
const ResourceContext::SaltCallback& salt_callback);
+ // Creates an audio output stream with the specified format.
+ // Upon success/failure, the peer is notified via the NotifyStreamCreated
+ // message.
+ virtual void CreateStream(
+ int stream_id,
+ int render_frame_id,
+ const media::AudioParameters& params,
+ const media::mojom::AudioOutput::CreateStreamCallback& callback);
+
+ // Close the audio stream referenced by |stream_id|.
+ virtual void CloseStream(int stream_id);
+
// Calls |callback| with the list of AudioOutputControllers for this object.
void GetOutputControllers(
const RenderProcessHost::GetAudioOutputControllersCallback&
@@ -106,12 +122,22 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
// |render_frame_id| are actively playing. Can be called from any thread.
bool RenderFrameHasActiveAudio(int render_frame_id) const;
+ virtual AudioOutputImpl* get_audio_output_impl(int render_frame_id) const;
+
+ virtual void set_audio_output_impl(int render_frame_id,
+ AudioOutputImpl* audio_output_impl);
+
private:
+ friend class AudioEntry;
+ friend class AudioOutputImplTest;
friend class AudioRendererHostTest;
- friend class BrowserThread;
friend class base::DeleteHelper<AudioRendererHost>;
+ friend class BrowserThread;
friend class MockAudioRendererHost;
+ friend class MockAudioOutputAudioRendererHost;
+ friend class MockAudioOutputStreamAudioRendererHost;
friend class TestAudioRendererHost;
+
FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream);
FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation);
@@ -149,22 +175,12 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
const std::string& device_id,
const url::Origin& security_origin);
- // Creates an audio output stream with the specified format.
- // Upon success/failure, the peer is notified via the NotifyStreamCreated
- // message.
- void OnCreateStream(int stream_id,
- int render_frame_id,
- const media::AudioParameters& params);
-
// Play the audio stream referenced by |stream_id|.
void OnPlayStream(int stream_id);
// Pause the audio stream referenced by |stream_id|.
void OnPauseStream(int stream_id);
- // Close the audio stream referenced by |stream_id|.
- void OnCloseStream(int stream_id);
-
// Set the volume of the audio stream referenced by |stream_id|.
void OnSetVolume(int stream_id, double volume);
@@ -183,15 +199,21 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
// Start the actual creation of an audio stream, after the device
// authorization process is complete.
- void DoCreateStream(int stream_id,
- int render_frame_id,
- const media::AudioParameters& params,
- const std::string& device_unique_id);
+ virtual void DoCreateStream(
+ int stream_id,
+ int render_frame_id,
+ const media::AudioParameters& params,
+ const std::string& device_unique_id,
+ const media::mojom::AudioOutput::CreateStreamCallback&
+ create_stream_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);
+ virtual void DoCompleteCreation(
+ int stream_id,
+ const media::mojom::AudioOutput::CreateStreamCallback&
+ create_stream_callback);
// Send playing/paused status to the renderer.
void DoNotifyStreamStateChanged(int stream_id, bool is_playing);
@@ -205,9 +227,14 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
// AudioOutputController after it has closed.
void DeleteEntry(std::unique_ptr<AudioEntry> entry);
- // Send an error message to the renderer, then close the stream.
+ // Send an error message to the client, then close the stream.
void ReportErrorAndClose(int stream_id);
+ // Send an error message to the renderer, then close the stream.
+ void ReportErrorAndCloseStream(
+ int stream_id,
+ const media::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 +270,8 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
media::AudioManager* const audio_manager_;
AudioMirroringManager* const mirroring_manager_;
std::unique_ptr<media::AudioLog> audio_log_;
+ std::map<int, AudioOutputImpl*> audio_output_impls_;
+ std::map<int, int> renderer_frame_ids_;
// Used to access to AudioInputDeviceManager.
MediaStreamManager* media_stream_manager_;

Powered by Google App Engine
This is Rietveld 408576698