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

Side by Side Diff: content/browser/renderer_host/media/audio_sync_reader.cc

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Improve CastMediaClient::IsSupportedPassthroughAudio() Created 4 years, 1 month 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
OLDNEW
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 "content/browser/renderer_host/media/audio_sync_reader.h" 5 #include "content/browser/renderer_host/media/audio_sync_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)), 64 maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)),
65 #endif 65 #endif
66 buffer_index_(0) { 66 buffer_index_(0) {
67 DCHECK_EQ(static_cast<size_t>(packet_size_), 67 DCHECK_EQ(static_cast<size_t>(packet_size_),
68 sizeof(media::AudioOutputBufferParameters) + 68 sizeof(media::AudioOutputBufferParameters) +
69 AudioBus::CalculateMemorySize(params)); 69 AudioBus::CalculateMemorySize(params));
70 AudioOutputBuffer* buffer = 70 AudioOutputBuffer* buffer =
71 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); 71 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory());
72 output_bus_ = AudioBus::WrapMemory(params, buffer->audio); 72 output_bus_ = AudioBus::WrapMemory(params, buffer->audio);
73 output_bus_->Zero(); 73 output_bus_->Zero();
74 output_bus_->set_is_raw_format(params.IsRawFormat());
74 } 75 }
75 76
76 AudioSyncReader::~AudioSyncReader() { 77 AudioSyncReader::~AudioSyncReader() {
77 if (!renderer_callback_count_) 78 if (!renderer_callback_count_)
78 return; 79 return;
79 80
80 DVLOG(1) << "Trailing glitch count on destruction: " 81 DVLOG(1) << "Trailing glitch count on destruction: "
81 << trailing_renderer_missed_callback_count_; 82 << trailing_renderer_missed_callback_count_;
82 83
83 // Subtract 'trailing' count of callbacks missed just before the destructor 84 // Subtract 'trailing' count of callbacks missed just before the destructor
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 LOG(WARNING) << "(log cap reached, suppressing further logs)"; 170 LOG(WARNING) << "(log cap reached, suppressing further logs)";
170 } 171 }
171 dest->Zero(); 172 dest->Zero();
172 return; 173 return;
173 } 174 }
174 175
175 trailing_renderer_missed_callback_count_ = 0; 176 trailing_renderer_missed_callback_count_ = 0;
176 177
177 if (mute_audio_) 178 if (mute_audio_)
178 dest->Zero(); 179 dest->Zero();
179 else 180 else {
181 if (output_bus_->is_raw_format()) {
182 AudioOutputBuffer* buffer =
183 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory());
184 output_bus_->set_frames(buffer->params.frames);
185 output_bus_->set_data_size(buffer->params.data_size);
186 }
180 output_bus_->CopyTo(dest); 187 output_bus_->CopyTo(dest);
188 }
181 } 189 }
182 190
183 void AudioSyncReader::Close() { 191 void AudioSyncReader::Close() {
184 socket_->Close(); 192 socket_->Close();
185 } 193 }
186 194
187 bool AudioSyncReader::WaitUntilDataIsReady() { 195 bool AudioSyncReader::WaitUntilDataIsReady() {
188 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); 196 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady");
189 base::TimeDelta timeout = maximum_wait_time_; 197 base::TimeDelta timeout = maximum_wait_time_;
190 const base::TimeTicks start_time = base::TimeTicks::Now(); 198 const base::TimeTicks start_time = base::TimeTicks::Now();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 base::TimeDelta::FromMilliseconds(1), 240 base::TimeDelta::FromMilliseconds(1),
233 base::TimeDelta::FromMilliseconds(1000), 241 base::TimeDelta::FromMilliseconds(1000),
234 50); 242 50);
235 return false; 243 return false;
236 } 244 }
237 245
238 return true; 246 return true;
239 } 247 }
240 248
241 } // namespace content 249 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698