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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 uint32 CrasUnifiedStream::WriteAudio(size_t frames, | 299 uint32 CrasUnifiedStream::WriteAudio(size_t frames, |
300 uint8* buffer, | 300 uint8* buffer, |
301 const timespec* sample_ts) { | 301 const timespec* sample_ts) { |
302 DCHECK_EQ(frames, static_cast<size_t>(output_bus_->frames())); | 302 DCHECK_EQ(frames, static_cast<size_t>(output_bus_->frames())); |
303 | 303 |
304 // Determine latency and pass that on to the source. | 304 // Determine latency and pass that on to the source. |
305 timespec latency_ts = {0, 0}; | 305 timespec latency_ts = {0, 0}; |
306 cras_client_calc_playback_latency(sample_ts, &latency_ts); | 306 cras_client_calc_playback_latency(sample_ts, &latency_ts); |
307 | 307 |
308 int frames_filled = source_callback_->OnMoreData( | 308 int frames_filled = source_callback_->OnMoreData( |
309 output_bus_.get(), AudioBuffersState(0, GetBytesLatency(latency_ts))); | 309 output_bus_.get(), GetBytesLatency(latency_ts)); |
310 | 310 |
311 // Note: If this ever changes to output raw float the data must be clipped and | 311 // Note: If this ever changes to output raw float the data must be clipped and |
312 // sanitized since it may come from an untrusted source such as NaCl. | 312 // sanitized since it may come from an untrusted source such as NaCl. |
313 output_bus_->ToInterleaved( | 313 output_bus_->ToInterleaved( |
314 frames_filled, bytes_per_frame_ / params_.channels(), buffer); | 314 frames_filled, bytes_per_frame_ / params_.channels(), buffer); |
315 | 315 |
316 return frames_filled; | 316 return frames_filled; |
317 } | 317 } |
318 | 318 |
319 void CrasUnifiedStream::NotifyStreamError(int err) { | 319 void CrasUnifiedStream::NotifyStreamError(int err) { |
320 // This will remove the stream from the client. | 320 // This will remove the stream from the client. |
321 if (source_callback_) | 321 if (source_callback_) |
322 source_callback_->OnError(this); | 322 source_callback_->OnError(this); |
323 } | 323 } |
324 | 324 |
325 } // namespace media | 325 } // namespace media |
OLD | NEW |