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

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

Issue 2443573003: Factor out AudioOutputDelegate from AudioRendererHost. (Closed)
Patch Set: Final comments addressed. Created 4 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_streams_tracker.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 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 "media/audio/audio_streams_tracker.h" 5 #include "media/audio/audio_streams_tracker.h"
6 6
7 #include <limits>
8
7 namespace media { 9 namespace media {
8 10
9 AudioStreamsTracker::AudioStreamsTracker() 11 AudioStreamsTracker::AudioStreamsTracker()
10 : current_stream_count_(0), max_stream_count_(0) { 12 : current_stream_count_(0), max_stream_count_(0) {
11 thread_checker_.DetachFromThread(); 13 thread_checker_.DetachFromThread();
12 } 14 }
13 15
14 AudioStreamsTracker::~AudioStreamsTracker() { 16 AudioStreamsTracker::~AudioStreamsTracker() {
15 DCHECK_EQ(current_stream_count_, 0u); 17 DCHECK_EQ(current_stream_count_, 0u);
16 } 18 }
17 19
18 void AudioStreamsTracker::IncreaseStreamCount() { 20 void AudioStreamsTracker::IncreaseStreamCount() {
19 DCHECK(thread_checker_.CalledOnValidThread()); 21 DCHECK(thread_checker_.CalledOnValidThread());
20 DCHECK_NE(current_stream_count_, SIZE_MAX); 22 DCHECK_NE(current_stream_count_, std::numeric_limits<size_t>::max());
21 ++current_stream_count_; 23 ++current_stream_count_;
22 if (current_stream_count_ > max_stream_count_) 24 if (current_stream_count_ > max_stream_count_)
23 max_stream_count_ = current_stream_count_; 25 max_stream_count_ = current_stream_count_;
24 } 26 }
25 27
26 void AudioStreamsTracker::DecreaseStreamCount() { 28 void AudioStreamsTracker::DecreaseStreamCount(size_t count) {
27 DCHECK(thread_checker_.CalledOnValidThread()); 29 DCHECK(thread_checker_.CalledOnValidThread());
28 DCHECK_NE(current_stream_count_, 0u); 30 DCHECK_GE(current_stream_count_, count);
29 --current_stream_count_; 31 current_stream_count_ -= count;
30 } 32 }
31 33
32 void AudioStreamsTracker::ResetMaxStreamCount() { 34 void AudioStreamsTracker::ResetMaxStreamCount() {
33 DCHECK(thread_checker_.CalledOnValidThread()); 35 DCHECK(thread_checker_.CalledOnValidThread());
34 max_stream_count_ = current_stream_count_; 36 max_stream_count_ = current_stream_count_;
35 } 37 }
36 38
37 size_t AudioStreamsTracker::max_stream_count() const { 39 size_t AudioStreamsTracker::max_stream_count() const {
38 DCHECK(thread_checker_.CalledOnValidThread()); 40 DCHECK(thread_checker_.CalledOnValidThread());
39 return max_stream_count_; 41 return max_stream_count_;
40 } 42 }
41 43
42 } // namespace media 44 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_streams_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698