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

Unified Diff: media/mojo/services/mojo_audio_output_provider.h

Issue 2697793002: Add mojo interface+impl for audio stream control. (Closed)
Patch Set: Introduce provider Created 3 years, 10 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: media/mojo/services/mojo_audio_output_provider.h
diff --git a/media/mojo/services/mojo_audio_output_provider.h b/media/mojo/services/mojo_audio_output_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..40a460b371a4887b2aa2a4876603d7529daffea1
--- /dev/null
+++ b/media/mojo/services/mojo_audio_output_provider.h
@@ -0,0 +1,59 @@
+// 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_PROVIDER_H_
+#define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_
+
+#include <memory>
+#include <string>
+
+// Provides a single AudioOutput, given the audio parameters to use.
+
+#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 "media/mojo/services/mojo_audio_output.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+namespace media {
+
+class MEDIA_MOJO_EXPORT MojoAudioOutputProvider
+ : public mojom::AudioOutputProvider {
+ public:
+ using CreateDelegateCallback =
+ base::OnceCallback<std::unique_ptr<AudioOutputDelegate>(
+ const AudioParameters& params,
+ AudioOutputDelegate::EventHandler*)>;
+ using DeleterCallback = base::OnceCallback<void(mojom::AudioOutputProvider*)>;
+
+ // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the
+ // AudioOutput when it's initialized and |deleter_callback| is called when
+ // this class should be removed (stream ended/error). |deleter_callback| is
+ // required to destroy |this| synchronously.
+ MojoAudioOutputProvider(AudioOutputProviderRequest request,
+ CreateDelegateCallback create_delegate_callback,
+ DeleterCallback deleter_callback);
+
+ ~MojoAudioOutputProvider() override;
+
+ private:
+ // mojom::AudioOutput implementation.
+ void Acquire(AudioParameters params,
+ AcquireCallback acquire_callback) override;
+
+ // The callback for the Acquire() must be stored until the response is ready.
+ AcquireCallback acquire_callback_;
+
+ base::Optional<AudioOutput> audio_output_;
+ mojo::Binding<AudioOutputProvider*> binding_;
o1ka 2017/03/07 00:49:24 How will delete AudioOutputProvider if a connectio
Max Morin 2017/03/07 11:23:17 I fixed this (added connection error handler to bi
+ DeleterCallback deleter_callback_;
+ base::ThreadChecker thread_checker_;
o1ka 2017/03/07 00:49:24 Not used?
Max Morin 2017/03/07 11:23:16 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputProvider);
+};
+
+} // namespace media
+
+#endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698