forked from len0rd/rockbox
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
This commit is contained in:
parent
b3dac27aa6
commit
65d94ecd08
2 changed files with 32 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue