Skip to content

Commit

Permalink
Cherry pick PR youtube#1607: [android] Add SB version guards (youtube…
Browse files Browse the repository at this point in the history
…#1632)

Refer to the original PR: youtube#1607

b/284140486

Co-authored-by: Jason <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and jasonzhangxx authored Sep 25, 2023
1 parent ee8fecb commit faede4f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions starboard/android/shared/media_capabilities_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ constexpr int TYPE_USB_HEADSET = 22;
constexpr int TYPE_WIRED_HEADPHONES = 4;
constexpr int TYPE_WIRED_HEADSET = 3;

#if SB_API_VERSION >= 15
SbMediaAudioConnector GetConnectorFromAndroidOutputType(
int android_output_device_type) {
switch (android_output_device_type) {
Expand Down Expand Up @@ -145,6 +146,7 @@ SbMediaAudioConnector GetConnectorFromAndroidOutputType(
<< android_output_device_type;
return kSbMediaAudioConnectorUnknown;
}
#endif // SB_API_VERSION >= 15

bool EndsWith(const std::string& str, const std::string& suffix) {
if (str.size() < suffix.size()) {
Expand Down Expand Up @@ -267,8 +269,12 @@ bool GetAudioConfiguration(int index,
return env->CallIntMethodOrAbort(j_output_device_info.Get(), name, "()I");
};

#if SB_API_VERSION >= 15
configuration->connector =
GetConnectorFromAndroidOutputType(call_int_method("getType"));
#else // SB_API_VERSION >= 15
configuration->connector = kSbMediaAudioConnectorHdmi;
#endif // SB_API_VERSION >= 15
configuration->latency = 0;
configuration->coding_type = kSbMediaAudioCodingTypePcm;
configuration->number_of_channels = call_int_method("getChannels");
Expand Down

0 comments on commit faede4f

Please sign in to comment.