diff --git a/src/media/audio/audio_core/audio_capturer_impl.cc b/src/media/audio/audio_core/audio_capturer_impl.cc index 008f2b9e034e0d1b0d09d7935de8c9b81b274199..9a1681873f01e6471030f2d941ca97ded6da24e7 100644 --- a/src/media/audio/audio_core/audio_capturer_impl.cc +++ b/src/media/audio/audio_core/audio_capturer_impl.cc @@ -1335,8 +1335,8 @@ zx_status_t AudioCapturerImpl::ChooseMixer(const fbl::RefPtr<AudioLink>& link) { FXL_DCHECK(source); if (!source->is_input() && !source->is_output()) { - FXL_LOG(WARNING) << "Failed to find mixer for source of type " - << static_cast<uint32_t>(source->type()); + FXL_LOG(ERROR) << "Failed to find mixer for source of type " + << static_cast<uint32_t>(source->type()); return ZX_ERR_INVALID_ARGS; } diff --git a/src/media/audio/audio_core/audio_core_impl.cc b/src/media/audio/audio_core/audio_core_impl.cc index 61dec0eff01aa29f030f10c71343855c24182062..0278f592203b3b7602e02f98aa293317c644f4df 100644 --- a/src/media/audio/audio_core/audio_core_impl.cc +++ b/src/media/audio/audio_core/audio_core_impl.cc @@ -8,6 +8,7 @@ #include <lib/async/cpp/task.h> #include <lib/async/default.h> +#include "src/lib/fxl/log_settings.h" #include "src/media/audio/audio_core/audio_capturer_impl.h" #include "src/media/audio/audio_core/audio_device_manager.h" #include "src/media/audio/audio_core/audio_renderer_impl.h" @@ -19,6 +20,16 @@ constexpr float AudioCoreImpl::kMaxSystemAudioGainDb; AudioCoreImpl::AudioCoreImpl( std::unique_ptr<sys::ComponentContext> startup_context) : device_manager_(this), ctx_(std::move(startup_context)) { + fxl::LogSettings settings; + +#ifdef NDEBUG + settings.min_log_level = fxl::LOG_WARNING; +#else + settings.min_log_level = fxl::LOG_INFO; +#endif + + fxl::SetLogSettings(settings); + // Stash a pointer to our async object. dispatcher_ = async_get_default_dispatcher(); FXL_DCHECK(dispatcher_); diff --git a/src/media/audio/audio_core/audio_device_manager.cc b/src/media/audio/audio_core/audio_device_manager.cc index cc57623352869bd8803283e2bff60a3c97736a40..d0c0125e65a73d6ee5f418b7aa9bedf607d29b42 100644 --- a/src/media/audio/audio_core/audio_device_manager.cc +++ b/src/media/audio/audio_core/audio_device_manager.cc @@ -34,14 +34,14 @@ zx_status_t AudioDeviceManager::Init() { // Instantiate and initialize the default throttle output. auto throttle_output = ThrottleOutput::Create(this); if (throttle_output == nullptr) { - FXL_LOG(WARNING) + FXL_LOG(ERROR) << "AudioDeviceManager failed to create default throttle output!"; return ZX_ERR_NO_MEMORY; } zx_status_t res = throttle_output->Startup(); if (res != ZX_OK) { - FXL_LOG(WARNING) + FXL_LOG(ERROR) << "AudioDeviceManager failed to initialize the throttle output (res " << res << ")"; throttle_output->Shutdown(); @@ -51,8 +51,8 @@ zx_status_t AudioDeviceManager::Init() { // Start monitoring for plug/unplug events of pluggable audio output devices. res = plug_detector_.Start(this); if (res != ZX_OK) { - FXL_LOG(WARNING) << "AudioDeviceManager failed to start plug detector (res " - << res << ")"; + FXL_LOG(ERROR) << "AudioDeviceManager failed to start plug detector (res " + << res << ")"; return res; } @@ -347,8 +347,8 @@ void AudioDeviceManager::SetDeviceGain( // allowed gain range. NAN is undefined (signless); handle it here and exit. if ((set_flags & ::fuchsia::media::SetAudioGainFlag_GainValid) && isnan(gain_info.gain_db)) { - FXL_LOG(ERROR) << "Invalid device gain " << gain_info.gain_db - << " dB -- making no change"; + FXL_DLOG(WARNING) << "Invalid device gain " << gain_info.gain_db + << " dB -- making no change"; return; } diff --git a/src/media/audio/audio_core/audio_device_settings.cc b/src/media/audio/audio_core/audio_device_settings.cc index 7e809e91933fe165bc66f85b1fcdb17c6d1af97e..d9bb5d8224c174056ab45d30672feb2708c35042 100644 --- a/src/media/audio/audio_core/audio_device_settings.cc +++ b/src/media/audio/audio_core/audio_device_settings.cc @@ -143,7 +143,7 @@ zx_status_t AudioDeviceSettings::InitFromDisk() { for (const auto& cfg_src : kConfigSources) { // Start by attempting to open a pre-existing file which has our settings in - // it. If we cannot find such a file, or if the file exists but is invalid, + // it. If we cannot find such a file, or if the file exists but is invalid, // simply create a new file and write out our current settings. char path[256]; fbl::unique_fd storage; @@ -156,26 +156,25 @@ zx_status_t AudioDeviceSettings::InitFromDisk() { if (res == ZX_OK) { if (cfg_src.is_default) { // If we just loaded and deserialized the fallback default config, - // then break out of the for loop and fall thru to the serialization - // code. + // break out of the loop and fall thru to serialization code. break; } - // We successfully loaded out persisted settings. Cancel our commit - // timer, hold onto the FD and we should be good to go. + // We successfully loaded our persisted settings. Cancel our commit + // timer, hold onto the FD, and we should be good to go. CancelCommitTimeouts(); storage_ = std::move(storage); return ZX_OK; } else { storage_.reset(); if (!cfg_src.is_default) { - FXL_LOG(WARNING) << "Failed to deserialize audio settings file \"" - << path << "\" (res " << res - << "). Re-creating file from defaults."; + FXL_LOG(INFO) << "Failed to read device settings at \"" << path + << "\" (err " << res + << "). Re-creating file from defaults."; ::unlink(path); } else { - FXL_LOG(WARNING) << "Could not load default audio settings from \"" - << path << "\" (res " << res << ")."; + FXL_LOG(INFO) << "Could not load default audio settings file \"" + << path << "\" (err " << res << ")."; } } } @@ -186,8 +185,8 @@ zx_status_t AudioDeviceSettings::InitFromDisk() { return ZX_OK; } - // We have failed to load our persisted settings for one reason or another. - // Try to create a settings file and persist our defaults to that instead. + // We failed to load persisted settings for one reason or another. + // Create a new settings file for this device; persist our defaults there. char path[256]; CreateSettingsPath(kSettingsPath, path, sizeof(path)); FXL_DCHECK(static_cast<bool>(storage_) == false); @@ -196,17 +195,17 @@ zx_status_t AudioDeviceSettings::InitFromDisk() { if (!static_cast<bool>(storage_)) { // TODO(mpuryear): define and enforce a limit for the number of settings // files allowed to be created. - FXL_LOG(ERROR) << "Failed to create new audio settings file \"" << path - << "\" (errno " << errno - << "). Settings will not be persisted."; + FXL_LOG(WARNING) << "Failed to create new audio settings file \"" << path + << "\" (err " << errno + << "). Settings for this device will not be persisted."; return ZX_ERR_IO; } zx_status_t res = Serialize(); if (res != ZX_OK) { - FXL_LOG(WARNING) << "Failed to serialize audio settings file \"" << path - << "\" (res " << res - << "). Settings will not be persisted."; + FXL_LOG(WARNING) << "Failed to write new settings file at \"" << path + << "\" (err " << res + << "). Settings for this device will not be persisted."; storage_.reset(); ::unlink(path); } diff --git a/src/media/audio/audio_core/audio_device_settings.h b/src/media/audio/audio_core/audio_device_settings.h index 401a160383c58bc607e80f2fd6fed971badc6832..42aee127c4bba7079eed8394f281013f2667584f 100644 --- a/src/media/audio/audio_core/audio_device_settings.h +++ b/src/media/audio/audio_core/audio_device_settings.h @@ -144,8 +144,8 @@ class AudioDeviceSettings // When settings are clean (in sync with storage), both will be infinite. // Anytime a change is introduced, the timeouts are updated as follows. // - // 1) If max is infinite, it gets set to now + MaxUpdateDelay, otherwise it - // is unchanged. + // 1) If max is infinite, it is set to now + MaxUpdateDelay, otherwise it is + // unchanged. // 2) next gets set to min(now + UpdateDelay, max_commit_time) // // When now >= next, it is time to commit. The general idea here is to wait diff --git a/src/media/audio/audio_core/audio_plug_detector.cc b/src/media/audio/audio_core/audio_plug_detector.cc index 04e7f5346051b717950ef1793d6d10a16faaf5f6..80d21e5988a351b99d39496a07a692f3250e8bed 100644 --- a/src/media/audio/audio_core/audio_plug_detector.cc +++ b/src/media/audio/audio_core/audio_plug_detector.cc @@ -47,7 +47,7 @@ zx_status_t AudioPlugDetector::Start(AudioDeviceManager* manager) { // If we are already running, we cannot start again. Cancel the cleanup // operation and report that things are successfully started. if (manager_ != nullptr) { - FXL_DLOG(WARNING) << "Attempted to start the AudioPlugDetector twice!"; + FXL_LOG(INFO) << "Attempted to start the AudioPlugDetector twice!"; error_cleanup.cancel(); return ZX_OK; } @@ -104,8 +104,8 @@ void AudioPlugDetector::AddAudioDevice(int dir_fd, const std::string& name, res = fdio_get_service_handle(dev_node.release(), dev_channel.reset_and_get_address()); if (res != ZX_OK) { - FXL_LOG(WARNING) << "Failed to obtain FDIO service channel to AudioOutput " - << "(res " << res << ")"; + FXL_LOG(ERROR) << "Failed to obtain FDIO service channel to AudioOutput " + << "(res " << res << ")"; return; } @@ -115,8 +115,8 @@ void AudioPlugDetector::AddAudioDevice(int dir_fd, const std::string& name, res = dev.GetChannel(&channel); if (res != ZX_OK) { - FXL_LOG(WARNING) << "Failed to open channel to AudioOutput (res " << res - << ")"; + FXL_LOG(ERROR) << "Failed to open channel to AudioOutput (res " << res + << ")"; return; } diff --git a/src/media/audio/audio_core/audio_renderer_impl.cc b/src/media/audio/audio_core/audio_renderer_impl.cc index aa1239276d6480abbe219361843a3f9f0aa0a481..309e1397783b290a0e6e67a706a3d398b031ad69 100644 --- a/src/media/audio/audio_core/audio_renderer_impl.cc +++ b/src/media/audio/audio_core/audio_renderer_impl.cc @@ -409,7 +409,7 @@ void AudioRendererImpl::SendPacket(fuchsia::media::StreamPacket packet, uint64_t start = packet.payload_offset; uint64_t end = start + packet.payload_size; uint64_t pb_size = payload_buffer_->size(); - if ((start >= payload_buffer_->size()) || (end > payload_buffer_->size())) { + if ((start >= pb_size) || (end > pb_size)) { FXL_LOG(ERROR) << "Bad packet range [" << start << ", " << end << "). Payload buffer size is " << pb_size; return; diff --git a/src/media/audio/audio_core/driver_output.cc b/src/media/audio/audio_core/driver_output.cc index 763a5145f0c3ebd9f8378c288bc9d4c15212b465..7db9b1239eee92197fba1c163de222c2ac7d5a85 100644 --- a/src/media/audio/audio_core/driver_output.cc +++ b/src/media/audio/audio_core/driver_output.cc @@ -295,8 +295,8 @@ void DriverOutput::OnDriverInfoFetched() { }); if (state_ != State::FetchingFormats) { - FXL_LOG(WARNING) << "Unexpected GetFormatsComplete while in state " - << static_cast<uint32_t>(state_); + FXL_LOG(ERROR) << "Unexpected GetFormatsComplete while in state " + << static_cast<uint32_t>(state_); return; } diff --git a/src/media/audio/audio_core/test/audio_device_test.cc b/src/media/audio/audio_core/test/audio_device_test.cc index 4b868ccb2a66d27c72150c974261000567512413..3d42fb85692b59c495c200d85ab751a10c62c27b 100644 --- a/src/media/audio/audio_core/test/audio_device_test.cc +++ b/src/media/audio/audio_core/test/audio_device_test.cc @@ -335,7 +335,7 @@ TEST_F(AudioDeviceTest, ReceivesGetDevicesCallback) { TEST_F(AudioDeviceTest, GetDevicesHandlesLackOfDevices) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } @@ -353,7 +353,7 @@ TEST_F(AudioDeviceTest, GetDevicesHandlesLackOfDevices) { TEST_F(AudioDeviceTest, GetDefaultInputDeviceHandlesLackOfDevices) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } RetrieveTokenUsingGetDefault(true); @@ -362,7 +362,7 @@ TEST_F(AudioDeviceTest, GetDefaultInputDeviceHandlesLackOfDevices) { TEST_F(AudioDeviceTest, GetDefaultOutputDeviceHandlesLackOfDevices) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } RetrieveTokenUsingGetDefault(false); diff --git a/src/media/audio/audio_core/test/virtual_audio_device_test.cc b/src/media/audio/audio_core/test/virtual_audio_device_test.cc index ef4e8c8ee6610a1bc61df30c34350f1c8a6f09c8..4d511b43b717419c78fa7e1c47871330b963940c 100644 --- a/src/media/audio/audio_core/test/virtual_audio_device_test.cc +++ b/src/media/audio/audio_core/test/virtual_audio_device_test.cc @@ -415,7 +415,7 @@ void VirtualAudioDeviceTest::TestGetDefaultDeviceUsingAddGetDevices( // From no-devices, GetDefault should recognize an added device as new default. void VirtualAudioDeviceTest::TestGetDefaultDeviceAfterAdd(bool is_input) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } @@ -444,7 +444,7 @@ void VirtualAudioDeviceTest::TestGetDefaultDeviceAfterAdd(bool is_input) { void VirtualAudioDeviceTest::TestGetDefaultDeviceAfterUnpluggedAdd( bool is_input) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } @@ -956,7 +956,7 @@ void VirtualAudioDeviceTest::TestOnDeviceRemovedAfterUnplug(bool is_input) { // unimportant Remove, Add(unplugged), plug change void VirtualAudioDeviceTest::TestOnDefaultDeviceChangedAfterAdd(bool is_input) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } diff --git a/src/media/audio/audio_core/test/virtual_audio_system_gain_test.cc b/src/media/audio/audio_core/test/virtual_audio_system_gain_test.cc index 736c8adf546271b39b8792ab85f402c59fff74a1..e82cbde64f19b88d1f94c95e677dc2a3d286b527 100644 --- a/src/media/audio/audio_core/test/virtual_audio_system_gain_test.cc +++ b/src/media/audio/audio_core/test/virtual_audio_system_gain_test.cc @@ -167,7 +167,7 @@ void VirtualAudioSystemGainTest::ChangeAndVerifySystemMute() { void VirtualAudioSystemGainTest::TestDeviceGainAfterChangeSystemGainMute( bool use_get_devices, bool is_input, bool set_gain) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } @@ -199,7 +199,7 @@ void VirtualAudioSystemGainTest:: TestOnDeviceGainChangedAfterChangeSystemGainMute(bool is_input, bool set_gain) { if (HasPreExistingDevices()) { - FXL_LOG(INFO) << "Test case requires an environment with no audio devices"; + FXL_DLOG(INFO) << "Test case requires an environment with no audio devices"; return; } diff --git a/src/media/audio/audio_core/utils.cc b/src/media/audio/audio_core/utils.cc index ad5683561af2ec93c399058f3972859f33301af3..283e59968a1f1ae02122b0a6b611c3c51244a23b 100644 --- a/src/media/audio/audio_core/utils.cc +++ b/src/media/audio/audio_core/utils.cc @@ -120,10 +120,10 @@ zx_status_t SelectBestFormat( // if (range.min_frames_per_second > range.max_frames_per_second) { // Skip this frame rate range entirely if it is empty. - FXL_DLOG(WARNING) << "Skipping empty frame rate range [" - << range.min_frames_per_second << ", " - << range.max_frames_per_second - << "] while searching for best format in driver list."; + FXL_LOG(INFO) << "Skipping empty frame rate range [" + << range.min_frames_per_second << ", " + << range.max_frames_per_second + << "] while searching for best format in driver list."; continue; } @@ -194,10 +194,10 @@ zx_status_t SelectBestFormat( // though min was <= max as it should be) Debug log a warning, then skip // the range entirely. if (frame_rate_score == 0) { - FXL_DLOG(WARNING) << "Skipping empty discrete frame rate range [" - << range.min_frames_per_second << ", " - << range.max_frames_per_second << "] (flags " - << range.flags << ") while searching for best format"; + FXL_LOG(INFO) << "Skipping empty discrete frame rate range [" + << range.min_frames_per_second << ", " + << range.max_frames_per_second << "] (flags " << range.flags + << ") while searching for best format"; continue; }