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

Side by Side Diff: content/renderer/media/html_audio_element_capturer_source.cc

Issue 2025643002: Fixing HtmlAudioElementCapturerSource::OnAudioBus() to accept delay frames intead of milliseconds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « content/renderer/media/html_audio_element_capturer_source.h ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/renderer/media/html_audio_element_capturer_source.h" 5 #include "content/renderer/media/html_audio_element_capturer_source.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "media/base/audio_parameters.h" 8 #include "media/base/audio_parameters.h"
9 #include "media/base/audio_renderer_sink.h" 9 #include "media/base/audio_renderer_sink.h"
10 #include "media/blink/webaudiosourceprovider_impl.h" 10 #include "media/blink/webaudiosourceprovider_impl.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 if (audio_source_) { 59 if (audio_source_) {
60 audio_source_->ClearCopyAudioCallback(); 60 audio_source_->ClearCopyAudioCallback();
61 audio_source_ = nullptr; 61 audio_source_ = nullptr;
62 } 62 }
63 is_started_ = false; 63 is_started_ = false;
64 } 64 }
65 65
66 void HtmlAudioElementCapturerSource::OnAudioBus( 66 void HtmlAudioElementCapturerSource::OnAudioBus(
67 std::unique_ptr<media::AudioBus> audio_bus, 67 std::unique_ptr<media::AudioBus> audio_bus,
68 uint32_t delay_milliseconds, 68 uint32_t frames_delayed,
69 int sample_rate) { 69 int sample_rate) {
70 const base::TimeTicks capture_time = 70 const base::TimeTicks capture_time =
71 base::TimeTicks::Now() - 71 base::TimeTicks::Now() -
72 base::TimeDelta::FromMilliseconds(delay_milliseconds); 72 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond *
73 frames_delayed / sample_rate);
73 74
74 if (sample_rate != last_sample_rate_ || 75 if (sample_rate != last_sample_rate_ ||
75 audio_bus->channels() != last_num_channels_ || 76 audio_bus->channels() != last_num_channels_ ||
76 audio_bus->frames() != last_bus_frames_) { 77 audio_bus->frames() != last_bus_frames_) {
77 MediaStreamAudioSource::SetFormat( 78 MediaStreamAudioSource::SetFormat(
78 media::AudioParameters(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 79 media::AudioParameters(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
79 media::GuessChannelLayout(audio_bus->channels()), 80 media::GuessChannelLayout(audio_bus->channels()),
80 sample_rate, 16, audio_bus->frames())); 81 sample_rate, 16, audio_bus->frames()));
81 last_sample_rate_ = sample_rate; 82 last_sample_rate_ = sample_rate;
82 last_num_channels_ = audio_bus->channels(); 83 last_num_channels_ = audio_bus->channels();
83 last_bus_frames_ = audio_bus->frames(); 84 last_bus_frames_ = audio_bus->frames();
84 } 85 }
85 86
86 MediaStreamAudioSource::DeliverDataToTracks(*audio_bus, capture_time); 87 MediaStreamAudioSource::DeliverDataToTracks(*audio_bus, capture_time);
87 } 88 }
88 89
89 } // namespace content 90 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/html_audio_element_capturer_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698