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(
LOG(INFO) << "No saved volumes found";
// If saved_volumes does not exist, use per-device default if it exists.
JSONFileValueDeserializer cast_audio_deserializer(
media::CastAudioJson::GetFilePath());
auto cast_audio_config = deserializer.Deserialize(nullptr, nullptr);
auto path = media::CastAudioJson::GetFilePath();
JSONFileValueDeserializer cast_audio_deserializer(path);
auto cast_audio_config =
cast_audio_deserializer.Deserialize(nullptr, nullptr);
if (!cast_audio_config || !cast_audio_config->is_dict()) {
LOG(INFO) << "Invalid JSON from " << path;
return volumes;
}
const base::Value* default_volume_dict =
cast_audio_config->FindDictKey(kKeyDefaultVolume);
if (!default_volume_dict) {
LOG(INFO) << "No default volumes specified in " << path;
return volumes;
}
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) {
LOG(INFO) << "Using default volume for " << ContentTypeToDbFSKey(type)
<< " of " << v.value();
LOG(INFO) << "Using default volume for " << key << " of " << v.value();
volumes[type] = v.value();
} else {
LOG(INFO) << "No default volume for " << key;
}
}
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