Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

rgnano: Sleep timer and idle poweroff support

Actually power off the handheld with the sleep timer and idle poweroff functions instead of closing rockbox.

This commit also moves setting system volume to max from the launch script to system-sdl.c so it works when running rockbox via instant play.

Change-Id: I174b67c6abef451faa05f4a8f52b8d9eeed98a22

authored by

Hairo R. Carela and committed by
Solomon Peachy
c9e16e48 5ecb5832

+36 -26
+21 -16
firmware/target/hosted/anbernic/instant_play.c
··· 80 80 } 81 81 } 82 82 83 - void ip_handle_sigusr1(int sig) 83 + void ip_power_off(void) 84 84 { 85 - if (sig == SIGUSR1) 86 - { 87 - /* Stop the powerdown countdown */ 88 - system("powerdown handle"); 85 + /* Stop the powerdown countdown */ 86 + system("powerdown handle"); 87 + 88 + /* Write the instant_play file */ 89 + char buf[60]; 90 + size_t nbytes; 91 + int fd; 89 92 90 - /* Write the instant_play file */ 91 - char buf[60]; 92 - size_t nbytes; 93 - int fd; 93 + fd = open("/mnt/instant_play", O_WRONLY | O_CREAT, 0640); 94 94 95 - fd = open("/mnt/instant_play", O_WRONLY | O_CREAT, 0640); 95 + strcpy(buf, "'/opk/rockbox' &\npid record $!\nwait $!\npid erase\n"); 96 + nbytes = strlen(buf); 97 + write(fd, buf, nbytes); 96 98 97 - strcpy(buf, "'/opk/rockbox' &\npid record $!\nwait $!\npid erase\n"); 98 - nbytes = strlen(buf); 99 - write(fd, buf, nbytes); 99 + close(fd); 100 100 101 - close(fd); 101 + /* Powerdown the handheld after writting the file */ 102 + system("powerdown now"); 103 + } 102 104 103 - /* Powerdown the handheld after writting the file */ 104 - system("powerdown now"); 105 + void ip_handle_sigusr1(int sig) 106 + { 107 + if (sig == SIGUSR1) 108 + { 109 + ip_power_off(); 105 110 } 106 111 }
+2 -1
firmware/target/hosted/anbernic/instant_play.h
··· 20 20 #ifndef _INSTANT_PLAY_H_ 21 21 #define _INSTANT_PLAY_H_ 22 22 23 + void ip_reset_values(void); 24 + void ip_power_off(void); 23 25 void ip_handle_sigusr1(int sig); 24 - void ip_reset_values(void); 25 26 #endif /* _INSTANT_PLAY_H_ */
+7 -5
firmware/target/hosted/sdl/button-sdl.c
··· 586 586 return; 587 587 #endif 588 588 #endif 589 - #if (CONFIG_PLATFORM & PLATFORM_PANDORA) || defined(RG_NANO) 590 - #ifdef RG_NANO 591 - case SDLK_q: 592 - #else 589 + #if (CONFIG_PLATFORM & PLATFORM_PANDORA) 593 590 case SDLK_LCTRL: 594 - #endif 595 591 /* Will post SDL_USEREVENT in shutdown_hw() if successful. */ 596 592 sys_poweroff(); 593 + break; 594 + #endif 595 + #ifdef RG_NANO 596 + case SDLK_q: 597 + /* Use reboot to exit without shutting down */ 598 + sys_reboot(); 597 599 break; 598 600 #endif 599 601 #ifdef HAS_BUTTON_HOLD
+6
firmware/target/hosted/sdl/system-sdl.c
··· 202 202 #if defined(RG_NANO) && !defined(SIMULATOR) 203 203 /* Reset volume/brightness to the values before launching rockbox */ 204 204 ip_reset_values(); 205 + ip_power_off(); 205 206 #endif 206 207 207 208 #ifdef HAVE_SDL_THREADS ··· 252 253 #endif 253 254 254 255 #if defined(RG_NANO) && !defined(SIMULATOR) 256 + /* Set system volume to max with amixer */ 257 + system("amixer -q sset 'Headphone' 63 unmute"); 258 + 255 259 /* Instant play handling */ 256 260 struct sigaction ip_sa; 257 261 ip_sa.sa_handler = ip_handle_sigusr1; ··· 305 309 #if defined(RG_NANO) && !defined(SIMULATOR) 306 310 /* Reset volume/brightness to the values before launching rockbox */ 307 311 ip_reset_values(); 312 + SDL_Quit(); 313 + exit(EXIT_SUCCESS); 308 314 #endif 309 315 310 316 #ifdef HAVE_SDL_THREADS
-1
packaging/rgnano/config.cfg
··· 1 1 # .cfg file created by rockbox c145f41658-250621 - http://www.rockbox.org 2 2 3 - idle poweroff: 0 4 3 font: /FunKey/.rockbox/fonts/16-GNU-Unifont.fnt 5 4 database scan paths: /Music 6 5 qs top: brightness
-3
packaging/rgnano/run.sh
··· 39 39 cp ./config.cfg $CFGFILE 40 40 fi 41 41 42 - # Set volume to max with amixer so it's not permanent 43 - amixer -q sset 'Headphone' 63 unmute 44 - 45 42 # Need to send SIGUSR1 to the rockbox process for instant play support 46 43 trap _send_sigusr1 SIGUSR1 47 44