OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/audio/audio_streams_tracker.h" | |
6 | |
7 #include <limits> | |
8 | |
9 namespace media { | |
10 | |
11 AudioStreamsTracker::AudioStreamsTracker() | |
12 : current_stream_count_(0), max_stream_count_(0) { | |
13 thread_checker_.DetachFromThread(); | |
14 } | |
15 | |
16 AudioStreamsTracker::~AudioStreamsTracker() { | |
17 DCHECK_EQ(current_stream_count_, 0u); | |
18 } | |
19 | |
20 void AudioStreamsTracker::IncreaseStreamCount() { | |
21 DCHECK(thread_checker_.CalledOnValidThread()); | |
22 DCHECK_NE(current_stream_count_, std::numeric_limits<size_t>::max()); | |
23 ++current_stream_count_; | |
24 if (current_stream_count_ > max_stream_count_) | |
25 max_stream_count_ = current_stream_count_; | |
26 } | |
27 | |
28 void AudioStreamsTracker::DecreaseStreamCount(size_t count) { | |
29 DCHECK(thread_checker_.CalledOnValidThread()); | |
30 DCHECK_GE(current_stream_count_, count); | |
31 current_stream_count_ -= count; | |
32 } | |
33 | |
34 void AudioStreamsTracker::ResetMaxStreamCount() { | |
35 DCHECK(thread_checker_.CalledOnValidThread()); | |
36 max_stream_count_ = current_stream_count_; | |
37 } | |
38 | |
39 size_t AudioStreamsTracker::max_stream_count() const { | |
40 DCHECK(thread_checker_.CalledOnValidThread()); | |
41 return max_stream_count_; | |
42 } | |
43 | |
44 } // namespace media | |
OLD | NEW |