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

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

Issue 687563004: Change parameter type on AudioDeviceThread::Callback::Process() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « media/audio/audio_input_device.cc ('k') | no next file » | 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_output_device.h" 5 #include "media/audio/audio_output_device.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 AudioThreadCallback(const AudioParameters& audio_parameters, 22 AudioThreadCallback(const AudioParameters& audio_parameters,
23 base::SharedMemoryHandle memory, 23 base::SharedMemoryHandle memory,
24 int memory_length, 24 int memory_length,
25 AudioRendererSink::RenderCallback* render_callback); 25 AudioRendererSink::RenderCallback* render_callback);
26 ~AudioThreadCallback() override; 26 ~AudioThreadCallback() override;
27 27
28 void MapSharedMemory() override; 28 void MapSharedMemory() override;
29 29
30 // Called whenever we receive notifications about pending data. 30 // Called whenever we receive notifications about pending data.
31 void Process(int pending_data) override; 31 void Process(uint32 pending_data) override;
32 32
33 private: 33 private:
34 AudioRendererSink::RenderCallback* render_callback_; 34 AudioRendererSink::RenderCallback* render_callback_;
35 scoped_ptr<AudioBus> output_bus_; 35 scoped_ptr<AudioBus> output_bus_;
36 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 36 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
37 }; 37 };
38 38
39 AudioOutputDevice::AudioOutputDevice( 39 AudioOutputDevice::AudioOutputDevice(
40 scoped_ptr<AudioOutputIPC> ipc, 40 scoped_ptr<AudioOutputIPC> ipc,
41 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 41 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { 278 void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
279 CHECK_EQ(total_segments_, 1); 279 CHECK_EQ(total_segments_, 1);
280 CHECK(shared_memory_.Map(memory_length_)); 280 CHECK(shared_memory_.Map(memory_length_));
281 DCHECK_EQ(memory_length_, AudioBus::CalculateMemorySize(audio_parameters_)); 281 DCHECK_EQ(memory_length_, AudioBus::CalculateMemorySize(audio_parameters_));
282 282
283 output_bus_ = 283 output_bus_ =
284 AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory()); 284 AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory());
285 } 285 }
286 286
287 // Called whenever we receive notifications about pending data. 287 // Called whenever we receive notifications about pending data.
288 void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) { 288 void AudioOutputDevice::AudioThreadCallback::Process(uint32 pending_data) {
289 // Negative |pending_data| indicates the browser side stream has stopped.
290 if (pending_data < 0)
291 return;
292
293 // Convert the number of pending bytes in the render buffer into milliseconds. 289 // Convert the number of pending bytes in the render buffer into milliseconds.
294 int audio_delay_milliseconds = pending_data / bytes_per_ms_; 290 int audio_delay_milliseconds = pending_data / bytes_per_ms_;
295 291
296 TRACE_EVENT0("audio", "AudioOutputDevice::FireRenderCallback"); 292 TRACE_EVENT0("audio", "AudioOutputDevice::FireRenderCallback");
297 293
298 // Update the audio-delay measurement then ask client to render audio. Since 294 // Update the audio-delay measurement then ask client to render audio. Since
299 // |output_bus_| is wrapping the shared memory the Render() call is writing 295 // |output_bus_| is wrapping the shared memory the Render() call is writing
300 // directly into the shared memory. 296 // directly into the shared memory.
301 render_callback_->Render(output_bus_.get(), audio_delay_milliseconds); 297 render_callback_->Render(output_bus_.get(), audio_delay_milliseconds);
302 } 298 }
303 299
304 } // namespace media. 300 } // namespace media.
OLDNEW
« no previous file with comments | « media/audio/audio_input_device.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698