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

Audio quality issue #327

Open
Seezov opened this issue Jan 10, 2025 · 0 comments
Open

Audio quality issue #327

Seezov opened this issue Jan 10, 2025 · 0 comments
Labels
device Indicates that an issue cannot be addressed due to the lack of access to the required device. good first issue Indicates that an issue for newcommers.

Comments

@Seezov
Copy link

Seezov commented Jan 10, 2025

Describe the bug

Hi, I have audio quality issues on devices with Android 8 and 9 and some Android 10 devices. If I use default settings for AudioRecord I get distorted and choppy sound when streaming from the device.

To Reproduce

Stream from devices with Android 8 or 9

Expected behavior

Quality should be good

Version

0.14.1

Smartphone info.

Any device with Android 8 or 9, OPPO device with Andorid 10

Additional context

I've made temporary fix by coping your AudioRecordSource file and setting sampleCount to 2048 instead of default 1024, and it helped, the quality got better but it brought another issue. Now on newer devices (Android 11 and above and some Android 10) there is a crash when trying to stream

2025-01-10 16:25:49.887 AndroidRuntime           E  FATAL EXCEPTION: com.haishinkit.codec.AudioCodec (Ask Gemini)
                                                    Process: com.kidslox.app, PID: 14414
                                                    java.nio.BufferOverflowException
                                                    	at java.nio.ByteBuffer.put(ByteBuffer.java:1035)
                                                    	at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:285)
                                                    	at com.haishinkit.codec.AudioCodecBuffer.render(AudioCodecBuffer.kt:29)
                                                    	at com.haishinkit.codec.AudioCodec.onInputBufferAvailable(AudioCodec.kt:68)
                                                    	at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1923)
                                                    	at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1851)
                                                    	at android.os.Handler.dispatchMessage(Handler.java:109)
                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                    	at android.os.Looper.loop(Looper.java:317)
                                                    	at android.os.HandlerThread.run(HandlerThread.java:85)

So I guess, setting a 2048 sample count is not an ideal solution and I have a question. PLUS the problem is NOT Android version specific, because I've tested multiple devices with Android 10 and for some of them there are sound quality issues and for some, there are not.

  1. How can I increase sound quality on older devices?
  2. Maybe if increasing sampleCount IS the solution then can you add throws BufferOverflowException to onInputBufferAvailable or smth so I can catch the exception? Or maybe you could set sampleCount value based on the device (if it supports 2048 - set 2048)

Screenshots

No response

Relevant log output

2025-01-10 16:25:49.887 AndroidRuntime           E  FATAL EXCEPTION: com.haishinkit.codec.AudioCodec (Ask Gemini)
                                                    Process: com.kidslox.app, PID: 14414
                                                    java.nio.BufferOverflowException
                                                    	at java.nio.ByteBuffer.put(ByteBuffer.java:1035)
                                                    	at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:285)
                                                    	at com.haishinkit.codec.AudioCodecBuffer.render(AudioCodecBuffer.kt:29)
                                                    	at com.haishinkit.codec.AudioCodec.onInputBufferAvailable(AudioCodec.kt:68)
                                                    	at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1923)
                                                    	at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1851)
                                                    	at android.os.Handler.dispatchMessage(Handler.java:109)
                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                    	at android.os.Looper.loop(Looper.java:317)
                                                    	at android.os.HandlerThread.run(HandlerThread.java:85)
@shogo4405 shogo4405 added device Indicates that an issue cannot be addressed due to the lack of access to the required device. good first issue Indicates that an issue for newcommers. labels Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
device Indicates that an issue cannot be addressed due to the lack of access to the required device. good first issue Indicates that an issue for newcommers.
Projects
None yet
Development

No branches or pull requests

2 participants