hiby: r3proii: fix crash on playback when no headphones are detected

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Fri, 17 Jul 2026 10:07:30 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 8923f479d0fabe94ac585b646b8d4d376a174918
Author: Roman Artiukhin <[email protected]>
Date:   Wed Jul 15 15:50:10 2026 +0300

    hiby: r3proii: fix crash on playback when no headphones are detected
    
    0 is an invalid value to set on Hiby as "Output Port Switch". For devices with multiple outputs, we need to ensure it is set to a valid port.
    
    Change-Id: I16ea2e620fae3034dccf3267d316924d8e2c0a95

diff --git a/firmware/target/hosted/hiby/hibylinux_codec.c b/firmware/target/hosted/hiby/hibylinux_codec.c
index ba338f5410..4cb445887d 100644
--- a/firmware/target/hosted/hiby/hibylinux_codec.c
+++ b/firmware/target/hosted/hiby/hibylinux_codec.c
@@ -86,6 +86,12 @@ void hiby_set_output(int ps)
 {
     if (!hw_init || muted) return;
 
+    // Default to headset if nothing was ever inserted; otherwise, R3 Pro II crashes on playback
+    if (ps == 0)
+    {
+        ps = last_ps > 0 ? last_ps : 2;
+    }
+
     if (last_ps != ps)
     {
         logf("set out %d/%d", ps, last_ps);
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs