OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cras/cras_unified.h" | 5 #include "media/audio/cras/cras_unified.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/audio/cras/audio_manager_cras.h" | 8 #include "media/audio/cras/audio_manager_cras.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // Determine latency and pass that on to the source. We have the capture time | 350 // Determine latency and pass that on to the source. We have the capture time |
351 // of the first input sample and the playback time of the next audio sample | 351 // of the first input sample and the playback time of the next audio sample |
352 // passed from the audio server, add them together for total latency. | 352 // passed from the audio server, add them together for total latency. |
353 uint32 total_delay_bytes; | 353 uint32 total_delay_bytes; |
354 timespec latency_ts = {0, 0}; | 354 timespec latency_ts = {0, 0}; |
355 cras_client_calc_capture_latency(input_ts, &latency_ts); | 355 cras_client_calc_capture_latency(input_ts, &latency_ts); |
356 total_delay_bytes = GetBytesLatency(latency_ts); | 356 total_delay_bytes = GetBytesLatency(latency_ts); |
357 cras_client_calc_playback_latency(output_ts, &latency_ts); | 357 cras_client_calc_playback_latency(output_ts, &latency_ts); |
358 total_delay_bytes += GetBytesLatency(latency_ts); | 358 total_delay_bytes += GetBytesLatency(latency_ts); |
359 | 359 |
360 int frames_filled = source_callback_->OnMoreIOData( | 360 int frames_filled = source_callback_->OnMoreData( |
361 input_bus_.get(), | |
362 output_bus_.get(), | 361 output_bus_.get(), |
363 AudioBuffersState(0, total_delay_bytes)); | 362 AudioBuffersState(0, total_delay_bytes)); |
364 | 363 |
365 output_bus_->ToInterleaved(frames_filled, bytes_per_sample, output_samples); | 364 output_bus_->ToInterleaved(frames_filled, bytes_per_sample, output_samples); |
366 | 365 |
367 return frames_filled; | 366 return frames_filled; |
368 } | 367 } |
369 | 368 |
370 uint32 CrasUnifiedStream::WriteAudio(size_t frames, | 369 uint32 CrasUnifiedStream::WriteAudio(size_t frames, |
371 uint8* buffer, | 370 uint8* buffer, |
(...skipping 15 matching lines...) Expand all Loading... |
387 return frames_filled; | 386 return frames_filled; |
388 } | 387 } |
389 | 388 |
390 void CrasUnifiedStream::NotifyStreamError(int err) { | 389 void CrasUnifiedStream::NotifyStreamError(int err) { |
391 // This will remove the stream from the client. | 390 // This will remove the stream from the client. |
392 if (source_callback_) | 391 if (source_callback_) |
393 source_callback_->OnError(this); | 392 source_callback_->OnError(this); |
394 } | 393 } |
395 | 394 |
396 } // namespace media | 395 } // namespace media |
OLD | NEW |