Skip to content

Commit

Permalink
Quirks: Include Vivo and check for Oboe workaround flag (#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwu1 authored Aug 4, 2022
1 parent 927f2bd commit b99f4d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/common/QuirksManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ bool QuirksManager::DeviceQuirks::isAAudioMMapPossible(const AudioStreamBuilder
&& builder.getChannelCount() <= kChannelCountStereo;
}

bool QuirksManager::DeviceQuirks::shouldConvertFloatToI16ForOutputStreams() {
std::string productManufacturer = getPropertyString("ro.product.manufacturer");
if (getSdkVersion() < __ANDROID_API_L__) {
return true;
} else if ((productManufacturer == "vivo") && (getSdkVersion() < __ANDROID_API_M__)) {
return true;
}
return false;
}

/**
* This is for Samsung Exynos quirks. Samsung Mobile uses Qualcomm chips so
* the QualcommDeviceQuirks would apply.
Expand Down Expand Up @@ -213,7 +223,8 @@ bool QuirksManager::isConversionNeeded(
conversionNeeded = true;
}

// If a SAMPLE RATE is specified for low latency then let the native code choose an optimal rate.
// If a SAMPLE RATE is specified for low latency, let the native code choose an optimal rate.
// This isn't really a workaround. It is an Oboe feature that is convenient to place here.
// TODO There may be a problem if the devices supports low latency
// at a higher rate than the default.
if (builder.getSampleRate() != oboe::Unspecified
Expand All @@ -226,7 +237,8 @@ bool QuirksManager::isConversionNeeded(

// Data Format
// OpenSL ES and AAudio before P do not support FAST path for FLOAT capture.
if (isFloat
if (OboeGlobals::areWorkaroundsEnabled()
&& isFloat
&& isInput
&& builder.isFormatConversionAllowed()
&& isLowLatency
Expand All @@ -237,15 +249,17 @@ bool QuirksManager::isConversionNeeded(
LOGI("QuirksManager::%s() forcing internal format to I16 for low latency", __func__);
}

// Add quirk for float output on API <21
if (isFloat
// Add quirk for float output when needed.
if (OboeGlobals::areWorkaroundsEnabled()
&& isFloat
&& !isInput
&& getSdkVersion() < __ANDROID_API_L__
&& builder.isFormatConversionAllowed()
&& mDeviceQuirks->shouldConvertFloatToI16ForOutputStreams()
) {
childBuilder.setFormat(AudioFormat::I16);
conversionNeeded = true;
LOGI("QuirksManager::%s() float was requested but not supported on pre-L devices, "
LOGI("QuirksManager::%s() float was requested but not supported on pre-L devices "
"and some devices like Vivo devices may have issues on L devices, "
"creating an underlying I16 stream and using format conversion to provide a float "
"stream", __func__);
}
Expand Down
3 changes: 3 additions & 0 deletions src/common/QuirksManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class QuirksManager {
return true;
}

// On some devices, Float does not work so it should be converted to I16.
static bool shouldConvertFloatToI16ForOutputStreams();

static constexpr int32_t kDefaultBottomMarginInBursts = 0;
static constexpr int32_t kDefaultTopMarginInBursts = 0;

Expand Down

0 comments on commit b99f4d0

Please sign in to comment.