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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // This function is called on the main thread. | 47 // This function is called on the main thread. |
48 void Configure(int32_t number_of_buffers); | 48 void Configure(int32_t number_of_buffers); |
49 | 49 |
50 private: | 50 private: |
51 // Initializes buffers on the main thread. | 51 // Initializes buffers on the main thread. |
52 void SetFormatOnMainThread(int bytes_per_second); | 52 void SetFormatOnMainThread(int bytes_per_second); |
53 | 53 |
54 void InitBuffers(); | 54 void InitBuffers(); |
55 | 55 |
56 // Send enqueue buffer message on the main thread. | 56 // Send enqueue buffer message on the main thread. |
57 void SendEnqueueBufferMessageOnMainThread(int32_t index); | 57 void SendEnqueueBufferMessageOnMainThread(int32_t index, |
58 int32_t buffers_init_count); | |
58 | 59 |
59 // MediaStreamAudioSink overrides: | 60 // MediaStreamAudioSink overrides: |
60 // These two functions should be called on the audio thread. | 61 // These two functions should be called on the audio thread. |
61 virtual void OnData(const int16* audio_data, | 62 virtual void OnData(const int16* audio_data, |
62 int sample_rate, | 63 int sample_rate, |
63 int number_of_channels, | 64 int number_of_channels, |
64 int number_of_frames) OVERRIDE; | 65 int number_of_frames) OVERRIDE; |
65 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; | 66 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; |
66 | 67 |
67 // Unowned host which is available during the AudioSink's lifespan. | 68 // Unowned host which is available during the AudioSink's lifespan. |
(...skipping 17 matching lines...) Expand all Loading... | |
85 | 86 |
86 // The original audio parameters which is set in the first time of | 87 // The original audio parameters which is set in the first time of |
87 // OnSetFormat being called. | 88 // OnSetFormat being called. |
88 // Access only on the audio thread. | 89 // Access only on the audio thread. |
89 media::AudioParameters original_audio_params_; | 90 media::AudioParameters original_audio_params_; |
90 | 91 |
91 // The audio data size of one audio buffer in bytes. | 92 // The audio data size of one audio buffer in bytes. |
92 // Access only on the audio thread. | 93 // Access only on the audio thread. |
93 uint32_t buffer_data_size_; | 94 uint32_t buffer_data_size_; |
94 | 95 |
95 // A lock to protect the index queue |buffers_|. | 96 // A lock to protect the index queue |buffers_|, |init_buffers_count_| and |
97 // buffers in |host_->buffer_manager()|. | |
96 base::Lock lock_; | 98 base::Lock lock_; |
97 | 99 |
98 // A queue for free buffer indices. | 100 // A queue for free buffer indices. |
99 std::deque<int32_t> buffers_; | 101 std::deque<int32_t> buffers_; |
100 | 102 |
103 // Count of |InitBuffers()| calls. | |
104 int32_t init_buffers_count_; | |
Anand Mistry (off Chromium)
2014/07/25 00:42:54
To me, after reading the code, I think it would be
Peng
2014/07/25 15:25:31
Done.
| |
105 | |
101 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; | 106 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; |
102 | 107 |
103 base::ThreadChecker audio_thread_checker_; | 108 base::ThreadChecker audio_thread_checker_; |
104 | 109 |
105 base::WeakPtrFactory<AudioSink> weak_factory_; | 110 base::WeakPtrFactory<AudioSink> weak_factory_; |
106 | 111 |
107 // Number of buffers. | 112 // Number of buffers. |
108 int32_t number_of_buffers_; | 113 int32_t number_of_buffers_; |
109 | 114 |
110 // Number of bytes per second. | 115 // Number of bytes per second. |
(...skipping 30 matching lines...) Expand all Loading... | |
141 bool connected_; | 146 bool connected_; |
142 | 147 |
143 AudioSink audio_sink_; | 148 AudioSink audio_sink_; |
144 | 149 |
145 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); | 150 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); |
146 }; | 151 }; |
147 | 152 |
148 } // namespace content | 153 } // namespace content |
149 | 154 |
150 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 155 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
OLD | NEW |