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

Unified Diff: media/renderers/renderer_impl.cc

Issue 1812543003: Allow muting/unmuting audio through media track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: Avoid ChunkDemuxer/PipelineImpl deadlock Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/renderers/renderer_impl.h ('k') | media/test/pipeline_integration_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/renderer_impl.cc
diff --git a/media/renderers/renderer_impl.cc b/media/renderers/renderer_impl.cc
index 38f49d4b66099adbb753cd1cccf67e8d79524e2d..a8e86bd8c8a5574c5e8637990c14b6ae48333766 100644
--- a/media/renderers/renderer_impl.cc
+++ b/media/renderers/renderer_impl.cc
@@ -205,8 +205,16 @@ void RendererImpl::SetVolume(float volume) {
DVLOG(1) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
- if (audio_renderer_)
- audio_renderer_->SetVolume(volume);
+ audio_volume_ = volume;
+ if (!audio_renderer_)
+ return;
+
+ if (audio_stream_currently_disabled_) {
+ DVLOG(1) << "SetVolume ignored since audio stream is currently disabled.";
+ return;
+ }
+
+ audio_renderer_->SetVolume(volume);
}
base::TimeDelta RendererImpl::GetMediaTime() {
@@ -225,6 +233,52 @@ bool RendererImpl::HasVideo() {
return video_renderer_ != NULL;
}
+void RendererImpl::OnEnabledAudioStreamsChanged(
+ const std::vector<const DemuxerStream*>& enabledAudioStreams) {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ // DemuxerStream* audio_stream =
+ // demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO);
+
+ bool audio_stream_enabled = false;
+ for (const DemuxerStream* demuxer_stream : enabledAudioStreams) {
+ DCHECK_EQ(demuxer_stream->type(), DemuxerStream::AUDIO);
+ // DCHECK_EQ(demuxer_stream, audio_stream);
+ audio_stream_enabled = true;
+ }
+
+ // TODO(servolk,wolenetz): Need to find a way to completely disable audio
+ // (i.e. stop audio decoder and switch video to wall clock) when audio stream
+ // is disabled, but for now just set volume to 0. crbug.com/599709
+ if (audio_renderer_) {
+ if (audio_stream_enabled && audio_stream_currently_disabled_) {
+ DVLOG(3) << __FUNCTION__ << " enabled audio. SetVolume=" << audio_volume_;
+ audio_stream_currently_disabled_ = false;
+ audio_renderer_->SetVolume(audio_volume_);
+ } else if (!audio_stream_enabled) {
+ DVLOG(3) << __FUNCTION__ << " disabled audio. SetVolume=0";
+ DCHECK(!audio_stream_currently_disabled_);
+ audio_stream_currently_disabled_ = true;
+ audio_renderer_->SetVolume(0);
+ }
+ }
+}
+
+void RendererImpl::OnSelectedVideoStreamChanged(
+ const DemuxerStream* selectedVideoStream) {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ // DemuxerStream* video_stream =
+ // demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO);
+ if (selectedVideoStream) {
+ DVLOG(3) << __FUNCTION__ << " selectedVideoStream=" << selectedVideoStream;
+ DCHECK_EQ(selectedVideoStream->type(), DemuxerStream::VIDEO);
+ // CHECK_EQ(selectedVideoStream, video_stream);
+ } else {
+ DVLOG(3) << __FUNCTION__ << " selectedVideoStream=none";
+ // TODO(servolk,wolenetz): Need to find a way to stop video decoding and
+ // rendering when the video stream is deselected. crbug.com/599709
+ }
+}
+
void RendererImpl::DisableUnderflowForTesting() {
DVLOG(1) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
« no previous file with comments | « media/renderers/renderer_impl.h ('k') | media/test/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698