Commit 3899f64d authored by Ken MacKay's avatar Ken MacKay Committed by Commit Bot

[Chromecast] Fix default volume loading

Fix a bug where the default volumes were not loaded correctly. Also add
more logging.

Bug: internal b/167692705
Change-Id: I0e580422d3473f05ca9f4939407138f1e57aea3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414833
Commit-Queue: Kenneth MacKay <kmackay@chromium.org>
Commit-Queue: Yuchen Liu <yucliu@chromium.org>
Auto-Submit: Kenneth MacKay <kmackay@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807586}
parent ec20a6bb
...@@ -62,25 +62,30 @@ base::flat_map<AudioContentType, double> LoadSavedVolumes( ...@@ -62,25 +62,30 @@ base::flat_map<AudioContentType, double> LoadSavedVolumes(
LOG(INFO) << "No saved volumes found"; LOG(INFO) << "No saved volumes found";
// If saved_volumes does not exist, use per-device default if it exists. // If saved_volumes does not exist, use per-device default if it exists.
JSONFileValueDeserializer cast_audio_deserializer( auto path = media::CastAudioJson::GetFilePath();
media::CastAudioJson::GetFilePath()); JSONFileValueDeserializer cast_audio_deserializer(path);
auto cast_audio_config = deserializer.Deserialize(nullptr, nullptr); auto cast_audio_config =
cast_audio_deserializer.Deserialize(nullptr, nullptr);
if (!cast_audio_config || !cast_audio_config->is_dict()) { if (!cast_audio_config || !cast_audio_config->is_dict()) {
LOG(INFO) << "Invalid JSON from " << path;
return volumes; return volumes;
} }
const base::Value* default_volume_dict = const base::Value* default_volume_dict =
cast_audio_config->FindDictKey(kKeyDefaultVolume); cast_audio_config->FindDictKey(kKeyDefaultVolume);
if (!default_volume_dict) { if (!default_volume_dict) {
LOG(INFO) << "No default volumes specified in " << path;
return volumes; return volumes;
} }
for (auto type : types) { for (auto type : types) {
auto v = default_volume_dict->FindDoublePath(ContentTypeToDbFSKey(type)); std::string key = ContentTypeToDbFSKey(type);
auto v = default_volume_dict->FindDoublePath(key);
if (v) { if (v) {
LOG(INFO) << "Using default volume for " << ContentTypeToDbFSKey(type) LOG(INFO) << "Using default volume for " << key << " of " << v.value();
<< " of " << v.value();
volumes[type] = v.value(); volumes[type] = v.value();
} else {
LOG(INFO) << "No default volume for " << key;
} }
} }
return volumes; return volumes;
......
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