OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ |
7 | 7 |
8 #include "base/file_descriptor_posix.h" | 8 #include "base/file_descriptor_posix.h" |
| 9 #include "base/memory/scoped_vector.h" |
9 #include "base/process.h" | 10 #include "base/process.h" |
10 #include "base/sync_socket.h" | 11 #include "base/sync_socket.h" |
11 #include "media/audio/audio_input_controller.h" | 12 #include "media/audio/audio_input_controller.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 class SharedMemory; | 15 class SharedMemory; |
15 } | 16 } |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 // A AudioInputController::SyncWriter implementation using SyncSocket. This | 19 // A AudioInputController::SyncWriter implementation using SyncSocket. This |
19 // is used by AudioInputController to provide a low latency data source for | 20 // is used by AudioInputController to provide a low latency data source for |
20 // transmitting audio packets between the browser process and the renderer | 21 // transmitting audio packets between the browser process and the renderer |
21 // process. | 22 // process. |
22 class AudioInputSyncWriter : public media::AudioInputController::SyncWriter { | 23 class AudioInputSyncWriter : public media::AudioInputController::SyncWriter { |
23 public: | 24 public: |
24 explicit AudioInputSyncWriter(base::SharedMemory* shared_memory); | 25 typedef ScopedVector<base::SharedMemory> SharedMemoryVector; |
| 26 |
| 27 explicit AudioInputSyncWriter(SharedMemoryVector* shared_memory); |
25 | 28 |
26 virtual ~AudioInputSyncWriter(); | 29 virtual ~AudioInputSyncWriter(); |
27 | 30 |
28 // media::AudioOutputController::SyncWriter implementation. | 31 // media::AudioOutputController::SyncWriter implementation. |
29 virtual void UpdateRecordedBytes(uint32 bytes) OVERRIDE; | 32 virtual void UpdateRecordedBytes(uint32 bytes) OVERRIDE; |
30 virtual uint32 Write(const void* data, uint32 size, double volume) OVERRIDE; | 33 virtual uint32 Write(const void* data, uint32 size, double volume) OVERRIDE; |
31 virtual void Close() OVERRIDE; | 34 virtual void Close() OVERRIDE; |
32 | 35 |
33 bool Init(); | 36 bool Init(); |
34 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, | 37 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, |
35 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
36 base::SyncSocket::Handle* foreign_handle); | 39 base::SyncSocket::Handle* foreign_handle); |
37 #else | 40 #else |
38 base::FileDescriptor* foreign_handle); | 41 base::FileDescriptor* foreign_handle); |
39 #endif | 42 #endif |
40 | 43 |
41 private: | 44 private: |
42 base::SharedMemory* shared_memory_; | 45 SharedMemoryVector* shared_memory_; |
| 46 size_t current_buffer_id_; |
43 | 47 |
44 // Socket for transmitting audio data. | 48 // Socket for transmitting audio data. |
45 scoped_ptr<base::CancelableSyncSocket> socket_; | 49 scoped_ptr<base::CancelableSyncSocket> socket_; |
46 | 50 |
47 // Socket to be used by the renderer. The reference is released after | 51 // Socket to be used by the renderer. The reference is released after |
48 // PrepareForeignSocketHandle() is called and ran successfully. | 52 // PrepareForeignSocketHandle() is called and ran successfully. |
49 scoped_ptr<base::CancelableSyncSocket> foreign_socket_; | 53 scoped_ptr<base::CancelableSyncSocket> foreign_socket_; |
50 | 54 |
51 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputSyncWriter); | 55 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputSyncWriter); |
52 }; | 56 }; |
53 | 57 |
54 } // namespace content | 58 } // namespace content |
55 | 59 |
56 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ | 60 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ |
OLD | NEW |