OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // AudioRendererHost serves audio related requests from AudioRenderer which | 5 // AudioRendererHost serves audio related requests from AudioRenderer which |
6 // lives inside the render process and provide access to audio hardware. It maps | 6 // lives inside the render process and provide access to audio hardware. It maps |
7 // an internal ID to AudioRendererHost::IPCAudioSource in a map, which is the | 7 // an internal ID to AudioRendererHost::IPCAudioSource in a map, which is the |
8 // actual object providing audio packets through IPC. It creates the actual | 8 // actual object providing audio packets through IPC. It creates the actual |
9 // AudioOutputStream object when requested by the renderer provided with | 9 // AudioOutputStream object when requested by the renderer provided with |
10 // render view id and stream id. | 10 // render view id and stream id. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 #include "base/process.h" | 73 #include "base/process.h" |
74 #include "base/ref_counted.h" | 74 #include "base/ref_counted.h" |
75 #include "base/shared_memory.h" | 75 #include "base/shared_memory.h" |
76 #include "base/waitable_event.h" | 76 #include "base/waitable_event.h" |
77 #include "ipc/ipc_message.h" | 77 #include "ipc/ipc_message.h" |
78 #include "media/audio/audio_output.h" | 78 #include "media/audio/audio_output.h" |
79 #include "media/audio/simple_sources.h" | 79 #include "media/audio/simple_sources.h" |
80 #include "testing/gtest/include/gtest/gtest_prod.h" | 80 #include "testing/gtest/include/gtest/gtest_prod.h" |
81 | 81 |
82 class AudioManager; | 82 class AudioManager; |
83 class MessageLoop; | |
84 struct ViewHostMsg_Audio_CreateStream; | 83 struct ViewHostMsg_Audio_CreateStream; |
85 | 84 |
86 class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> { | 85 class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> { |
87 private: | 86 private: |
88 class IPCAudioSource; | 87 class IPCAudioSource; |
89 public: | 88 public: |
90 // Called from UI thread from the owner of this object. | 89 // Called from UI thread from the owner of this object. |
91 explicit AudioRendererHost(MessageLoop* message_loop); | 90 AudioRendererHost(); |
92 | 91 |
93 // Destruction can happen on either UI thread or IO thread, but at destruction | 92 // Destruction can happen on either UI thread or IO thread, but at destruction |
94 // all associated sources are destroyed and streams are closed. | 93 // all associated sources are destroyed and streams are closed. |
95 virtual ~AudioRendererHost(); | 94 virtual ~AudioRendererHost(); |
96 | 95 |
97 // Called from UI thread from the owner of this object to kick start | 96 // Called from UI thread from the owner of this object to kick start |
98 // destruction of streams in IO thread. | 97 // destruction of streams in IO thread. |
99 void Destroy(); | 98 void Destroy(); |
100 | 99 |
101 //--------------------------------------------------------------------------- | 100 //--------------------------------------------------------------------------- |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 void OnDestroySource(IPCAudioSource* source); | 332 void OnDestroySource(IPCAudioSource* source); |
334 | 333 |
335 // A helper method that destroy all IPCAudioSource and associated audio | 334 // A helper method that destroy all IPCAudioSource and associated audio |
336 // output streams. | 335 // output streams. |
337 void DestroyAllSources(); | 336 void DestroyAllSources(); |
338 | 337 |
339 // A helper method to look up a IPCAudioSource with a tuple of render view id | 338 // A helper method to look up a IPCAudioSource with a tuple of render view id |
340 // and stream id. Returns NULL if not found. | 339 // and stream id. Returns NULL if not found. |
341 IPCAudioSource* Lookup(int render_view_id, int stream_id); | 340 IPCAudioSource* Lookup(int render_view_id, int stream_id); |
342 | 341 |
343 MessageLoop* io_loop() { return io_loop_; } | |
344 | |
345 int process_id_; | 342 int process_id_; |
346 base::ProcessHandle process_handle_; | 343 base::ProcessHandle process_handle_; |
347 IPC::Message::Sender* ipc_sender_; | 344 IPC::Message::Sender* ipc_sender_; |
348 | 345 |
349 // A map of id to audio sources. | 346 // A map of id to audio sources. |
350 typedef std::pair<int32, int32> SourceID; | 347 typedef std::pair<int32, int32> SourceID; |
351 typedef std::map<SourceID, IPCAudioSource*> SourceMap; | 348 typedef std::map<SourceID, IPCAudioSource*> SourceMap; |
352 SourceMap sources_; | 349 SourceMap sources_; |
353 | 350 |
354 MessageLoop* io_loop_; | |
355 | |
356 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 351 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
357 }; | 352 }; |
358 | 353 |
359 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ | 354 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |