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

Side by Side Diff: media/audio/mac/audio_input_mac.cc

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop Created 3 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 "media/audio/mac/audio_input_mac.h" 5 #include "media/audio/mac/audio_input_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_logging.h" 10 #include "base/mac/mac_logging.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (elapsed < kMinDelay) { 225 if (elapsed < kMinDelay) {
226 TRACE_EVENT0("audio", 226 TRACE_EVENT0("audio",
227 "PCMQueueInAudioInputStream::HandleInputBuffer sleep"); 227 "PCMQueueInAudioInputStream::HandleInputBuffer sleep");
228 base::PlatformThread::Sleep(kMinDelay - elapsed); 228 base::PlatformThread::Sleep(kMinDelay - elapsed);
229 } 229 }
230 230
231 uint8_t* audio_data = reinterpret_cast<uint8_t*>(audio_buffer->mAudioData); 231 uint8_t* audio_data = reinterpret_cast<uint8_t*>(audio_buffer->mAudioData);
232 audio_bus_->FromInterleaved( 232 audio_bus_->FromInterleaved(
233 audio_data, audio_bus_->frames(), format_.mBitsPerChannel / 8); 233 audio_data, audio_bus_->frames(), format_.mBitsPerChannel / 8);
234 callback_->OnData( 234 callback_->OnData(
235 this, audio_bus_.get(), audio_buffer->mAudioDataByteSize, 0.0); 235 this, audio_bus_.get(),
236 base::TimeDelta::FromSecondsD(
237 audio_buffer->mAudioDataByteSize /
238 static_cast<double>(format_.mBytesPerFrame * format_.mSampleRate)),
239 base::TimeTicks::Now(), 0.0);
236 240
237 last_fill_ = base::TimeTicks::Now(); 241 last_fill_ = base::TimeTicks::Now();
238 } 242 }
239 // Recycle the buffer. 243 // Recycle the buffer.
240 OSStatus err = QueueNextBuffer(audio_buffer); 244 OSStatus err = QueueNextBuffer(audio_buffer);
241 if (err != noErr) { 245 if (err != noErr) {
242 if (err == kAudioQueueErr_EnqueueDuringReset) { 246 if (err == kAudioQueueErr_EnqueueDuringReset) {
243 // This is the error you get if you try to enqueue a buffer and the 247 // This is the error you get if you try to enqueue a buffer and the
244 // queue has been closed. Not really a problem if indeed the queue 248 // queue has been closed. Not really a problem if indeed the queue
245 // has been closed. 249 // has been closed.
246 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an 250 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an
247 // extra guard for this situation, but it seems to introduce more 251 // extra guard for this situation, but it seems to introduce more
248 // complications than it solves (memory barrier issues accessing it from 252 // complications than it solves (memory barrier issues accessing it from
249 // multiple threads, looses the means to indicate OnClosed to client). 253 // multiple threads, looses the means to indicate OnClosed to client).
250 // Should determine if we need to do something equivalent here. 254 // Should determine if we need to do something equivalent here.
251 return; 255 return;
252 } 256 }
253 HandleError(err); 257 HandleError(err);
254 } 258 }
255 } 259 }
256 260
257 } // namespace media 261 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698