diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2024-12-09 21:06:05 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2024-12-09 21:06:51 -0500 |
commit | 65d94ecd08c12c033d150a3ae11750317c2d6ef1 (patch) | |
tree | c3e5bdf852c871c2ac0770fd3d515625e42a9cb9 | |
parent | b3dac27aa6c68819c0daabf9b806344207db41c7 (diff) | |
download | rockbox-65d94ecd08.tar.gz rockbox-65d94ecd08.zip |
SDL: Allow the audio device used to be specified on the command line
To aid this we display the list of allowed drivers and devices at startup
Change-Id: If27fc2c4873b56cd220a3e3e1ad78e9ede1979e7
-rw-r--r-- | firmware/target/hosted/sdl/pcm-sdl.c | 26 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/system-sdl.c | 11 |
2 files changed, 32 insertions, 5 deletions
diff --git a/firmware/target/hosted/sdl/pcm-sdl.c b/firmware/target/hosted/sdl/pcm-sdl.c index 83c983559b..93f2361202 100644 --- a/firmware/target/hosted/sdl/pcm-sdl.c +++ b/firmware/target/hosted/sdl/pcm-sdl.c @@ -24,6 +24,7 @@ #include <stdlib.h> #include <stdbool.h> +#include <stdio.h> #include <SDL.h> #include "config.h" #include "debug.h" @@ -47,10 +48,12 @@ #include "logf.h" #ifdef DEBUG -#include <stdio.h> extern bool debug_audio; #endif +extern const char *audiodev; + + static int cvt_status = -1; static const void *pcm_data; @@ -101,8 +104,8 @@ static void pcm_dma_apply_settings_nolock(void) if (pcm_devid) SDL_CloseAudioDevice(pcm_devid); /* Open the audio device and start playing sound! */ - if((pcm_devid = SDL_OpenAudioDevice(NULL, 0, &wanted_spec, &obtained, 0)) == 0) { - DEBUGF("Unable to open audio: %s\n", SDL_GetError()); + if((pcm_devid = SDL_OpenAudioDevice(audiodev, 0, &wanted_spec, &obtained, 0)) == 0) { + panicf("Unable to open audio: %s\n", SDL_GetError()); return; } switch (obtained.format) @@ -122,7 +125,7 @@ static void pcm_dma_apply_settings_nolock(void) pcm_channel_bytes = 4; break; default: - DEBUGF("Unknown sample format obtained: %u\n", + panicf("Unknown sample format obtained: %u\n", (unsigned)obtained.format); return; } @@ -365,10 +368,23 @@ void pcm_play_dma_init(void) { if (SDL_InitSubSystem(SDL_INIT_AUDIO)) { - DEBUGF("Could not initialize SDL audio subsystem!\n"); + panicf("Could not initialize SDL audio subsystem!\n"); return; } +#ifdef SIMULATOR + int cnt = SDL_GetNumAudioDrivers(); + printf("SDL Audio Drivers supported:\n"); + for (int i = 0 ; i < cnt ; i++) { + printf(" %s %s\n", SDL_GetAudioDriver(i), SDL_GetAudioDriver(i) == SDL_GetCurrentAudioDriver() ? "(active)" : ""); + } + cnt = SDL_GetNumAudioDevices(0); + printf("SDL Audio Devices present:\n"); + for (int i = 0 ; i < cnt ; i++) { + printf(" '%s'\n", SDL_GetAudioDeviceName(i, 0)); + } +#endif + audio_lock = SDL_CreateMutex(); if (!audio_lock) diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c index 22186a5e36..1003191fb3 100644 --- a/firmware/target/hosted/sdl/system-sdl.c +++ b/firmware/target/hosted/sdl/system-sdl.c @@ -58,6 +58,7 @@ bool background = true; /* use backgrounds by default */ bool showremote = true; /* include remote by default */ #endif bool mapping = false; +const char *audiodev = NULL; bool debug_buttons = false; bool lcd_display_redraw = true; /* Used for player simulator */ @@ -388,6 +389,15 @@ void sys_handle_argv(int argc, char *argv[]) debug_buttons = true; printf("Printing background button clicks.\n"); } + else if (!strcmp("--audiodev", argv[x])) + { + x++; + if (x < argc) + { + audiodev = argv[x]; + printf("Audio device: '%s'\n", audiodev); + } + } else { printf("rockboxui\n"); @@ -405,6 +415,7 @@ void sys_handle_argv(int argc, char *argv[]) printf(" --alarm \t Simulate a wake-up on alarm\n"); printf(" --root [DIR]\t Set root directory\n"); printf(" --mapping \t Output coordinates and radius for mapping backgrounds\n"); + printf(" --audiodev [NAME] \t Audio device name to use\n"); exit(0); } } |