Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quirks: Include Vivo and check for Oboe workaround flag #1590

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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::shouldConvertFloatToI16() {
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->shouldConvertFloatToI16()
) {
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 shouldConvertFloatToI16();

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

Expand Down