OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_RENDERER_HOST_AUDIO_SYNC_READER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_AUDIO_SYNC_READER_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_AUDIO_SYNC_READER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_AUDIO_SYNC_READER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/file_descriptor_posix.h" | 9 // TODO(jam): remove this file when all files have been converted. |
10 #include "base/process.h" | 10 #include "content/browser/renderer_host/audio_sync_reader.h" |
11 #include "base/sync_socket.h" | |
12 #include "media/audio/audio_output_controller.h" | |
13 | |
14 namespace base { | |
15 | |
16 class SharedMemory; | |
17 | |
18 } | |
19 | |
20 // A AudioOutputController::SyncReader implementation using SyncSocket. This | |
21 // is used by AudioOutputController to provide a low latency data source for | |
22 // transmitting audio packets between the browser process and the renderer | |
23 // process. | |
24 class AudioSyncReader : public media::AudioOutputController::SyncReader { | |
25 public: | |
26 explicit AudioSyncReader(base::SharedMemory* shared_memory); | |
27 | |
28 virtual ~AudioSyncReader(); | |
29 | |
30 // media::AudioOutputController::SyncReader implementations. | |
31 virtual void UpdatePendingBytes(uint32 bytes); | |
32 virtual uint32 Read(void* data, uint32 size); | |
33 virtual void Close(); | |
34 | |
35 bool Init(); | |
36 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, | |
37 #if defined(OS_WIN) | |
38 base::SyncSocket::Handle* foreign_handle); | |
39 #else | |
40 base::FileDescriptor* foreign_handle); | |
41 #endif | |
42 | |
43 private: | |
44 base::SharedMemory* shared_memory_; | |
45 | |
46 // A pair of SyncSocket for transmitting audio data. | |
47 scoped_ptr<base::SyncSocket> socket_; | |
48 | |
49 // SyncSocket to be used by the renderer. The reference is released after | |
50 // PrepareForeignSocketHandle() is called and ran successfully. | |
51 scoped_ptr<base::SyncSocket> foreign_socket_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); | |
54 }; | |
55 | 11 |
56 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_SYNC_READER_H_ | 12 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_SYNC_READER_H_ |
OLD | NEW |