Commit 44001bb7 authored by Yuanyao Zhong's avatar Yuanyao Zhong Committed by Commit Bot

[chromecast] Replace base::LazyInstance

Bug: b/78599329
Test: build cast_shell
Change-Id: I87afd8567613295860bc16a0e1c664a3ec4ee1a4
Reviewed-on: https://chromium-review.googlesource.com/1058596
Commit-Queue: Yuanyao Zhong <yyzhong@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558757}
parent 4cc26d55
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "base/files/file.h" #include "base/files/file.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/no_destructor.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/posix/global_descriptors.h" #include "base/posix/global_descriptors.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -43,8 +43,11 @@ ...@@ -43,8 +43,11 @@
namespace { namespace {
#if defined(OS_LINUX) #if defined(OS_LINUX)
base::LazyInstance<chromecast::CastCrashReporterClient>::Leaky chromecast::CastCrashReporterClient* GetCastCrashReporter() {
g_crash_reporter_client = LAZY_INSTANCE_INITIALIZER; static base::NoDestructor<chromecast::CastCrashReporterClient>
crash_reporter_client;
return crash_reporter_client.get();
}
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -145,7 +148,7 @@ void CastMainDelegate::PreSandboxStartup() { ...@@ -145,7 +148,7 @@ void CastMainDelegate::PreSandboxStartup() {
base::PathService::Get(FILE_CAST_ANDROID_LOG, &log_file); base::PathService::Get(FILE_CAST_ANDROID_LOG, &log_file);
chromecast::CrashHandler::Initialize(process_type, log_file); chromecast::CrashHandler::Initialize(process_type, log_file);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer()); crash_reporter::SetCrashReporterClient(GetCastCrashReporter());
if (process_type != switches::kZygoteProcess) { if (process_type != switches::kZygoteProcess) {
CastCrashReporterClient::InitCrashReporter(process_type); CastCrashReporterClient::InitCrashReporter(process_type);
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/lazy_instance.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_param_associator.h" #include "base/metrics/field_trial_param_associator.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
...@@ -25,14 +24,18 @@ const base::FieldTrial::Probability k100PercentProbability = 100; ...@@ -25,14 +24,18 @@ const base::FieldTrial::Probability k100PercentProbability = 100;
// The name of the default group to use for Cast DCS features. // The name of the default group to use for Cast DCS features.
const char kDefaultDCSFeaturesGroup[] = "default_dcs_features_group"; const char kDefaultDCSFeaturesGroup[] = "default_dcs_features_group";
base::LazyInstance<std::unordered_set<int32_t>>::Leaky g_experiment_ids = std::unordered_set<int32_t>& GetExperimentIds() {
LAZY_INSTANCE_INITIALIZER; static base::NoDestructor<std::unordered_set<int32_t>> g_experiment_ids;
return *g_experiment_ids;
}
bool g_experiment_ids_initialized = false; bool g_experiment_ids_initialized = false;
// The collection of features that have been registered by unit tests // The collection of features that have been registered by unit tests
std::vector<const base::Feature*>& GetTestFeatures() { std::vector<const base::Feature*>& GetTestFeatures() {
static base::NoDestructor<std::vector<const base::Feature*>> g_features_for_test; static base::NoDestructor<std::vector<const base::Feature*>>
return *g_features_for_test; features_for_test;
return *features_for_test;
} }
void SetExperimentIds(const base::ListValue& list) { void SetExperimentIds(const base::ListValue& list) {
...@@ -46,7 +49,7 @@ void SetExperimentIds(const base::ListValue& list) { ...@@ -46,7 +49,7 @@ void SetExperimentIds(const base::ListValue& list) {
LOG(ERROR) << "Non-integer value found in experiment id list!"; LOG(ERROR) << "Non-integer value found in experiment id list!";
} }
} }
g_experiment_ids.Get().swap(ids); GetExperimentIds().swap(ids);
g_experiment_ids_initialized = true; g_experiment_ids_initialized = true;
} }
...@@ -318,7 +321,7 @@ base::DictionaryValue GetOverriddenFeaturesForStorage( ...@@ -318,7 +321,7 @@ base::DictionaryValue GetOverriddenFeaturesForStorage(
const std::unordered_set<int32_t>& GetDCSExperimentIds() { const std::unordered_set<int32_t>& GetDCSExperimentIds() {
DCHECK(g_experiment_ids_initialized); DCHECK(g_experiment_ids_initialized);
return g_experiment_ids.Get(); return GetExperimentIds();
} }
void ResetCastFeaturesForTesting() { void ResetCastFeaturesForTesting() {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <utility> #include <utility>
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/lazy_instance.h"
#include "jni/ChromecastConfigAndroid_jni.h" #include "jni/ChromecastConfigAndroid_jni.h"
using base::android::JavaParamRef; using base::android::JavaParamRef;
...@@ -15,14 +14,10 @@ using base::android::JavaParamRef; ...@@ -15,14 +14,10 @@ using base::android::JavaParamRef;
namespace chromecast { namespace chromecast {
namespace android { namespace android {
namespace {
base::LazyInstance<ChromecastConfigAndroid>::DestructorAtExit g_instance =
LAZY_INSTANCE_INITIALIZER;
} // namespace
// static // static
ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() { ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() {
return g_instance.Pointer(); static base::NoDestructor<ChromecastConfigAndroid> instance;
return instance.get();
} }
ChromecastConfigAndroid::ChromecastConfigAndroid() { ChromecastConfigAndroid::ChromecastConfigAndroid() {
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <jni.h> #include <jni.h>
#include "base/callback.h" #include "base/callback.h"
#include "base/lazy_instance.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/no_destructor.h"
namespace chromecast { namespace chromecast {
namespace android { namespace android {
...@@ -31,7 +31,7 @@ class ChromecastConfigAndroid { ...@@ -31,7 +31,7 @@ class ChromecastConfigAndroid {
void RunSendUsageStatsChangedCallback(bool enabled); void RunSendUsageStatsChangedCallback(bool enabled);
private: private:
friend struct base::LazyInstanceTraitsBase<ChromecastConfigAndroid>; friend class base::NoDestructor<ChromecastConfigAndroid>;
ChromecastConfigAndroid(); ChromecastConfigAndroid();
~ChromecastConfigAndroid(); ~ChromecastConfigAndroid();
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/metrics/statistics_recorder.h" #include "base/metrics/statistics_recorder.h"
#include "base/no_destructor.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
...@@ -30,12 +30,14 @@ struct CurrentAppNameWithLock { ...@@ -30,12 +30,14 @@ struct CurrentAppNameWithLock {
std::string app_name; std::string app_name;
}; };
base::LazyInstance<CurrentAppNameWithLock>::DestructorAtExit g_current_app = CurrentAppNameWithLock& GetCurrentApp() {
LAZY_INSTANCE_INITIALIZER; static base::NoDestructor<CurrentAppNameWithLock> current_app;
return *current_app;
}
std::string GetAppName() { std::string GetAppName() {
base::AutoLock lock(g_current_app.Get().lock); base::AutoLock lock(GetCurrentApp().lock);
const std::string& app_name = g_current_app.Get().app_name; const std::string& app_name = GetCurrentApp().app_name;
return app_name.empty() ? kAppNameErrorNoApp : app_name; return app_name.empty() ? kAppNameErrorNoApp : app_name;
} }
...@@ -177,8 +179,8 @@ void PreregisterAllGroupedHistograms() { ...@@ -177,8 +179,8 @@ void PreregisterAllGroupedHistograms() {
} }
void TagAppStartForGroupedHistograms(const std::string& app_name) { void TagAppStartForGroupedHistograms(const std::string& app_name) {
base::AutoLock lock(g_current_app.Get().lock); base::AutoLock lock(GetCurrentApp().lock);
g_current_app.Get().app_name = app_name; GetCurrentApp().app_name = app_name;
} }
} // namespace metrics } // namespace metrics
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "chromecast/browser/extensions/cast_extension_host_delegate.h" #include "chromecast/browser/extensions/cast_extension_host_delegate.h"
#include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/no_destructor.h"
#include "chromecast/browser/extensions/cast_extension_web_contents_observer.h" #include "chromecast/browser/extensions/cast_extension_web_contents_observer.h"
#include "extensions/browser/media_capture_util.h" #include "extensions/browser/media_capture_util.h"
#include "extensions/browser/serial_extension_host_queue.h" #include "extensions/browser/serial_extension_host_queue.h"
...@@ -57,11 +57,9 @@ bool CastExtensionHostDelegate::CheckMediaAccessPermission( ...@@ -57,11 +57,9 @@ bool CastExtensionHostDelegate::CheckMediaAccessPermission(
return media_capture_util::CheckMediaAccessPermission(type, extension); return media_capture_util::CheckMediaAccessPermission(type, extension);
} }
static base::LazyInstance<SerialExtensionHostQueue>::DestructorAtExit g_queue =
LAZY_INSTANCE_INITIALIZER;
ExtensionHostQueue* CastExtensionHostDelegate::GetExtensionHostQueue() const { ExtensionHostQueue* CastExtensionHostDelegate::GetExtensionHostQueue() const {
return g_queue.Pointer(); static base::NoDestructor<SerialExtensionHostQueue> queue;
return queue.get();
} }
} // namespace extensions } // namespace extensions
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/no_destructor.h"
#include "chromecast/common/extensions_api/cast_aliases.h" #include "chromecast/common/extensions_api/cast_aliases.h"
#include "chromecast/common/extensions_api/cast_api_features.h" #include "chromecast/common/extensions_api/cast_api_features.h"
#include "chromecast/common/extensions_api/cast_api_permissions.h" #include "chromecast/common/extensions_api/cast_api_permissions.h"
...@@ -79,9 +79,6 @@ class ShellPermissionMessageProvider : public PermissionMessageProvider { ...@@ -79,9 +79,6 @@ class ShellPermissionMessageProvider : public PermissionMessageProvider {
DISALLOW_COPY_AND_ASSIGN(ShellPermissionMessageProvider); DISALLOW_COPY_AND_ASSIGN(ShellPermissionMessageProvider);
}; };
base::LazyInstance<ShellPermissionMessageProvider>::DestructorAtExit
g_permission_message_provider = LAZY_INSTANCE_INITIALIZER;
} // namespace } // namespace
CastExtensionsClient::CastExtensionsClient() CastExtensionsClient::CastExtensionsClient()
...@@ -109,7 +106,9 @@ void CastExtensionsClient::InitializeWebStoreUrls( ...@@ -109,7 +106,9 @@ void CastExtensionsClient::InitializeWebStoreUrls(
const PermissionMessageProvider& const PermissionMessageProvider&
CastExtensionsClient::GetPermissionMessageProvider() const { CastExtensionsClient::GetPermissionMessageProvider() const {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return g_permission_message_provider.Get(); static base::NoDestructor<ShellPermissionMessageProvider>
g_permission_message_provider;
return *g_permission_message_provider;
} }
const std::string CastExtensionsClient::GetProductName() { const std::string CastExtensionsClient::GetProductName() {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "chromecast/crash/app_state_tracker.h" #include "chromecast/crash/app_state_tracker.h"
#include "base/lazy_instance.h" #include "base/no_destructor.h"
#include "chromecast/crash/cast_crash_keys.h" #include "chromecast/crash/cast_crash_keys.h"
#include "components/crash/core/common/crash_key.h" #include "components/crash/core/common/crash_key.h"
...@@ -16,11 +16,9 @@ struct CurrentAppState { ...@@ -16,11 +16,9 @@ struct CurrentAppState {
std::string last_launched_app; std::string last_launched_app;
}; };
base::LazyInstance<CurrentAppState>::DestructorAtExit g_app_state =
LAZY_INSTANCE_INITIALIZER;
CurrentAppState* GetAppState() { CurrentAppState* GetAppState() {
return g_app_state.Pointer(); static base::NoDestructor<CurrentAppState> app_state;
return app_state.get();
} }
} // namespace } // namespace
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <algorithm> #include <algorithm>
#include "base/lazy_instance.h" #include "base/no_destructor.h"
#include "chromecast/media/cma/backend/android/audio_sink_android.h" #include "chromecast/media/cma/backend/android/audio_sink_android.h"
namespace chromecast { namespace chromecast {
...@@ -23,14 +23,12 @@ class AudioSinkManagerInstance : public AudioSinkManager { ...@@ -23,14 +23,12 @@ class AudioSinkManagerInstance : public AudioSinkManager {
DISALLOW_COPY_AND_ASSIGN(AudioSinkManagerInstance); DISALLOW_COPY_AND_ASSIGN(AudioSinkManagerInstance);
}; };
base::LazyInstance<AudioSinkManagerInstance>::DestructorAtExit
g_sink_manager_instance = LAZY_INSTANCE_INITIALIZER;
} // namespace } // namespace
// static // static
AudioSinkManager* AudioSinkManager::Get() { AudioSinkManager* AudioSinkManager::Get() {
return g_sink_manager_instance.Pointer(); base::NoDestructor<AudioSinkManagerInstance> sink_manager_instance;
return sink_manager_instance.get();
} }
// static // static
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/no_destructor.h"
#include "chromecast/base/init_command_line_shlib.h" #include "chromecast/base/init_command_line_shlib.h"
#include "chromecast/base/serializers.h" #include "chromecast/base/serializers.h"
#include "chromecast/chromecast_buildflags.h" #include "chromecast/chromecast_buildflags.h"
...@@ -68,8 +68,10 @@ float MapIntoDifferentVolumeTableDomain(AudioContentType from_type, ...@@ -68,8 +68,10 @@ float MapIntoDifferentVolumeTableDomain(AudioContentType from_type,
} // namespace } // namespace
base::LazyInstance<VolumeControlAndroid>::Leaky g_volume_control = VolumeControlAndroid& GetVolumeControl() {
LAZY_INSTANCE_INITIALIZER; static base::NoDestructor<VolumeControlAndroid> volume_control;
return *volume_control;
}
VolumeControlAndroid::VolumeControlAndroid() VolumeControlAndroid::VolumeControlAndroid()
: thread_("VolumeControl"), : thread_("VolumeControl"),
...@@ -319,37 +321,37 @@ void VolumeControl::Finalize() { ...@@ -319,37 +321,37 @@ void VolumeControl::Finalize() {
// static // static
void VolumeControl::AddVolumeObserver(VolumeObserver* observer) { void VolumeControl::AddVolumeObserver(VolumeObserver* observer) {
g_volume_control.Get().AddVolumeObserver(observer); GetVolumeControl().AddVolumeObserver(observer);
} }
// static // static
void VolumeControl::RemoveVolumeObserver(VolumeObserver* observer) { void VolumeControl::RemoveVolumeObserver(VolumeObserver* observer) {
g_volume_control.Get().RemoveVolumeObserver(observer); GetVolumeControl().RemoveVolumeObserver(observer);
} }
// static // static
float VolumeControl::GetVolume(AudioContentType type) { float VolumeControl::GetVolume(AudioContentType type) {
return g_volume_control.Get().GetVolume(type); return GetVolumeControl().GetVolume(type);
} }
// static // static
void VolumeControl::SetVolume(AudioContentType type, float level) { void VolumeControl::SetVolume(AudioContentType type, float level) {
g_volume_control.Get().SetVolume(type, level); GetVolumeControl().SetVolume(type, level);
} }
// static // static
bool VolumeControl::IsMuted(AudioContentType type) { bool VolumeControl::IsMuted(AudioContentType type) {
return g_volume_control.Get().IsMuted(type); return GetVolumeControl().IsMuted(type);
} }
// static // static
void VolumeControl::SetMuted(AudioContentType type, bool muted) { void VolumeControl::SetMuted(AudioContentType type, bool muted) {
g_volume_control.Get().SetMuted(type, muted); GetVolumeControl().SetMuted(type, muted);
} }
// static // static
void VolumeControl::SetOutputLimit(AudioContentType type, float limit) { void VolumeControl::SetOutputLimit(AudioContentType type, float limit) {
g_volume_control.Get().SetOutputLimit(type, limit); GetVolumeControl().SetOutputLimit(type, limit);
} }
// static // static
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/lazy_instance.h" #include "base/no_destructor.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -175,9 +175,6 @@ void UseHighPriority() { ...@@ -175,9 +175,6 @@ void UseHighPriority() {
#endif #endif
} }
base::LazyInstance<StreamMixer>::DestructorAtExit g_mixer_instance =
LAZY_INSTANCE_INITIALIZER;
} // namespace } // namespace
float StreamMixer::VolumeInfo::GetEffectiveVolume() { float StreamMixer::VolumeInfo::GetEffectiveVolume() {
...@@ -186,7 +183,8 @@ float StreamMixer::VolumeInfo::GetEffectiveVolume() { ...@@ -186,7 +183,8 @@ float StreamMixer::VolumeInfo::GetEffectiveVolume() {
// static // static
StreamMixer* StreamMixer::Get() { StreamMixer* StreamMixer::Get() {
return g_mixer_instance.Pointer(); static base::NoDestructor<StreamMixer> mixer_instance;
return mixer_instance.get();
} }
StreamMixer::StreamMixer() StreamMixer::StreamMixer()
......
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/no_destructor.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
...@@ -69,7 +69,10 @@ std::string ContentTypeToDbFSKey(AudioContentType type) { ...@@ -69,7 +69,10 @@ std::string ContentTypeToDbFSKey(AudioContentType type) {
} }
} }
base::LazyInstance<VolumeMap>::Leaky g_volume_map = LAZY_INSTANCE_INITIALIZER; VolumeMap& GetVolumeMap() {
static base::NoDestructor<VolumeMap> volume_map;
return *volume_map;
}
class VolumeControlInternal : public SystemVolumeControl::Delegate { class VolumeControlInternal : public SystemVolumeControl::Delegate {
public: public:
...@@ -79,7 +82,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -79,7 +82,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED) { base::WaitableEvent::InitialState::NOT_SIGNALED) {
// Load volume map to check that the config file is correct. // Load volume map to check that the config file is correct.
g_volume_map.Get(); GetVolumeMap();
stored_values_.SetDouble(kKeyMediaDbFS, kDefaultMediaDbFS); stored_values_.SetDouble(kKeyMediaDbFS, kDefaultMediaDbFS);
stored_values_.SetDouble(kKeyAlarmDbFS, kDefaultAlarmDbFS); stored_values_.SetDouble(kKeyAlarmDbFS, kDefaultAlarmDbFS);
...@@ -339,15 +342,19 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -339,15 +342,19 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
DISALLOW_COPY_AND_ASSIGN(VolumeControlInternal); DISALLOW_COPY_AND_ASSIGN(VolumeControlInternal);
}; };
base::LazyInstance<VolumeControlInternal>::Leaky g_volume_control = // base::LazyInstance<VolumeControlInternal>::Leaky g_volume_control =
LAZY_INSTANCE_INITIALIZER; // LAZY_INSTANCE_INITIALIZER;
VolumeControlInternal& GetVolumeControl() {
static base::NoDestructor<VolumeControlInternal> g_volume_control;
return *g_volume_control;
}
} // namespace } // namespace
// static // static
void VolumeControl::Initialize(const std::vector<std::string>& argv) { void VolumeControl::Initialize(const std::vector<std::string>& argv) {
chromecast::InitCommandLineShlib(argv); chromecast::InitCommandLineShlib(argv);
g_volume_control.Get(); GetVolumeControl();
} }
// static // static
...@@ -357,52 +364,52 @@ void VolumeControl::Finalize() { ...@@ -357,52 +364,52 @@ void VolumeControl::Finalize() {
// static // static
void VolumeControl::AddVolumeObserver(VolumeObserver* observer) { void VolumeControl::AddVolumeObserver(VolumeObserver* observer) {
g_volume_control.Get().AddVolumeObserver(observer); GetVolumeControl().AddVolumeObserver(observer);
} }
// static // static
void VolumeControl::RemoveVolumeObserver(VolumeObserver* observer) { void VolumeControl::RemoveVolumeObserver(VolumeObserver* observer) {
g_volume_control.Get().RemoveVolumeObserver(observer); GetVolumeControl().RemoveVolumeObserver(observer);
} }
// static // static
float VolumeControl::GetVolume(AudioContentType type) { float VolumeControl::GetVolume(AudioContentType type) {
return g_volume_control.Get().GetVolume(type); return GetVolumeControl().GetVolume(type);
} }
// static // static
void VolumeControl::SetVolume(AudioContentType type, float level) { void VolumeControl::SetVolume(AudioContentType type, float level) {
g_volume_control.Get().SetVolume(type, level); GetVolumeControl().SetVolume(type, level);
} }
// static // static
bool VolumeControl::IsMuted(AudioContentType type) { bool VolumeControl::IsMuted(AudioContentType type) {
return g_volume_control.Get().IsMuted(type); return GetVolumeControl().IsMuted(type);
} }
// static // static
void VolumeControl::SetMuted(AudioContentType type, bool muted) { void VolumeControl::SetMuted(AudioContentType type, bool muted) {
g_volume_control.Get().SetMuted(type, muted); GetVolumeControl().SetMuted(type, muted);
} }
// static // static
void VolumeControl::SetOutputLimit(AudioContentType type, float limit) { void VolumeControl::SetOutputLimit(AudioContentType type, float limit) {
g_volume_control.Get().SetOutputLimit(type, limit); GetVolumeControl().SetOutputLimit(type, limit);
} }
// static // static
float VolumeControl::VolumeToDbFS(float volume) { float VolumeControl::VolumeToDbFS(float volume) {
return g_volume_map.Get().VolumeToDbFS(volume); return GetVolumeMap().VolumeToDbFS(volume);
} }
// static // static
float VolumeControl::DbFSToVolume(float db) { float VolumeControl::DbFSToVolume(float db) {
return g_volume_map.Get().DbFSToVolume(db); return GetVolumeMap().DbFSToVolume(db);
} }
// static // static
void VolumeControl::SetPowerSaveMode(bool power_save_on) { void VolumeControl::SetPowerSaveMode(bool power_save_on) {
g_volume_control.Get().SetPowerSaveMode(power_save_on); GetVolumeControl().SetPowerSaveMode(power_save_on);
} }
} // namespace media } // namespace media
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment