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

Side by Side Diff: components/audio_modem/audio_player_unittest.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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/audio_modem/audio_player.h" 5 #include "components/audio_modem/audio_player.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void GetVolume(double* volume) override {} 44 void GetVolume(double* volume) override {}
45 void Close() override {} 45 void Close() override {}
46 46
47 private: 47 private:
48 void GatherPlayedSamples() { 48 void GatherPlayedSamples() {
49 int frames = 0, total_frames = 0; 49 int frames = 0, total_frames = 0;
50 do { 50 do {
51 // Call back into the player to get samples that it wants us to play. 51 // Call back into the player to get samples that it wants us to play.
52 scoped_ptr<media::AudioBus> dest = 52 scoped_ptr<media::AudioBus> dest =
53 media::AudioBus::Create(1, default_frame_count_); 53 media::AudioBus::Create(1, default_frame_count_);
54 frames = callback_->OnMoreData(dest.get(), 0); 54 frames = callback_->OnMoreData(dest.get(), 0, 0);
55 total_frames += frames; 55 total_frames += frames;
56 // Send the samples given to us by the player to the gather callback. 56 // Send the samples given to us by the player to the gather callback.
57 caller_loop_->task_runner()->PostTask( 57 caller_loop_->task_runner()->PostTask(
58 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); 58 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames));
59 } while (frames && total_frames < max_frame_count_); 59 } while (frames && total_frames < max_frame_count_);
60 } 60 }
61 61
62 int default_frame_count_; 62 int default_frame_count_;
63 int max_frame_count_; 63 int max_frame_count_;
64 GatherSamplesCallback gather_callback_; 64 GatherSamplesCallback gather_callback_;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 PlayAndVerifySamples( 205 PlayAndVerifySamples(
206 CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123)); 206 CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123));
207 207
208 PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2)); 208 PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2));
209 209
210 DeletePlayer(); 210 DeletePlayer();
211 } 211 }
212 212
213 } // namespace audio_modem 213 } // namespace audio_modem
OLDNEW
« no previous file with comments | « components/audio_modem/audio_player_impl.cc ('k') | content/browser/media/capture/web_contents_audio_muter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698