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

Unified Diff: content/browser/renderer_host/media/audio_stream_registry_impl.h

Issue 2578983003: Add AudioStreamRegistry. Move stream counting logic (Closed)
Patch Set: Remove active audio tracking from ARH to see what tests break. Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/audio_stream_registry_impl.h
diff --git a/content/browser/renderer_host/media/audio_stream_registry_impl.h b/content/browser/renderer_host/media/audio_stream_registry_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..783c54bee6a3b196d286811abeb54e1508d66942
--- /dev/null
+++ b/content/browser/renderer_host/media/audio_stream_registry_impl.h
@@ -0,0 +1,49 @@
+// Copyright 2016 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.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_
+
+#include <map>
+#include <memory>
+#include <set>
+
+#include "base/atomic_ref_count.h"
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
+#include "content/browser/renderer_host/media/audio_stream_registry.h"
+#include "content/common/content_export.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+class CONTENT_EXPORT AudioStreamRegistryImpl : public AudioStreamRegistry {
+ public:
+ explicit AudioStreamRegistryImpl(int render_process_id);
+ ~AudioStreamRegistryImpl() override;
+
+ using UniquePtr =
+ std::unique_ptr<AudioStreamRegistryImpl, BrowserThread::DeleteOnIOThread>;
+
+ static UniquePtr Create(int render_process_id);
+
+ // Indicates whether there is an output stream currently playing.
+ // May be called from any thread.
+ bool HasActiveAudio();
+
+ void RegisterStream() override;
+ void DeregisterStream() override;
+ void StreamStateChanged(bool playing) override;
+
+ private:
+ int32_t num_output_streams_ = 0;
+ int32_t max_simultaneous_output_streams_ = 0;
+ base::AtomicRefCount num_playing_output_streams_ = 0;
+ const int render_process_id_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698