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 #include "media/audio/pulse/pulse_util.h" | 5 #include "media/audio/pulse/pulse_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "media/audio/audio_manager_base.h" | 9 #include "media/audio/audio_manager_base.h" |
10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 pa_buffer_attributes.tlength = params.GetBytesPerBuffer() * 3; | 282 pa_buffer_attributes.tlength = params.GetBytesPerBuffer() * 3; |
283 pa_buffer_attributes.fragsize = static_cast<uint32_t>(-1); | 283 pa_buffer_attributes.fragsize = static_cast<uint32_t>(-1); |
284 | 284 |
285 // Connect playback stream. Like pa_buffer_attr, the pa_stream_flags have a | 285 // Connect playback stream. Like pa_buffer_attr, the pa_stream_flags have a |
286 // huge impact on the performance of the stream and were chosen through trial | 286 // huge impact on the performance of the stream and were chosen through trial |
287 // and error. | 287 // and error. |
288 RETURN_ON_FAILURE( | 288 RETURN_ON_FAILURE( |
289 pa_stream_connect_playback( | 289 pa_stream_connect_playback( |
290 *stream, NULL, &pa_buffer_attributes, | 290 *stream, NULL, &pa_buffer_attributes, |
291 static_cast<pa_stream_flags_t>( | 291 static_cast<pa_stream_flags_t>( |
292 PA_STREAM_FIX_RATE | PA_STREAM_INTERPOLATE_TIMING | | 292 PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | |
293 PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE | | 293 PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_NOT_MONOTONIC | |
294 PA_STREAM_NOT_MONOTONIC | PA_STREAM_START_CORKED), | 294 PA_STREAM_START_CORKED), |
295 NULL, NULL) == 0, | 295 NULL, NULL) == 0, |
296 "pa_stream_connect_playback FAILED "); | 296 "pa_stream_connect_playback FAILED "); |
297 | 297 |
298 // Wait for the stream to be ready. | 298 // Wait for the stream to be ready. |
299 while (true) { | 299 while (true) { |
300 pa_stream_state_t stream_state = pa_stream_get_state(*stream); | 300 pa_stream_state_t stream_state = pa_stream_get_state(*stream); |
301 RETURN_ON_FAILURE( | 301 RETURN_ON_FAILURE( |
302 PA_STREAM_IS_GOOD(stream_state), "Invalid PulseAudio stream state"); | 302 PA_STREAM_IS_GOOD(stream_state), "Invalid PulseAudio stream state"); |
303 if (stream_state == PA_STREAM_READY) | 303 if (stream_state == PA_STREAM_READY) |
304 break; | 304 break; |
305 pa_threaded_mainloop_wait(*mainloop); | 305 pa_threaded_mainloop_wait(*mainloop); |
306 } | 306 } |
307 | 307 |
308 return true; | 308 return true; |
309 } | 309 } |
310 | 310 |
311 #undef RETURN_ON_FAILURE | 311 #undef RETURN_ON_FAILURE |
312 | 312 |
313 } // namespace pulse | 313 } // namespace pulse |
314 | 314 |
315 } // namespace media | 315 } // namespace media |
OLD | NEW |