A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

usbaudio: block playback while usbaudio is active

Needed due to us commandeering the AUDIO DSP "channel" for USBAudio.
If/When we add another DSP channel, this can be reverted.

Works, but still goes to a "blank" WPS screen for a split second before
cancelling out.

Change-Id: I5fb8a1e226b4d3e46c86c59d593d807f49d7a35f

+28
+15
apps/playback.c
··· 65 #include <strings.h> /* For strncasecmp() */ 66 #endif 67 68 /* TODO: The audio thread really is doing multitasking of acting like a 69 consumer and producer of tracks. It may be advantageous to better 70 logically separate the two functions. I won't go that far just yet. */ ··· 2978 static void audio_start_playback(const struct audio_resume_info *resume_info, 2979 unsigned int flags) 2980 { 2981 static struct audio_resume_info resume = { 0, 0 }; 2982 enum play_status old_status = play_status; 2983
··· 65 #include <strings.h> /* For strncasecmp() */ 66 #endif 67 68 + #ifdef USB_ENABLE_AUDIO 69 + #include "usbstack/usb_audio.h" 70 + #include "splash.h" 71 + #include "lang.h" 72 + #endif 73 + 74 /* TODO: The audio thread really is doing multitasking of acting like a 75 consumer and producer of tracks. It may be advantageous to better 76 logically separate the two functions. I won't go that far just yet. */ ··· 2984 static void audio_start_playback(const struct audio_resume_info *resume_info, 2985 unsigned int flags) 2986 { 2987 + /* NOTE: if USBAudio ever gets its own DSP channel, this block can go away! */ 2988 + #ifdef USB_ENABLE_AUDIO 2989 + if (usb_audio_get_active()) 2990 + { 2991 + splash(HZ*2, str(LANG_USB_DAC_ACTIVE)); 2992 + queue_reply(&audio_queue, 0); 2993 + return; 2994 + } 2995 + #endif 2996 static struct audio_resume_info resume = { 0, 0 }; 2997 enum play_status old_status = play_status; 2998
+10
firmware/usbstack/usb_audio.c
··· 398 static int last_frame = 0; 399 static int frames_dropped = 0; 400 401 /* Schematic view of the RX situation: 402 * (in case NR_BUFFERS = 4) 403 * ··· 1181 { 1182 logf("usbaudio: init connection"); 1183 1184 dsp = dsp_get_config(CODEC_IDX_AUDIO); 1185 dsp_configure(dsp, DSP_RESET, 0); 1186 dsp_configure(dsp, DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); ··· 1202 1203 usb_audio_stop_playback(); 1204 usb_audio_free_buf(); 1205 } 1206 1207 bool usb_audio_get_alloc_failed(void)
··· 398 static int last_frame = 0; 399 static int frames_dropped = 0; 400 401 + /* for blocking normal playback */ 402 + static bool usbaudio_active = false; 403 + 404 /* Schematic view of the RX situation: 405 * (in case NR_BUFFERS = 4) 406 * ··· 1184 { 1185 logf("usbaudio: init connection"); 1186 1187 + usbaudio_active = true; 1188 dsp = dsp_get_config(CODEC_IDX_AUDIO); 1189 dsp_configure(dsp, DSP_RESET, 0); 1190 dsp_configure(dsp, DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); ··· 1206 1207 usb_audio_stop_playback(); 1208 usb_audio_free_buf(); 1209 + usbaudio_active = false; 1210 + } 1211 + 1212 + bool usb_audio_get_active(void) 1213 + { 1214 + return usbaudio_active; 1215 } 1216 1217 bool usb_audio_get_alloc_failed(void)
+3
firmware/usbstack/usb_audio.h
··· 20 #define USB_AUDIO_H 21 22 #include "usb_ch9.h" 23 24 /* NOTE 25 * ··· 275 * Return current audio volume in db 276 */ 277 int usb_audio_get_cur_volume(void); 278 279 #endif
··· 20 #define USB_AUDIO_H 21 22 #include "usb_ch9.h" 23 + #include "usb_class_driver.h" 24 25 /* NOTE 26 * ··· 276 * Return current audio volume in db 277 */ 278 int usb_audio_get_cur_volume(void); 279 + 280 + bool usb_audio_get_active(void); 281 282 #endif