| 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/process.h" | 9 #include "base/process/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 // TODO(dalecurtis): Remove block. |
| 36 virtual int Read(bool block, | 37 virtual int Read(bool block, |
| 37 const media::AudioBus* source, | 38 const media::AudioBus* source, |
| 38 media::AudioBus* dest) OVERRIDE; | 39 media::AudioBus* dest) OVERRIDE; |
| 39 virtual void Close() OVERRIDE; | 40 virtual void Close() OVERRIDE; |
| 40 | 41 |
| 41 bool Init(); | 42 bool Init(); |
| 42 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, | 43 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, |
| 43 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 44 base::SyncSocket::Handle* foreign_handle); | 45 base::SyncSocket::Handle* foreign_handle); |
| 45 #else | 46 #else |
| 46 base::FileDescriptor* foreign_handle); | 47 base::FileDescriptor* foreign_handle); |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 // Indicates whether the renderer has data available for reading. | 51 // Indicates whether the renderer has data available for reading. |
| 51 bool DataReady(); | 52 bool DataReady(); |
| 52 | 53 |
| 53 // Blocks until DataReady() is true or a timeout expires. | 54 // Blocks until DataReady() is true or a timeout expires. Returns false if a |
| 54 void WaitTillDataReady(); | 55 // timeout occurs. |
| 56 bool WaitTillDataReady(); |
| 55 | 57 |
| 56 base::SharedMemory* shared_memory_; | 58 base::SharedMemory* shared_memory_; |
| 57 | 59 |
| 58 // Number of input channels for synchronized I/O. | 60 // Number of input channels for synchronized I/O. |
| 59 int input_channels_; | 61 int input_channels_; |
| 60 | 62 |
| 61 // Mutes all incoming samples. This is used to prevent audible sound | 63 // Mutes all incoming samples. This is used to prevent audible sound |
| 62 // during automated testing. | 64 // during automated testing. |
| 63 bool mute_audio_; | 65 bool mute_audio_; |
| 64 | 66 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 scoped_ptr<media::AudioBus> input_bus_; | 78 scoped_ptr<media::AudioBus> input_bus_; |
| 77 | 79 |
| 78 // Maximum amount of audio data which can be transferred in one Read() call. | 80 // Maximum amount of audio data which can be transferred in one Read() call. |
| 79 int packet_size_; | 81 int packet_size_; |
| 80 | 82 |
| 81 // Track the number of times the renderer missed its real-time deadline and | 83 // Track the number of times the renderer missed its real-time deadline and |
| 82 // report a UMA stat during destruction. | 84 // report a UMA stat during destruction. |
| 83 size_t renderer_callback_count_; | 85 size_t renderer_callback_count_; |
| 84 size_t renderer_missed_callback_count_; | 86 size_t renderer_missed_callback_count_; |
| 85 | 87 |
| 88 // The maximum amount of time to wait for data from the renderer. Calculated |
| 89 // from the parameters given at construction. |
| 90 const base::TimeDelta maximum_wait_time_; |
| 91 |
| 92 // The index of the audio buffer we're expecting to be sent from the renderer; |
| 93 // used to block with timeout for audio data. |
| 94 uint32_t buffer_index_; |
| 95 |
| 86 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); | 96 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); |
| 87 }; | 97 }; |
| 88 | 98 |
| 89 } // namespace content | 99 } // namespace content |
| 90 | 100 |
| 91 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ | 101 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ |
| OLD | NEW |