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

Unified Diff: content/browser/media/audio_output_impl.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: Created 4 years, 8 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/media/audio_output_impl.h
diff --git a/content/browser/media/audio_output_impl.h b/content/browser/media/audio_output_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..7451f50cafd2cb7e6dcc4712e74e6258f3c7a3a1
--- /dev/null
+++ b/content/browser/media/audio_output_impl.h
@@ -0,0 +1,100 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
+#define CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "content/browser/renderer_host/media/audio_renderer_host.h"
+#include "content/common/content_export.h"
+#include "media/mojo/interfaces/audio_output.mojom.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace content {
+// This class implements AudioOutputStream Mojo interface. It will be used
+// by the AudioOutputClient to perform operations on audio output streams.
+// AudioOutputClient will perform operations remotely on the
+// AudioOutputStreamPtr and Mojo will transfer them to AudioOutputStreamImpl.
+// Owned by AudioOutputImpl.
+class CONTENT_EXPORT AudioOutputStreamImpl
mcasas 2016/04/29 18:29:00 Either spin this class into a file on its own, or
Henrik Grunell 2016/05/02 12:12:22 Agree, put in its own file.
rchtara 2016/05/23 16:38:17 Done.
rchtara 2016/05/23 16:38:17 Done.
+ : public media::interfaces::AudioOutputStream {
+ public:
+ AudioOutputStreamImpl(media::interfaces::AudioOutputStreamRequest request,
+ int stream_id,
+ AudioRendererHost* audio_renderer_host);
+
+ ~AudioOutputStreamImpl() override;
+
+ private:
+ // AudioOutputStream interface implementation.
+ void Close() override;
+
+ mojo::StrongBinding<media::interfaces::AudioOutputStream> binding_;
+ int stream_id_;
+ // AudioRendererHost is ref counted and AudioOutputImpl holds a reference to
+ // it. And because all AudioOutputStreamImpl instances will be owned by
+ // AudioOutputImpl too, it's safe to access AudioRendererHost from
+ // AudioOutputStreamImpl.
+ // The only issue that could happen is during AudioOutputStreamImpl
+ // destructor. AudioRendererHost cannot access from there.
+ AudioRendererHost* audio_renderer_host_;
+};
+
+// This class implements AudioOutput Mojo interface. It will be used
+// by the AudioOutputClient to perform operations on audio output streams.
+// AudioOutputClient is going to perform operations remotely and Mojo will
+// transfer them to AudioOutputImpl.
+// This class must always be accessed from the creation thread.
+class CONTENT_EXPORT AudioOutputImpl
+ : NON_EXPORTED_BASE(public media::interfaces::AudioOutput) {
+ public:
+ explicit AudioOutputImpl(scoped_refptr<AudioRendererHost> audio_renderer_host,
+ media::interfaces::AudioOutputRequest request);
+
+ ~AudioOutputImpl() override;
+
+ // Create a Mojo service.
+ static void CreateService(
+ scoped_refptr<AudioRendererHost> audio_renderer_host,
+ media::interfaces::AudioOutputRequest request);
+ // Initialize Mojo service on the IO thread. The service is bound to the
+ // IO thread so future Mojo calls performed by the AudioOutputClient to the
+ // AudioOutput interface will be run on that thread.
+ // There are a lot of dependencies used in audio output that require to be
+ // called on the IO thread, this is why we initialize Mojo service on this
+ // thread. There is a plan to enable these dependencies to run on another
+ // thread and move the Mojo service to this thread as IO thread is very
+ // performance sensitive and we want to move stuff off it.
+ static void CreateServiceOnIOThread(
+ scoped_refptr<AudioRendererHost> audio_renderer_host,
+ media::interfaces::AudioOutputRequest request);
+
+ // Called by AudioRendererHost::DoCompleteCreation to create the streams.
+ media::interfaces::AudioOutputStreamPtr StreamFactory(
+ int stream_id,
+ AudioRendererHost* audio_renderer_host);
+
+ private:
+ // AudioOutput interface implementation.
+ void CreateStream(int stream_id,
+ int render_frame_id,
+ media::interfaces::AudioOutputStreamParametersPtr params,
+ const CreateStreamCallback& callback) override;
+
+ scoped_refptr<AudioRendererHost> audio_renderer_host_;
+ mojo::StrongBinding<AudioOutput> binding_;
+ std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_;
+ DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
« no previous file with comments | « no previous file | content/browser/media/audio_output_impl.cc » ('j') | content/browser/media/audio_output_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698