Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
113.69k stars 10.83k forks source link

Demuxer 'audio': stream explicitly disabled by the device #3934

Closed hannesa2 closed 1 year ago

hannesa2 commented 1 year ago

When I start scrcpy all works fine, expect audio

scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
/opt/homebrew/Cellar/scrcpy/2.0/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 36.1 MB/s (52867 bytes in 0.001s)
[server] INFO: Device: idc23 for arm64 (Android 12)
INFO: Renderer: metal
INFO: Initial texture: 1920x960
WARN: Demuxer 'audio': stream explicitly disabled by the device
[server] ERROR: Exception on thread Thread[Thread-4,5,main]
java.lang.UnsupportedOperationException: Cannot create AudioRecord
    at android.media.AudioRecord$Builder.build(AudioRecord.java:913)
    at com.genymobile.scrcpy.AudioCapture.createAudioRecord(AudioCapture.java:58)
    at com.genymobile.scrcpy.AudioCapture.start(AudioCapture.java:90)
    at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:183)
    at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:120)
    at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:2)
    at java.lang.Thread.run(Thread.java:920)
    WARN: Killing the server...

Demuxer 'audio': stream explicitly disabled by the device does someone knows how to enable it. It's an own build of AOSP

Btw, thank you for this cool tool !

rom1v commented 1 year ago

AudioRecord.Builder.build() throws an UnsupportedOperationException.

It is expected on Android 11 when the shell application is not foreground when you start, but not on Android 12.

Just in case, unlock your device, execute:

adb shell am start -n com.android.shell/.HeapDumpActivity

It should open a popup. While the popup is visible, start scrcpy. Does it solve the problem?

hannesa2 commented 1 year ago

I see this dialog

image

means "Share heap dump? The memory limit of 0.00 was exceeded for the process "null". A heap dump is available to share with the developer. However, it is important to note that the heap dump may contain personal information about you that the app can access."

Unfortunately , scrcpy still shows the same error

[server] ERROR: Exception on thread Thread[Thread-4,5,main]
java.lang.UnsupportedOperationException: Cannot create AudioRecord
    at android.media.AudioRecord$Builder.build(AudioRecord.java:913)
    at com.genymobile.scrcpy.AudioCapture.createAudioRecord(AudioCapture.java:58)
    at com.genymobile.scrcpy.AudioCapture.start(AudioCapture.java:90)
    at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:183)
    at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:120)
    at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:2)
    at java.lang.Thread.run(Thread.java:920)
INFO: Renderer: metal
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Initial texture: 1920x960
rom1v commented 1 year ago

OK, so that's not the same cause as on Android 11. You must find in your ROM why building an AudioRecord throws an UnsupportedOperationException. On Android 12, it is not expected to happen (AOSP or vendor ROMs).

rom1v commented 1 year ago

UnsupportedOperationException if the parameters set on the Builder were incompatible, if the parameters are not supported by the device, if the caller does not hold the appropriate permissions, or if the device was not available.

https://developer.android.com/reference/android/media/AudioRecord.Builder#build()

hannesa2 commented 1 year ago

Ok, I guess it's on my side. I close it, Thank you !

hyunkwak commented 4 months ago

Hello @hannesa2, I am experiencing the same issue with my own build of AOSP and I was wondering if you managed to resolve it in the end? Thanks 🙂

hannesa2 commented 4 months ago

Sorry, no