OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_output.h" | 5 #include "media/audio/pulse/pulse_output.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "media/audio/audio_parameters.h" | 9 #include "media/audio/audio_parameters.h" |
10 #include "media/audio/audio_util.h" | 10 #include "media/audio/audio_util.h" |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // Write data to stream. | 376 // Write data to stream. |
377 pa_stream_write(playback_handle_, chunk, chunk_size, | 377 pa_stream_write(playback_handle_, chunk, chunk_size, |
378 NULL, 0LL, PA_SEEK_RELATIVE); | 378 NULL, 0LL, PA_SEEK_RELATIVE); |
379 client_buffer_->Seek(chunk_size); | 379 client_buffer_->Seek(chunk_size); |
380 *bytes_written += chunk_size; | 380 *bytes_written += chunk_size; |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 void PulseAudioOutputStream::Start(AudioSourceCallback* callback) { | 384 void PulseAudioOutputStream::Start(AudioSourceCallback* callback) { |
385 DCHECK_EQ(message_loop_, MessageLoop::current()); | 385 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 386 CHECK(callback); |
| 387 DLOG_IF(ERROR, !playback_handle_) |
| 388 << "Open() has not been called successfully"; |
| 389 if (!playback_handle_) |
| 390 return; |
386 | 391 |
387 CHECK(callback); | |
388 source_callback_ = callback; | 392 source_callback_ = callback; |
389 | 393 |
390 // Clear buffer, it might still have data in it. | 394 // Clear buffer, it might still have data in it. |
391 client_buffer_->Clear(); | 395 client_buffer_->Clear(); |
392 stream_stopped_ = false; | 396 stream_stopped_ = false; |
393 | 397 |
394 // Start playback. | 398 // Start playback. |
395 message_loop_->PostTask(FROM_HERE, base::Bind( | 399 message_loop_->PostTask(FROM_HERE, base::Bind( |
396 &PulseAudioOutputStream::WaitForWriteRequest, | 400 &PulseAudioOutputStream::WaitForWriteRequest, |
397 weak_factory_.GetWeakPtr())); | 401 weak_factory_.GetWeakPtr())); |
(...skipping 17 matching lines...) Expand all Loading... |
415 *volume = volume_; | 419 *volume = volume_; |
416 } | 420 } |
417 | 421 |
418 uint32 PulseAudioOutputStream::RunDataCallback( | 422 uint32 PulseAudioOutputStream::RunDataCallback( |
419 uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { | 423 uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { |
420 if (source_callback_) | 424 if (source_callback_) |
421 return source_callback_->OnMoreData(this, dest, max_size, buffers_state); | 425 return source_callback_->OnMoreData(this, dest, max_size, buffers_state); |
422 | 426 |
423 return 0; | 427 return 0; |
424 } | 428 } |
OLD | NEW |