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

Side by Side Diff: media/audio/audio_input_device.cc

Issue 1538563002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fix. git cl format. Rebase. Created 5 years 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
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/audio/audio_io.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/audio_input_device.h" 5 #include "media/audio/audio_input_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 18 matching lines...) Expand all
29 AudioThreadCallback(const AudioParameters& audio_parameters, 29 AudioThreadCallback(const AudioParameters& audio_parameters,
30 base::SharedMemoryHandle memory, 30 base::SharedMemoryHandle memory,
31 int memory_length, 31 int memory_length,
32 int total_segments, 32 int total_segments,
33 CaptureCallback* capture_callback); 33 CaptureCallback* capture_callback);
34 ~AudioThreadCallback() override; 34 ~AudioThreadCallback() override;
35 35
36 void MapSharedMemory() override; 36 void MapSharedMemory() override;
37 37
38 // Called whenever we receive notifications about pending data. 38 // Called whenever we receive notifications about pending data.
39 void Process(uint32 pending_data) override; 39 void Process(uint32_t pending_data) override;
40 40
41 private: 41 private:
42 int current_segment_id_; 42 int current_segment_id_;
43 uint32 last_buffer_id_; 43 uint32 last_buffer_id_;
44 ScopedVector<media::AudioBus> audio_buses_; 44 ScopedVector<media::AudioBus> audio_buses_;
45 CaptureCallback* capture_callback_; 45 CaptureCallback* capture_callback_;
46 46
47 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 47 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
48 }; 48 };
49 49
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 for (int i = 0; i < total_segments_; ++i) { 290 for (int i = 0; i < total_segments_; ++i) {
291 media::AudioInputBuffer* buffer = 291 media::AudioInputBuffer* buffer =
292 reinterpret_cast<media::AudioInputBuffer*>(ptr); 292 reinterpret_cast<media::AudioInputBuffer*>(ptr);
293 scoped_ptr<media::AudioBus> audio_bus = 293 scoped_ptr<media::AudioBus> audio_bus =
294 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); 294 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio);
295 audio_buses_.push_back(audio_bus.Pass()); 295 audio_buses_.push_back(audio_bus.Pass());
296 ptr += segment_length_; 296 ptr += segment_length_;
297 } 297 }
298 } 298 }
299 299
300 void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) { 300 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
301 // The shared memory represents parameters, size of the data buffer and the 301 // The shared memory represents parameters, size of the data buffer and the
302 // actual data buffer containing audio data. Map the memory into this 302 // actual data buffer containing audio data. Map the memory into this
303 // structure and parse out parameters and the data area. 303 // structure and parse out parameters and the data area.
304 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); 304 uint8* ptr = static_cast<uint8*>(shared_memory_.memory());
305 ptr += current_segment_id_ * segment_length_; 305 ptr += current_segment_id_ * segment_length_;
306 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 306 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
307 307
308 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz, 308 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz,
309 // the buffer may be bigger (on mac at least)). 309 // the buffer may be bigger (on mac at least)).
310 DCHECK_GE(buffer->params.size, 310 DCHECK_GE(buffer->params.size,
(...skipping 25 matching lines...) Expand all
336 audio_bus, 336 audio_bus,
337 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 337 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
338 buffer->params.volume, 338 buffer->params.volume,
339 buffer->params.key_pressed); 339 buffer->params.key_pressed);
340 340
341 if (++current_segment_id_ >= total_segments_) 341 if (++current_segment_id_ >= total_segments_)
342 current_segment_id_ = 0; 342 current_segment_id_ = 0;
343 } 343 }
344 344
345 } // namespace media 345 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/audio/audio_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698