| 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_SYNC_READER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ |
| 7 | 7 |
| 8 #include "base/file_descriptor_posix.h" | 8 #include "base/file_descriptor_posix.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class AudioSyncReader : public media::AudioOutputController::SyncReader { | 26 class AudioSyncReader : public media::AudioOutputController::SyncReader { |
| 27 public: | 27 public: |
| 28 AudioSyncReader(base::SharedMemory* shared_memory, | 28 AudioSyncReader(base::SharedMemory* shared_memory, |
| 29 const media::AudioParameters& params, | 29 const media::AudioParameters& params, |
| 30 int input_channels); | 30 int input_channels); |
| 31 | 31 |
| 32 virtual ~AudioSyncReader(); | 32 virtual ~AudioSyncReader(); |
| 33 | 33 |
| 34 // media::AudioOutputController::SyncReader implementations. | 34 // media::AudioOutputController::SyncReader implementations. |
| 35 virtual void UpdatePendingBytes(uint32 bytes) OVERRIDE; | 35 virtual void UpdatePendingBytes(uint32 bytes) OVERRIDE; |
| 36 virtual int Read(media::AudioBus* source, media::AudioBus* dest) OVERRIDE; | 36 virtual int Read(bool block, |
| 37 const media::AudioBus* source, |
| 38 media::AudioBus* dest) OVERRIDE; |
| 37 virtual void Close() OVERRIDE; | 39 virtual void Close() OVERRIDE; |
| 38 virtual bool DataReady() OVERRIDE; | |
| 39 | 40 |
| 40 bool Init(); | 41 bool Init(); |
| 41 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, | 42 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, |
| 42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
| 43 base::SyncSocket::Handle* foreign_handle); | 44 base::SyncSocket::Handle* foreign_handle); |
| 44 #else | 45 #else |
| 45 base::FileDescriptor* foreign_handle); | 46 base::FileDescriptor* foreign_handle); |
| 46 #endif | 47 #endif |
| 47 | 48 |
| 48 private: | 49 private: |
| 50 // Indicates whether the renderer has data available for reading. |
| 51 bool DataReady(); |
| 52 |
| 53 // Blocks until DataReady() is true or a timeout expires. |
| 54 void WaitTillDataReady(); |
| 55 |
| 49 base::SharedMemory* shared_memory_; | 56 base::SharedMemory* shared_memory_; |
| 50 | 57 |
| 51 // Number of input channels for synchronized I/O. | 58 // Number of input channels for synchronized I/O. |
| 52 int input_channels_; | 59 int input_channels_; |
| 53 | 60 |
| 54 // Socket for transmitting audio data. | 61 // Socket for transmitting audio data. |
| 55 scoped_ptr<base::CancelableSyncSocket> socket_; | 62 scoped_ptr<base::CancelableSyncSocket> socket_; |
| 56 | 63 |
| 57 // Socket to be used by the renderer. The reference is released after | 64 // Socket to be used by the renderer. The reference is released after |
| 58 // PrepareForeignSocketHandle() is called and ran successfully. | 65 // PrepareForeignSocketHandle() is called and ran successfully. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 // report a UMA stat during destruction. | 78 // report a UMA stat during destruction. |
| 72 size_t renderer_callback_count_; | 79 size_t renderer_callback_count_; |
| 73 size_t renderer_missed_callback_count_; | 80 size_t renderer_missed_callback_count_; |
| 74 | 81 |
| 75 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); | 82 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); |
| 76 }; | 83 }; |
| 77 | 84 |
| 78 } // namespace content | 85 } // namespace content |
| 79 | 86 |
| 80 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ | 87 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ |
| OLD | NEW |