| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // This function is called on the main thread. | 45 // This function is called on the main thread. |
| 46 void EnqueueBuffer(int32_t index); | 46 void EnqueueBuffer(int32_t index); |
| 47 | 47 |
| 48 // This function is called on the main thread. | 48 // This function is called on the main thread. |
| 49 int32_t Configure(int32_t number_of_buffers, int32_t duration, | 49 int32_t Configure(int32_t number_of_buffers, int32_t duration, |
| 50 const ppapi::host::ReplyMessageContext& context); | 50 const ppapi::host::ReplyMessageContext& context); |
| 51 | 51 |
| 52 // Send a reply to the currently pending |Configure()| request. | 52 // Send a reply to the currently pending |Configure()| request. |
| 53 void SendConfigureReply(int32_t result); | 53 void SendConfigureReply(int32_t result); |
| 54 | 54 |
| 55 // MediaStreamAudioSink overrides: |
| 56 // These two functions should be called on the audio thread. |
| 57 // NOTE: For this specific instance, |OnSetFormat()| is also called on the |
| 58 // main thread. However, the call to |OnSetFormat()| happens before this |
| 59 // sink is added to an audio track, also on the main thread, which should |
| 60 // avoid any potential races. |
| 61 void OnData(const media::AudioBus& audio_bus, |
| 62 base::TimeTicks estimated_capture_time) override; |
| 63 void OnSetFormat(const media::AudioParameters& params) override; |
| 64 |
| 55 private: | 65 private: |
| 56 // Initializes buffers on the main thread. | 66 // Initializes buffers on the main thread. |
| 57 void SetFormatOnMainThread(int bytes_per_second, int bytes_per_frame); | 67 void SetFormatOnMainThread(int bytes_per_second, int bytes_per_frame); |
| 58 | 68 |
| 59 void InitBuffers(); | 69 void InitBuffers(); |
| 60 | 70 |
| 61 // Send enqueue buffer message on the main thread. | 71 // Send enqueue buffer message on the main thread. |
| 62 void SendEnqueueBufferMessageOnMainThread(int32_t index, | 72 void SendEnqueueBufferMessageOnMainThread(int32_t index, |
| 63 int32_t buffers_generation); | 73 int32_t buffers_generation); |
| 64 | 74 |
| 65 // MediaStreamAudioSink overrides: | |
| 66 // These two functions should be called on the audio thread. | |
| 67 void OnData(const media::AudioBus& audio_bus, | |
| 68 base::TimeTicks estimated_capture_time) override; | |
| 69 void OnSetFormat(const media::AudioParameters& params) override; | |
| 70 | |
| 71 // Unowned host which is available during the AudioSink's lifespan. | 75 // Unowned host which is available during the AudioSink's lifespan. |
| 72 // It is mainly used in the main thread. But the audio thread will use | 76 // It is mainly used in the main thread. But the audio thread will use |
| 73 // host_->buffer_manager() to read some buffer properties. It is safe | 77 // host_->buffer_manager() to read some buffer properties. It is safe |
| 74 // because the buffer_manager()'s properties will not be changed after | 78 // because the buffer_manager()'s properties will not be changed after |
| 75 // initialization. | 79 // initialization. |
| 76 PepperMediaStreamAudioTrackHost* host_; | 80 PepperMediaStreamAudioTrackHost* host_; |
| 77 | 81 |
| 78 // The estimated capture time of the first sample frame of audio. This is | 82 // The estimated capture time of the first sample frame of audio. This is |
| 79 // used as the timebase to compute the buffer timestamps. | 83 // used as the timebase to compute the buffer timestamps. |
| 80 // Access only on the audio thread. | 84 // Access only on the audio thread. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 bool connected_; | 166 bool connected_; |
| 163 | 167 |
| 164 AudioSink audio_sink_; | 168 AudioSink audio_sink_; |
| 165 | 169 |
| 166 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); | 170 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); |
| 167 }; | 171 }; |
| 168 | 172 |
| 169 } // namespace content | 173 } // namespace content |
| 170 | 174 |
| 171 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 175 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| OLD | NEW |