concurrent_stream_metric_reporter.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2021 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. #include "services/audio/concurrent_stream_metric_reporter.h"
  5. #include "base/metrics/histogram_functions.h"
  6. namespace audio {
  7. void ConcurrentStreamMetricReporter::OnInputStreamActive() {
  8. ++active_input_stream_count_;
  9. if (active_input_stream_count_ == 1) {
  10. // Reset metric when recording starts.
  11. max_concurrent_output_streams_metric_ = active_output_stream_count_;
  12. }
  13. }
  14. void ConcurrentStreamMetricReporter::OnInputStreamInactive() {
  15. DCHECK_GE(active_input_stream_count_, 1);
  16. --active_input_stream_count_;
  17. if (active_input_stream_count_ == 0) {
  18. // Report metric when recording ends.
  19. base::UmaHistogramCustomCounts("Media.Audio.MaxOutputStreamsPerInputStream",
  20. max_concurrent_output_streams_metric_, 1, 50,
  21. 50);
  22. }
  23. }
  24. void ConcurrentStreamMetricReporter::OnOutputStreamActive() {
  25. ++active_output_stream_count_;
  26. // Report output stream count increases during recording.
  27. if (active_input_stream_count_ >= 1 &&
  28. active_output_stream_count_ > max_concurrent_output_streams_metric_) {
  29. max_concurrent_output_streams_metric_ = active_output_stream_count_;
  30. }
  31. }
  32. void ConcurrentStreamMetricReporter::OnOutputStreamInactive() {
  33. DCHECK_GE(active_output_stream_count_, 1);
  34. --active_output_stream_count_;
  35. }
  36. } // namespace audio