Skip to content

Commit

Permalink
[android] Refine SbMediaGetAudioConfiguration() (#3900)
Browse files Browse the repository at this point in the history
Log an error message when there is no audio connector for a certain
index, and no longer calling GetMediaAudioConnectorName() in such case,
to avoid triggering SB_NOTREACHED() in GetMediaAudioConnectorName() with
an invalid audio connector.

b/276483058

Change-Id: Ic713f75c114b8e27bc245e63194600880cd38804
  • Loading branch information
xiaomings authored Jul 26, 2024
1 parent ff5848d commit 39cf99d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions starboard/android/shared/media_get_audio_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ bool SbMediaGetAudioConfiguration(
return false;
}

bool result = MediaCapabilitiesCache::GetInstance()->GetAudioConfiguration(
output_index, out_configuration);

SB_LOG(INFO) << "Audio connector type for index " << output_index << " is "
<< GetMediaAudioConnectorName(out_configuration->connector)
<< " and it has " << out_configuration->number_of_channels
<< " channels.";
if (MediaCapabilitiesCache::GetInstance()->GetAudioConfiguration(
output_index, out_configuration)) {
SB_LOG(INFO) << "Audio connector type for index " << output_index << " is "
<< GetMediaAudioConnectorName(out_configuration->connector)
<< " and it has " << out_configuration->number_of_channels
<< " channels.";
return true;
}

return result;
SB_LOG(INFO) << "Failed to find audio connector type for index "
<< output_index;
return false;
}

0 comments on commit 39cf99d

Please sign in to comment.