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

Side by Side Diff: media/audio/pulse/pulse_input.cc

Issue 2891303002: Fake no input callbacks in PulseAudio. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « media/audio/pulse/pulse_input.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/audio/pulse/pulse_input.h" 5 #include "media/audio/pulse/pulse_input.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/audio/audio_device_description.h" 10 #include "media/audio/audio_device_description.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 &pulse::StreamSuccessCallback, 105 &pulse::StreamSuccessCallback,
106 pa_mainloop_); 106 pa_mainloop_);
107 WaitForOperationCompletion(pa_mainloop_, operation); 107 WaitForOperationCompletion(pa_mainloop_, operation);
108 108
109 // Stop the stream. 109 // Stop the stream.
110 pa_stream_set_read_callback(handle_, NULL, NULL); 110 pa_stream_set_read_callback(handle_, NULL, NULL);
111 operation = pa_stream_cork(handle_, 1, &pulse::StreamSuccessCallback, 111 operation = pa_stream_cork(handle_, 1, &pulse::StreamSuccessCallback,
112 pa_mainloop_); 112 pa_mainloop_);
113 WaitForOperationCompletion(pa_mainloop_, operation); 113 WaitForOperationCompletion(pa_mainloop_, operation);
114 callback_ = NULL; 114 callback_ = NULL;
115
116 callback_count_ = 0;
115 } 117 }
116 118
117 void PulseAudioInputStream::Close() { 119 void PulseAudioInputStream::Close() {
118 DCHECK(thread_checker_.CalledOnValidThread()); 120 DCHECK(thread_checker_.CalledOnValidThread());
119 { 121 {
120 AutoPulseLock auto_lock(pa_mainloop_); 122 AutoPulseLock auto_lock(pa_mainloop_);
121 if (handle_) { 123 if (handle_) {
122 // Disable all the callbacks before disconnecting. 124 // Disable all the callbacks before disconnecting.
123 pa_stream_set_state_callback(handle_, NULL, NULL); 125 pa_stream_set_state_callback(handle_, NULL, NULL);
124 pa_operation* operation = pa_stream_flush( 126 pa_operation* operation = pa_stream_flush(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 265
264 if (s && stream->callback_ && 266 if (s && stream->callback_ &&
265 pa_stream_get_state(s) == PA_STREAM_FAILED) { 267 pa_stream_get_state(s) == PA_STREAM_FAILED) {
266 stream->callback_->OnError(stream); 268 stream->callback_->OnError(stream);
267 } 269 }
268 270
269 pa_threaded_mainloop_signal(stream->pa_mainloop_, 0); 271 pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
270 } 272 }
271 273
272 void PulseAudioInputStream::ReadData() { 274 void PulseAudioInputStream::ReadData() {
275 if (callback_count_++ > 1000)
276 return;
277
273 uint32_t hardware_delay = pulse::GetHardwareLatencyInBytes( 278 uint32_t hardware_delay = pulse::GetHardwareLatencyInBytes(
274 handle_, params_.sample_rate(), params_.GetBytesPerFrame()); 279 handle_, params_.sample_rate(), params_.GetBytesPerFrame());
275 280
276 // Update the AGC volume level once every second. Note that, 281 // Update the AGC volume level once every second. Note that,
277 // |volume| is also updated each time SetVolume() is called 282 // |volume| is also updated each time SetVolume() is called
278 // through IPC by the render-side AGC. 283 // through IPC by the render-side AGC.
279 // We disregard the |normalized_volume| from GetAgcVolume() 284 // We disregard the |normalized_volume| from GetAgcVolume()
280 // and use the value calculated by |volume_|. 285 // and use the value calculated by |volume_|.
281 double normalized_volume = 0.0; 286 double normalized_volume = 0.0;
282 GetAgcVolume(&normalized_volume); 287 GetAgcVolume(&normalized_volume);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return false; 332 return false;
328 333
329 size_t index = pa_stream_get_device_index(handle_); 334 size_t index = pa_stream_get_device_index(handle_);
330 pa_operation* operation = 335 pa_operation* operation =
331 pa_context_get_source_info_by_index(pa_context_, index, callback, this); 336 pa_context_get_source_info_by_index(pa_context_, index, callback, this);
332 WaitForOperationCompletion(pa_mainloop_, operation); 337 WaitForOperationCompletion(pa_mainloop_, operation);
333 return true; 338 return true;
334 } 339 }
335 340
336 } // namespace media 341 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/pulse/pulse_input.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698