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/renderers/audio_renderer_impl.h" | 5 #include "media/renderers/audio_renderer_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 MakeAudioBuffer<float>(kSampleFormat, | 252 MakeAudioBuffer<float>(kSampleFormat, |
253 kChannelLayout, | 253 kChannelLayout, |
254 kChannelCount, | 254 kChannelCount, |
255 kInputSamplesPerSecond, | 255 kInputSamplesPerSecond, |
256 1.0f, | 256 1.0f, |
257 0.0f, | 257 0.0f, |
258 frames.value, | 258 frames.value, |
259 next_timestamp_->GetTimestamp()); | 259 next_timestamp_->GetTimestamp()); |
260 next_timestamp_->AddFrames(frames.value); | 260 next_timestamp_->AddFrames(frames.value); |
261 | 261 |
262 DeliverBuffer(AudioDecoder::kOk, buffer); | 262 DeliverBuffer(DecodeStatus::OK, buffer); |
263 } | 263 } |
264 | 264 |
265 void DeliverEndOfStream() { | 265 void DeliverEndOfStream() { |
266 DCHECK(!decode_cb_.is_null()); | 266 DCHECK(!decode_cb_.is_null()); |
267 | 267 |
268 // Return EOS buffer to trigger EOS frame. | 268 // Return EOS buffer to trigger EOS frame. |
269 EXPECT_CALL(demuxer_stream_, Read(_)) | 269 EXPECT_CALL(demuxer_stream_, Read(_)) |
270 .WillOnce(RunCallback<0>(DemuxerStream::kOk, | 270 .WillOnce(RunCallback<0>(DemuxerStream::kOk, |
271 DecoderBuffer::CreateEOSBuffer())); | 271 DecoderBuffer::CreateEOSBuffer())); |
272 | 272 |
273 // Satify pending |decode_cb_| to trigger a new DemuxerStream::Read(). | 273 // Satify pending |decode_cb_| to trigger a new DemuxerStream::Read(). |
274 message_loop_.PostTask( | 274 message_loop_.PostTask( |
275 FROM_HERE, | 275 FROM_HERE, |
276 base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk)); | 276 base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK)); |
277 | 277 |
278 WaitForPendingRead(); | 278 WaitForPendingRead(); |
279 | 279 |
280 message_loop_.PostTask( | 280 message_loop_.PostTask( |
281 FROM_HERE, | 281 FROM_HERE, |
282 base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk)); | 282 base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK)); |
283 | 283 |
284 base::RunLoop().RunUntilIdle(); | 284 base::RunLoop().RunUntilIdle(); |
285 EXPECT_EQ(last_statistics_.audio_memory_usage, | 285 EXPECT_EQ(last_statistics_.audio_memory_usage, |
286 renderer_->algorithm_->GetMemoryUsage()); | 286 renderer_->algorithm_->GetMemoryUsage()); |
287 } | 287 } |
288 | 288 |
289 // Delivers frames until |renderer_|'s internal buffer is full and no longer | 289 // Delivers frames until |renderer_|'s internal buffer is full and no longer |
290 // has pending reads. | 290 // has pending reads. |
291 void DeliverRemainingAudio() { | 291 void DeliverRemainingAudio() { |
292 while (frames_remaining_in_buffer().value > 0) { | 292 while (frames_remaining_in_buffer().value > 0) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (!decode_cb_.is_null()) { | 392 if (!decode_cb_.is_null()) { |
393 // |reset_cb| will be called in DeliverBuffer(), after the decoder is | 393 // |reset_cb| will be called in DeliverBuffer(), after the decoder is |
394 // flushed. | 394 // flushed. |
395 reset_cb_ = reset_cb; | 395 reset_cb_ = reset_cb; |
396 return; | 396 return; |
397 } | 397 } |
398 | 398 |
399 message_loop_.PostTask(FROM_HERE, reset_cb); | 399 message_loop_.PostTask(FROM_HERE, reset_cb); |
400 } | 400 } |
401 | 401 |
402 void DeliverBuffer(AudioDecoder::Status status, | 402 void DeliverBuffer(DecodeStatus status, |
403 const scoped_refptr<AudioBuffer>& buffer) { | 403 const scoped_refptr<AudioBuffer>& buffer) { |
404 CHECK(!decode_cb_.is_null()); | 404 CHECK(!decode_cb_.is_null()); |
405 | 405 |
406 if (buffer.get() && !buffer->end_of_stream()) | 406 if (buffer.get() && !buffer->end_of_stream()) |
407 output_cb_.Run(buffer); | 407 output_cb_.Run(buffer); |
408 base::ResetAndReturn(&decode_cb_).Run(status); | 408 base::ResetAndReturn(&decode_cb_).Run(status); |
409 | 409 |
410 if (!reset_cb_.is_null()) | 410 if (!reset_cb_.is_null()) |
411 base::ResetAndReturn(&reset_cb_).Run(); | 411 base::ResetAndReturn(&reset_cb_).Run(); |
412 | 412 |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 // Advance far enough that we shouldn't be clamped to current time (tested | 937 // Advance far enough that we shouldn't be clamped to current time (tested |
938 // already above). | 938 // already above). |
939 tick_clock_->Advance(kOneSecond); | 939 tick_clock_->Advance(kOneSecond); |
940 EXPECT_EQ( | 940 EXPECT_EQ( |
941 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), | 941 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), |
942 CurrentMediaWallClockTime(&is_time_moving)); | 942 CurrentMediaWallClockTime(&is_time_moving)); |
943 EXPECT_TRUE(is_time_moving); | 943 EXPECT_TRUE(is_time_moving); |
944 } | 944 } |
945 | 945 |
946 } // namespace media | 946 } // namespace media |
OLD | NEW |