Index: media/mojo/services/mojo_audio_output.h |
diff --git a/media/mojo/services/mojo_audio_output.h b/media/mojo/services/mojo_audio_output.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7524eacbcc058aafe40bcf344c96680928da1e79 |
--- /dev/null |
+++ b/media/mojo/services/mojo_audio_output.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2017 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 MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ |
+#define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ |
+ |
+#include <memory> |
+#include <string> |
+ |
+// This class handles IPC for single audio output stream by delegating method |
DaleCurtis
2017/03/06 17:56:12
Comments go on the class not between includes.
Max Morin
2017/03/07 11:23:16
Done.
|
+// calls to its AudioOutputDelegate. |
+ |
+#include "base/threading/thread_checker.h" |
+#include "media/audio/audio_output_delegate.h" |
+#include "media/mojo/interfaces/audio_output.mojom.h" |
+#include "media/mojo/services/media_mojo_export.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+ |
+namespace media { |
+ |
+class MEDIA_MOJO_EXPORT MojoAudioOutput |
+ : public mojom::AudioOutput, |
+ public AudioOutputDelegate::EventHandler { |
+ public: |
+ using StreamCreatedCallback = mojom::AudioOutputProvider::AcquireCallback; |
+ using CreateDelegateCallback = |
+ base::OnceCallback<std::unique_ptr<AudioOutputDelegate>( |
+ AudioOutputDelegate::EventHandler*)>; |
+ |
+ // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the |
+ // stream in the constructor. |stream_created_callback| is called when the |
+ // stream has been initialized. |deleter_callback| is called when this class |
+ // should be removed (stream ended/error). |deleter_callback| is required to |
+ // destroy |this| synchronously. |
+ MojoAudioOutput(mojom::AudioOutputRequest request, |
+ CreateDelegateCallback create_delegate_callback, |
+ StreamCreatedCallback stream_created_callback, |
+ base::OnceClosure deleter_callback); |
+ |
+ ~MojoAudioOutput() override; |
+ |
+ private: |
+ // mojom::AudioOutput implementation. |
+ void Play() override; |
+ void Pause() override; |
+ void SetVolume(double volume) override; |
+ |
+ // AudioOutputDelegate::EventHandler implementation. |
+ void OnStreamCreated(int stream_id, |
+ base::SharedMemory* shared_memory, |
+ base::CancelableSyncSocket* foreign_socket) override; |
+ void OnStreamError(int stream_id) override; |
+ |
+ // Closes connection to client and notifies owner. |
+ void OnError(); |
+ |
+ StreamCreatedCallback stream_created_callback_; |
+ base::OnceClosure deleter_callback_; |
+ mojo::Binding<AudioOutput> binding_; |
+ base::ThreadChecker thread_checker_; |
+ const std::unique_ptr<AudioOutputDelegate> delegate_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MojoAudioOutput); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ |