Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: content/renderer/pepper/pepper_media_stream_audio_track_host.h

Issue 414643003: Support configuring the audio buffer duration in the Pepper MediaStream API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add clarifying comment about buffer size. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 public: 38 public:
39 explicit AudioSink(PepperMediaStreamAudioTrackHost* host); 39 explicit AudioSink(PepperMediaStreamAudioTrackHost* host);
40 virtual ~AudioSink(); 40 virtual ~AudioSink();
41 41
42 // Enqueues a free buffer index into |buffers_| which will be used for 42 // Enqueues a free buffer index into |buffers_| which will be used for
43 // sending audio samples to plugin. 43 // sending audio samples to plugin.
44 // This function is called on the main thread. 44 // This function is called on the main thread.
45 void EnqueueBuffer(int32_t index); 45 void EnqueueBuffer(int32_t index);
46 46
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, int32_t duration);
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, int bytes_per_frame);
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_generation); 58 int32_t buffers_generation);
59 59
60 // MediaStreamAudioSink overrides: 60 // MediaStreamAudioSink overrides:
61 // These two functions should be called on the audio thread. 61 // These two functions should be called on the audio thread.
62 virtual void OnData(const int16* audio_data, 62 virtual void OnData(const int16* audio_data,
(...skipping 23 matching lines...) Expand all
86 86
87 // 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
88 // OnSetFormat being called. 88 // OnSetFormat being called.
89 // Access only on the audio thread. 89 // Access only on the audio thread.
90 media::AudioParameters original_audio_params_; 90 media::AudioParameters original_audio_params_;
91 91
92 // The audio data size of one audio buffer in bytes. 92 // The audio data size of one audio buffer in bytes.
93 // Access only on the audio thread. 93 // Access only on the audio thread.
94 uint32_t buffer_data_size_; 94 uint32_t buffer_data_size_;
95 95
96 // A lock to protect the index queue |buffers_|, |buffers_generation_| and 96 // Index of the currently active buffer.
97 // buffers in |host_->buffer_manager()|. 97 // Access only on the audio thread.
98 int active_buffer_index_;
99
100 // Generation of buffers corresponding to the currently active
101 // buffer. Used to make sure the active buffer is still valid.
102 // Access only on the audio thread.
103 int32_t active_buffers_generation_;
104
105 // Current offset, in bytes, within the currently active buffer.
106 // Access only on the audio thread.
107 uint32_t active_buffer_offset_;
108
109 // A lock to protect the index queue |buffers_|, |buffers_generation_|,
110 // buffers in |host_->buffer_manager()|, and |output_buffer_size_|.
98 base::Lock lock_; 111 base::Lock lock_;
99 112
100 // A queue for free buffer indices. 113 // A queue for free buffer indices.
101 std::deque<int32_t> buffers_; 114 std::deque<int32_t> buffers_;
102 115
103 // Generation of buffers. It is increased by every |InitBuffers()| call. 116 // Generation of buffers. It is increased by every |InitBuffers()| call.
104 int32_t buffers_generation_; 117 int32_t buffers_generation_;
105 118
119 // Intended size of each output buffer.
120 int32_t output_buffer_size_;
121
106 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; 122 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_;
107 123
108 base::ThreadChecker audio_thread_checker_; 124 base::ThreadChecker audio_thread_checker_;
109 125
110 base::WeakPtrFactory<AudioSink> weak_factory_; 126 base::WeakPtrFactory<AudioSink> weak_factory_;
111 127
112 // Number of buffers. 128 // Number of buffers.
113 int32_t number_of_buffers_; 129 int32_t number_of_buffers_;
114 130
115 // Number of bytes per second. 131 // Number of bytes per second.
116 int bytes_per_second_; 132 int bytes_per_second_;
117 133
134 // Number of bytes per frame = channels * bytes per sample.
135 int bytes_per_frame_;
136
137 // User-configured buffer duration, in milliseconds.
138 int32_t user_buffer_duration_;
139
118 DISALLOW_COPY_AND_ASSIGN(AudioSink); 140 DISALLOW_COPY_AND_ASSIGN(AudioSink);
119 }; 141 };
120 142
121 virtual ~PepperMediaStreamAudioTrackHost(); 143 virtual ~PepperMediaStreamAudioTrackHost();
122 144
123 // ResourceMessageHandler overrides: 145 // ResourceMessageHandler overrides:
124 virtual int32_t OnResourceMessageReceived( 146 virtual int32_t OnResourceMessageReceived(
125 const IPC::Message& msg, 147 const IPC::Message& msg,
126 ppapi::host::HostMessageContext* context) OVERRIDE; 148 ppapi::host::HostMessageContext* context) OVERRIDE;
127 149
(...skipping 18 matching lines...) Expand all
146 bool connected_; 168 bool connected_;
147 169
148 AudioSink audio_sink_; 170 AudioSink audio_sink_;
149 171
150 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); 172 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost);
151 }; 173 };
152 174
153 } // namespace content 175 } // namespace content
154 176
155 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ 177 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698