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

Side by Side Diff: media/mojo/services/mojo_audio_output_stream.h

Issue 2697793002: Add mojo interface+impl for audio stream control. (Closed)
Patch Set: Don't inline AudioOutputDelegate(EventHandler) dtor. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « media/mojo/services/BUILD.gn ('k') | media/mojo/services/mojo_audio_output_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_STREAM_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_STREAM_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/threading/thread_checker.h"
12 #include "media/audio/audio_output_delegate.h"
13 #include "media/mojo/interfaces/audio_output_stream.mojom.h"
14 #include "media/mojo/services/media_mojo_export.h"
15 #include "mojo/public/cpp/bindings/binding.h"
16
17 namespace media {
18
19 // This class handles IPC for single audio output stream by delegating method
20 // calls to its AudioOutputDelegate.
21 class MEDIA_MOJO_EXPORT MojoAudioOutputStream
22 : NON_EXPORTED_BASE(public mojom::AudioOutputStream),
23 NON_EXPORTED_BASE(public AudioOutputDelegate::EventHandler) {
24 public:
25 using StreamCreatedCallback =
26 mojom::AudioOutputStreamProvider::AcquireCallback;
27 using CreateDelegateCallback =
28 base::OnceCallback<std::unique_ptr<AudioOutputDelegate>(
29 AudioOutputDelegate::EventHandler*)>;
30
31 // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the
32 // stream in the constructor. |stream_created_callback| is called when the
33 // stream has been initialized. |deleter_callback| is called when this class
34 // should be removed (stream ended/error). |deleter_callback| is required to
35 // destroy |this| synchronously.
36 MojoAudioOutputStream(mojom::AudioOutputStreamRequest request,
37 CreateDelegateCallback create_delegate_callback,
38 StreamCreatedCallback stream_created_callback,
39 base::OnceClosure deleter_callback);
40
41 ~MojoAudioOutputStream() override;
42
43 private:
44 // mojom::AudioOutputStream implementation.
45 void Play() override;
46 void Pause() override;
47 void SetVolume(double volume) override;
48
49 // AudioOutputDelegate::EventHandler implementation.
50 void OnStreamCreated(int stream_id,
51 base::SharedMemory* shared_memory,
52 base::CancelableSyncSocket* foreign_socket) override;
53 void OnStreamError(int stream_id) override;
54
55 // Closes connection to client and notifies owner.
56 void OnError();
57
58 StreamCreatedCallback stream_created_callback_;
59 base::OnceClosure deleter_callback_;
60 mojo::Binding<AudioOutputStream> binding_;
61 base::ThreadChecker thread_checker_;
62 std::unique_ptr<AudioOutputDelegate> delegate_;
63
64 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputStream);
65 };
66
67 } // namespace media
68
69 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_STREAM_H_
OLDNEW
« no previous file with comments | « media/mojo/services/BUILD.gn ('k') | media/mojo/services/mojo_audio_output_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698