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

Side by Side Diff: media/audio/win/waveout_output_win.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 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
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/win/waveout_output_win.h" 5 #include "media/audio/win/waveout_output_win.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time/time.h"
9 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
10 #include "media/audio/audio_io.h" 11 #include "media/audio/audio_io.h"
11 #include "media/audio/win/audio_manager_win.h" 12 #include "media/audio/win/audio_manager_win.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 // Some general thoughts about the waveOut API which is badly documented : 16 // Some general thoughts about the waveOut API which is badly documented :
16 // - We use CALLBACK_EVENT mode in which XP signals events such as buffer 17 // - We use CALLBACK_EVENT mode in which XP signals events such as buffer
17 // releases. 18 // releases.
18 // - We use RegisterWaitForSingleObject() so one of threads in thread pool 19 // - We use RegisterWaitForSingleObject() so one of threads in thread pool
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 318 }
318 319
319 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { 320 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) {
320 DCHECK_EQ(channels_, format_.Format.nChannels); 321 DCHECK_EQ(channels_, format_.Format.nChannels);
321 // Call the source which will fill our buffer with pleasant sounds and 322 // Call the source which will fill our buffer with pleasant sounds and
322 // return to us how many bytes were used. 323 // return to us how many bytes were used.
323 // TODO(fbarchard): Handle used 0 by queueing more. 324 // TODO(fbarchard): Handle used 0 by queueing more.
324 325
325 // TODO(sergeyu): Specify correct hardware delay for |total_delay_bytes|. 326 // TODO(sergeyu): Specify correct hardware delay for |total_delay_bytes|.
326 uint32_t total_delay_bytes = pending_bytes_; 327 uint32_t total_delay_bytes = pending_bytes_;
327 int frames_filled = 328 int frames_filled = callback_->OnMoreData(audio_bus_.get(), total_delay_bytes,
328 callback_->OnMoreData(audio_bus_.get(), total_delay_bytes, 0); 329 base::TimeDelta(), 0);
329 uint32_t used = frames_filled * audio_bus_->channels() * 330 uint32_t used = frames_filled * audio_bus_->channels() *
330 format_.Format.wBitsPerSample / 8; 331 format_.Format.wBitsPerSample / 8;
331 332
332 if (used <= buffer_size_) { 333 if (used <= buffer_size_) {
333 // Note: If this ever changes to output raw float the data must be clipped 334 // Note: If this ever changes to output raw float the data must be clipped
334 // and sanitized since it may come from an untrusted source such as NaCl. 335 // and sanitized since it may come from an untrusted source such as NaCl.
335 audio_bus_->Scale(volume_); 336 audio_bus_->Scale(volume_);
336 audio_bus_->ToInterleaved( 337 audio_bus_->ToInterleaved(
337 frames_filled, format_.Format.wBitsPerSample / 8, buffer->lpData); 338 frames_filled, format_.Format.wBitsPerSample / 8, buffer->lpData);
338 339
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 buffer, 386 buffer,
386 sizeof(WAVEHDR)); 387 sizeof(WAVEHDR));
387 if (result != MMSYSERR_NOERROR) 388 if (result != MMSYSERR_NOERROR)
388 stream->HandleError(result); 389 stream->HandleError(result);
389 stream->pending_bytes_ += buffer->dwBufferLength; 390 stream->pending_bytes_ += buffer->dwBufferLength;
390 } 391 }
391 } 392 }
392 } 393 }
393 394
394 } // namespace media 395 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698