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

Can't play audio stream on android devices #322

Closed
yevhen-zhdanov opened this issue Nov 25, 2024 · 3 comments
Closed

Can't play audio stream on android devices #322

yevhen-zhdanov opened this issue Nov 25, 2024 · 3 comments
Milestone

Comments

@yevhen-zhdanov
Copy link

Describe the bug

Hello.

App crashes when starts to play audio stream that was created on any another android device.

I can play this stream in ios app (by HaishinKit.swift) or ffmpeg in console of linux. Also my android app plays streams that created by OBS studio or ffmpeg.

It is very similar to #163

To Reproduce

  1. Create audio stream on first android device
    rtmpStream.attachAudio(AudioRecordSource(context))
    rtmpStream.attachVideo(null)
    ...
    rtmpStream.publish(getStreamName())

  2. Try to play stream on second android device
    rtmpSstream.play(getStreamName())

Expected behavior

Stream should play

Version

0.14.0
0.13.7

Smartphone info.

Samsung A15
Motorola G24
Pixel 6a, Pixel 7a, 14 Android
emulators of android studio

Additional context

It looks like mistake here. Need replace channelCount by channelMask in calling AudioTrack.getMinBufferSize function

solution

Screenshots

No response

Relevant log output

Channel configuration features unsupported channels
getMinBufferSize(): Invalid channel configuration.
FATAL EXCEPTION: com.haishinkit.codec.AudioCodec
        Process: com.kidslox.app, PID: 4091
        java.lang.IllegalArgumentException: Invalid audio buffer size.
        at android.media.AudioTrack.audioBuffSizeCheck(AudioTrack.java:1955)
        at android.media.AudioTrack.<init>(AudioTrack.java:810)
        at android.media.AudioTrack.<init>(AudioTrack.java:752)
        at android.media.AudioTrack.<init>(AudioTrack.java:706)
        at android.media.AudioTrack.<init>(AudioTrack.java:647)
        at com.haishinkit.net.NetStream.createAudioTrack$haishinkit_release(NetStream.kt:165)
        at com.haishinkit.rtmp.RtmpMuxer.onFormatChanged(RtmpMuxer.kt:268)
        at com.haishinkit.codec.Codec.setOutputFormat(Codec.kt:170)
        at com.haishinkit.codec.Codec.access$setOutputFormat(Codec.kt:18)
        at com.haishinkit.codec.Codec$Callback.onOutputFormatChanged(Codec.kt:92)
        at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1868)
        at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1753)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)
@Seezov
Copy link

Seezov commented Nov 26, 2024

Have exactly the same issue, would be great if it was fixed

@Cjsghkd
Copy link

Cjsghkd commented Nov 27, 2024

I'm having this problem too and hope it gets resolved.

@shogo4405 shogo4405 added this to the 0.14.1 milestone Nov 28, 2024
@shogo4405
Copy link
Owner

@yevhen-zhdanov Thank you feedback. I fixed it.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants