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

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

Issue 1703473002: Make AudioOutputDevice restartable and reinitializable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_mixing
Patch Set: Created 4 years, 10 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
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 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 // Zero out the entire output buffer to avoid stuttering/repeating-buffers 99 // Zero out the entire output buffer to avoid stuttering/repeating-buffers
100 // in the anomalous case if the renderer is unable to keep up with real-time. 100 // in the anomalous case if the renderer is unable to keep up with real-time.
101 output_bus_->Zero(); 101 output_bus_->Zero();
102 102
103 socket_->Send(&bytes, sizeof(bytes)); 103 socket_->Send(&bytes, sizeof(bytes));
104 ++buffer_index_; 104 ++buffer_index_;
105 } 105 }
106 106
107 void AudioSyncReader::Read(AudioBus* dest) { 107 void AudioSyncReader::Read(AudioBus* dest) {
108 // printf("--+--+--+--+-- AudioSyncReader::Read enter\n");
108 ++renderer_callback_count_; 109 ++renderer_callback_count_;
109 if (!WaitUntilDataIsReady()) { 110 if (!WaitUntilDataIsReady()) {
110 ++renderer_missed_callback_count_; 111 ++renderer_missed_callback_count_;
111 if (renderer_missed_callback_count_ <= 100) { 112 if (renderer_missed_callback_count_ <= 100) {
112 LOG(WARNING) << "AudioSyncReader::Read timed out, audio glitch count=" 113 LOG(WARNING) << "AudioSyncReader::Read timed out, audio glitch count="
113 << renderer_missed_callback_count_; 114 << renderer_missed_callback_count_;
114 if (renderer_missed_callback_count_ == 100) 115 if (renderer_missed_callback_count_ == 100)
115 LOG(WARNING) << "(log cap reached, suppressing further logs)"; 116 LOG(WARNING) << "(log cap reached, suppressing further logs)";
116 } 117 }
117 dest->Zero(); 118 dest->Zero();
119 // printf("--+--+--+--+-- AudioSyncReader::Read exit 1\n");
118 return; 120 return;
119 } 121 }
120 122
121 if (mute_audio_) 123 if (mute_audio_)
122 dest->Zero(); 124 dest->Zero();
123 else 125 else
124 output_bus_->CopyTo(dest); 126 output_bus_->CopyTo(dest);
127
128 // printf("--+--+--+--+-- AudioSyncReader::Read exit 2\n");
125 } 129 }
126 130
127 void AudioSyncReader::Close() { 131 void AudioSyncReader::Close() {
128 socket_->Close(); 132 socket_->Close();
129 } 133 }
130 134
131 bool AudioSyncReader::Init() { 135 bool AudioSyncReader::Init() {
132 socket_.reset(new base::CancelableSyncSocket()); 136 socket_.reset(new base::CancelableSyncSocket());
133 foreign_socket_.reset(new base::CancelableSyncSocket()); 137 foreign_socket_.reset(new base::CancelableSyncSocket());
134 return base::CancelableSyncSocket::CreatePair(socket_.get(), 138 return base::CancelableSyncSocket::CreatePair(socket_.get(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 base::TimeDelta::FromMilliseconds(1), 191 base::TimeDelta::FromMilliseconds(1),
188 base::TimeDelta::FromMilliseconds(1000), 192 base::TimeDelta::FromMilliseconds(1000),
189 50); 193 50);
190 return false; 194 return false;
191 } 195 }
192 196
193 return true; 197 return true;
194 } 198 }
195 199
196 } // namespace content 200 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_device_factory.cc » ('j') | media/audio/audio_device_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698