Should work nicely.

This commit is contained in:
Themaister 2010-12-29 20:50:50 +01:00
parent 16d9abc8d4
commit 869d839eee
4 changed files with 92 additions and 4 deletions

View File

@ -11,26 +11,32 @@ LIBS = -lsamplerate $(libsnes)
ifeq ($(BUILD_RSOUND), 1)
OBJ += audio/rsound.o
LIBS += -lrsound
DEFINES += -DHAVE_RSOUND
endif
ifeq ($(BUILD_OSS), 1)
OBJ += audio/oss.o
DEFINES += -DHAVE_OSS
endif
ifeq ($(BUILD_ALSA), 1)
OBJ += audio/alsa.o
LIBS += -lasound
DEFINES += -DHAVE_ALSA
endif
ifeq ($(BUILD_ROAR), 1)
OBJ += audio/roar.o
LIBS += -lroar
DEFINES += -DHAVE_ROAR
endif
ifeq ($(BUILD_AL), 1)
OBJ += audio/openal.o
LIBS += -lopenal
DEFINES += -DHAVE_AL
endif
ifeq ($(BUILD_OPENGL), 1)
OBJ += gfx/gl.o
LIBS += -lglfw
DEFINES += -DHAVE_GL
endif
ifeq ($(BUILD_CG), 1)

View File

@ -40,8 +40,8 @@
////////////////////////
// Chooses which video and audio subsystem to use. Remember to update config.mk if you change these.
#define VIDEO_DRIVER VIDEO_GL
#define AUDIO_DRIVER AUDIO_ALSA
#define VIDEO_DEFAULT_DRIVER VIDEO_GL
#define AUDIO_DEFAULT_DRIVER AUDIO_ALSA
////////////////

View File

@ -21,7 +21,7 @@
#include <stdio.h>
#include <string.h>
static audio_driver_t audio_drivers[] = {
static const audio_driver_t *audio_drivers[] = {
#ifdef HAVE_ALSA
&audio_alsa,
#endif
@ -39,12 +39,39 @@ static audio_driver_t audio_drivers[] = {
#endif
};
static video_driver_t video_drivers[] = {
static const video_driver_t *video_drivers[] = {
#ifdef HAVE_GL
&video_gl,
#endif
};
static void find_audio_driver(void)
{
for (int i = 0; i < sizeof(audio_drivers) / sizeof(audio_driver_t*); i++)
{
if (strcasecmp(g_settings.audio.driver, audio_drivers[i]->ident) == 0)
{
driver.audio = audio_drivers[i];
return;
}
}
SSNES_ERR("Couldn't find any audio driver named \"%s\"\n", g_settings.audio.driver);
exit(1);
}
static void find_video_driver(void)
{
for (int i = 0; i < sizeof(video_drivers) / sizeof(video_driver_t*); i++)
{
if (strcasecmp(g_settings.video.driver, video_drivers[i]->ident) == 0)
{
driver.video = video_drivers[i];
return;
}
}
SSNES_ERR("Couldn't find any video driver named \"%s\"\n", g_settings.video.driver);
exit(1);
}
void init_drivers(void)
{
@ -66,6 +93,8 @@ void init_audio(void)
return;
}
find_audio_driver();
driver.audio_data = driver.audio->init(strlen(g_settings.audio.device) ? g_settings.audio.device : NULL, g_settings.audio.out_rate, g_settings.audio.latency);
if ( driver.audio_data == NULL )
g_extern.audio_active = false;
@ -98,6 +127,8 @@ void init_video_input(void)
{
int scale;
find_video_driver();
// We multiply scales with 2 to allow for hi-res games.
#if 0
#if VIDEO_FILTER == FILTER_NONE

View File

@ -8,6 +8,46 @@ struct settings g_settings;
static void set_defaults(void)
{
const char *def_video = NULL;
const char *def_audio = NULL;
switch (VIDEO_DEFAULT_DRIVER)
{
case VIDEO_GL:
def_video = "glfw";
break;
default:
break;
}
switch (AUDIO_DEFAULT_DRIVER)
{
case AUDIO_RSOUND:
def_audio = "rsound";
break;
case AUDIO_OSS:
def_audio = "oss";
break;
case AUDIO_ALSA:
def_audio = "alsa";
break;
case AUDIO_ROAR:
def_audio = "roar";
break;
case AUDIO_AL:
def_audio = "openal";
break;
default:
break;
}
// No input atm ... It is in the GLFW driver.
if (def_video)
strncpy(g_settings.video.driver, def_video, sizeof(g_settings.video.driver) - 1);
if (def_audio)
strncpy(g_settings.audio.driver, def_audio, sizeof(g_settings.audio.driver) - 1);
g_settings.video.xscale = xscale;
g_settings.video.yscale = yscale;
g_settings.video.fullscreen = fullscreen;
@ -140,6 +180,17 @@ void parse_config(void)
g_settings.audio.src_quality = quals[tmp_int];
}
if (config_get_string(conf, "video_driver", &tmp_str))
{
strncpy(g_settings.video.driver, tmp_str, sizeof(g_settings.video.driver) - 1);
free(tmp_str);
}
if (config_get_string(conf, "audio_driver", &tmp_str))
{
strncpy(g_settings.audio.driver, tmp_str, sizeof(g_settings.audio.driver) - 1);
free(tmp_str);
}
// TODO: Keybinds.
config_file_free(conf);