Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: media/cast/test/fake_media_source.cc

Issue 411683002: Remove muted_ and playback_rate_ from media::AudioRendererAlgorithm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix cast Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/audio_renderer_algorithm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cast/test/fake_media_source.h" 5 #include "media/cast/test/fake_media_source.h"
6 6
7 #include "base/files/memory_mapped_file.h" 7 #include "base/files/memory_mapped_file.h"
8 #include "base/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Send fake patterns. 200 // Send fake patterns.
201 task_runner_->PostTask( 201 task_runner_->PostTask(
202 FROM_HERE, 202 FROM_HERE,
203 base::Bind( 203 base::Bind(
204 &FakeMediaSource::SendNextFakeFrame, 204 &FakeMediaSource::SendNextFakeFrame,
205 base::Unretained(this))); 205 base::Unretained(this)));
206 return; 206 return;
207 } 207 }
208 208
209 // Send transcoding streams. 209 // Send transcoding streams.
210 audio_algo_.Initialize(playback_rate_, audio_params_); 210 audio_algo_.Initialize(audio_params_);
211 audio_algo_.FlushBuffers(); 211 audio_algo_.FlushBuffers();
212 audio_fifo_input_bus_ = 212 audio_fifo_input_bus_ =
213 AudioBus::Create( 213 AudioBus::Create(
214 audio_params_.channels(), audio_params_.frames_per_buffer()); 214 audio_params_.channels(), audio_params_.frames_per_buffer());
215 // Audio FIFO can carry all data fron AudioRendererAlgorithm. 215 // Audio FIFO can carry all data fron AudioRendererAlgorithm.
216 audio_fifo_.reset( 216 audio_fifo_.reset(
217 new AudioFifo(audio_params_.channels(), 217 new AudioFifo(audio_params_.channels(),
218 audio_algo_.QueueCapacity())); 218 audio_algo_.QueueCapacity()));
219 audio_resampler_.reset(new media::MultiChannelResampler( 219 audio_resampler_.reset(new media::MultiChannelResampler(
220 audio_params_.channels(), 220 audio_params_.channels(),
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 audio_algo_.EnqueueBuffer(buffer); 469 audio_algo_.EnqueueBuffer(buffer);
470 av_frame_unref(avframe); 470 av_frame_unref(avframe);
471 } while (packet_temp.size > 0); 471 } while (packet_temp.size > 0);
472 av_frame_free(&avframe); 472 av_frame_free(&avframe);
473 473
474 const int frames_needed_to_scale = 474 const int frames_needed_to_scale =
475 playback_rate_ * av_audio_context()->sample_rate / 475 playback_rate_ * av_audio_context()->sample_rate /
476 kAudioPacketsPerSecond; 476 kAudioPacketsPerSecond;
477 while (frames_needed_to_scale <= audio_algo_.frames_buffered()) { 477 while (frames_needed_to_scale <= audio_algo_.frames_buffered()) {
478 if (!audio_algo_.FillBuffer(audio_fifo_input_bus_.get(), 478 if (!audio_algo_.FillBuffer(audio_fifo_input_bus_.get(),
479 audio_fifo_input_bus_->frames())) { 479 audio_fifo_input_bus_->frames(),
480 playback_rate_)) {
480 // Nothing can be scaled. Decode some more. 481 // Nothing can be scaled. Decode some more.
481 return; 482 return;
482 } 483 }
483 484
484 // Prevent overflow of audio data in the FIFO. 485 // Prevent overflow of audio data in the FIFO.
485 if (audio_fifo_input_bus_->frames() + audio_fifo_->frames() 486 if (audio_fifo_input_bus_->frames() + audio_fifo_->frames()
486 <= audio_fifo_->max_frames()) { 487 <= audio_fifo_->max_frames()) {
487 audio_fifo_->Push(audio_fifo_input_bus_.get()); 488 audio_fifo_->Push(audio_fifo_input_bus_.get());
488 } else { 489 } else {
489 LOG(WARNING) << "Audio FIFO full; dropping samples."; 490 LOG(WARNING) << "Audio FIFO full; dropping samples.";
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 AVCodecContext* FakeMediaSource::av_audio_context() { 586 AVCodecContext* FakeMediaSource::av_audio_context() {
586 return av_audio_stream()->codec; 587 return av_audio_stream()->codec;
587 } 588 }
588 589
589 AVCodecContext* FakeMediaSource::av_video_context() { 590 AVCodecContext* FakeMediaSource::av_video_context() {
590 return av_video_stream()->codec; 591 return av_video_stream()->codec;
591 } 592 }
592 593
593 } // namespace cast 594 } // namespace cast
594 } // namespace media 595 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/audio_renderer_algorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698