summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_streams_tracker.cc
blob: 97b01ca2751743e1ce51d24b28957d551807091b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/audio/audio_streams_tracker.h"

namespace media {

AudioStreamsTracker::AudioStreamsTracker()
    : current_stream_count_(0), max_stream_count_(0) {
  thread_checker_.DetachFromThread();
}

AudioStreamsTracker::~AudioStreamsTracker() {
  DCHECK_EQ(current_stream_count_, 0u);
}

void AudioStreamsTracker::IncreaseStreamCount() {
  DCHECK(thread_checker_.CalledOnValidThread());
  DCHECK_NE(current_stream_count_, SIZE_MAX);
  ++current_stream_count_;
  if (current_stream_count_ > max_stream_count_)
    max_stream_count_ = current_stream_count_;
}

void AudioStreamsTracker::DecreaseStreamCount() {
  DCHECK(thread_checker_.CalledOnValidThread());
  DCHECK_NE(current_stream_count_, 0u);
  --current_stream_count_;
}

void AudioStreamsTracker::ResetMaxStreamCount() {
  DCHECK(thread_checker_.CalledOnValidThread());
  max_stream_count_ = current_stream_count_;
}

size_t AudioStreamsTracker::max_stream_count() const {
  DCHECK(thread_checker_.CalledOnValidThread());
  return max_stream_count_;
}

}  // namespace media