| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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 CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/files/file.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/threading/thread_checker.h" |
| 15 #include "content/common/content_export.h" |
| 16 #include "content/common/media/audio_output.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" |
| 18 #include "mojo/public/cpp/bindings/interface_request.h" |
| 19 |
| 20 namespace base { |
| 21 class SingleThreadTaskRunner; |
| 22 } |
| 23 |
| 24 namespace media { |
| 25 class AudioParameters; |
| 26 } |
| 27 |
| 28 namespace content { |
| 29 |
| 30 class ServiceRegistry; |
| 31 |
| 32 // All functions must only be accessed from the creation thread. |
| 33 class CONTENT_EXPORT AudioOutputClient { |
| 34 public: |
| 35 explicit AudioOutputClient(ServiceRegistry* service_registry); |
| 36 |
| 37 // Getter for the one AudioOutputClient object. |
| 38 static AudioOutputClient* Get(); |
| 39 |
| 40 ~AudioOutputClient(); |
| 41 |
| 42 void CreateStream(int stream_id_, |
| 43 int render_frame_id_, |
| 44 const media::AudioParameters& params); |
| 45 void CreateStreamCallback(mojo::ScopedSharedBufferHandle shared_buffer, |
| 46 mojo::ScopedHandle socket_descriptor, |
| 47 AudioOutputStreamPtr stream); |
| 48 void CreateStreamOnMainThread(int stream_id_, |
| 49 int render_frame_id_, |
| 50 const media::AudioParameters& params); |
| 51 |
| 52 void CloseStream(int id); |
| 53 void CloseStreamOnMainThread(int id); |
| 54 |
| 55 private: |
| 56 friend class base::RefCountedThreadSafe<AudioOutputClient>; |
| 57 |
| 58 // Mojo connection error handler. |
| 59 void OnConnectionError(); |
| 60 |
| 61 // The Mojo service for registering observers to listen for enable/disable |
| 62 // events. |
| 63 AudioOutputPtr service_; |
| 64 |
| 65 // The singleton instance for this. |
| 66 static AudioOutputClient* g_filter; |
| 67 |
| 68 base::ThreadChecker thread_checker_; |
| 69 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(AudioOutputClient); |
| 72 }; |
| 73 |
| 74 } // namespace content |
| 75 |
| 76 #endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_ |
| OLD | NEW |