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

Automatically detect supported sample rates for each codec #508

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

chenxiaolong
Copy link
Owner

Some devices unfortunately disable common sample rates that are normally supported in AOSP's software encoders. This commit reworks all of BCR's MediaCodec-based formats to query for the list of supported sample rates instead of relying on a hardcoded list. If BCR's default sample rate for a format is not supported, the closest supported sample rate will be used. The same applies for Android upgrades that remove support for the sample rate previously chosen by the user.

These queries are fast enough to be unnoticeable on Pixel devices. Hopefully other OEMs don't make modifications that slow this down, like they do for so many other things.

Fixes: #507

@chenxiaolong chenxiaolong self-assigned this Mar 3, 2024
@chenxiaolong chenxiaolong force-pushed the detect-sample-rate branch 2 times, most recently from 3294415 to 05e55a8 Compare March 3, 2024 22:14
Some devices unfortunately disable common sample rates that are normally
supported in AOSP's software encoders. This commit reworks all of BCR's
MediaCodec-based formats to query for the list of supported sample
rates instead of relying on a hardcoded list. If BCR's default sample
rate for a format is not supported, the closest supported sample rate
will be used. The same applies for Android upgrades that remove support
for the sample rate previously chosen by the user.

These queries are fast enough to be unnoticeable on Pixel devices.
Hopefully other OEMs don't make modifications that slow this down, like
they do for so many other things.

Fixes: #507

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong chenxiaolong merged commit 5f2b428 into master Mar 3, 2024
1 check passed
@chenxiaolong chenxiaolong deleted the detect-sample-rate branch March 3, 2024 22:19
chenxiaolong added a commit that referenced this pull request Mar 3, 2024
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@@ -11,3 +12,14 @@ val AudioFormat.frameSizeInBytesCompat: Int
assert(encoding == AudioFormat.ENCODING_PCM_16BIT)
2 * channelCount
}

// Static extension functions are currently not supported in Kotlin. Also, we install a sysconfig
Copy link
Contributor

@quyenvsp quyenvsp May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, what mean "we install a sysconfig"? This line seem lead to crash on my Pixel 5a API 34.

Caused by: java.lang.NoSuchFieldException: No field SAMPLE_RATE_HZ_MIN in class Landroid/media/AudioFormat; (declaration of 'android.media.AudioFormat' appears in /system/framework/framework.jar!classes2.dex)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's referring to the /system/etc/sysconfig/config-com.chiller3.bcr.xml file, which is included in BCR's Magisk module. That's supposed to allow BCR to access hidden/system APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to record call
2 participants