Search
lxdream.org :: lxdream :: r531:f0fee3ba71d1
lxdream 0.9.1
released Jun 29
Download Now
changeset531:f0fee3ba71d1
parent530:28bdc62e642a
child532:43653e748030
authornkeynes
dateMon Nov 19 08:47:39 2007 +0000 (12 years ago)
Move name-to-driver mappings to display.c and audio.c respectively
Move responsibility for invoking texcache_gl_init() to the driver
src/aica/audio.c
src/aica/audio.h
src/display.c
src/display.h
src/drivers/video_x11.c
src/main.c
1.1 --- a/src/aica/audio.c Mon Nov 19 08:46:30 2007 +0000
1.2 +++ b/src/aica/audio.c Mon Nov 19 08:47:39 2007 +0000
1.3 @@ -24,6 +24,13 @@
1.4 #include <assert.h>
1.5 #include <string.h>
1.6
1.7 +audio_driver_t audio_driver_list[] = {
1.8 +#ifdef HAVE_ESOUND
1.9 + &audio_esd_driver,
1.10 +#endif
1.11 + &audio_null_driver,
1.12 + NULL };
1.13 +
1.14 #define NUM_BUFFERS 3
1.15 #define MS_PER_BUFFER 100
1.16
1.17 @@ -61,6 +68,21 @@
1.18 return (read == AUDIO_CHANNEL_COUNT ? 0 : -1 );
1.19 }
1.20
1.21 +audio_driver_t get_audio_driver_by_name( const char *name )
1.22 +{
1.23 + int i;
1.24 + if( name == NULL ) {
1.25 + return audio_driver_list[0];
1.26 + }
1.27 + for( i=0; audio_driver_list[i] != NULL; i++ ) {
1.28 + if( strcasecmp( audio_driver_list[i]->name, name ) == 0 ) {
1.29 + return audio_driver_list[i];
1.30 + }
1.31 + }
1.32 +
1.33 + return NULL;
1.34 +}
1.35 +
1.36 /**
1.37 * Set the output driver, sample rate and format. Also initializes the
1.38 * output buffers, flushing any current data and reallocating as
2.1 --- a/src/aica/audio.h Mon Nov 19 08:46:30 2007 +0000
2.2 +++ b/src/aica/audio.h Mon Nov 19 08:47:39 2007 +0000
2.3 @@ -75,6 +75,8 @@
2.4 extern struct audio_driver audio_null_driver;
2.5 extern struct audio_driver audio_esd_driver;
2.6
2.7 +audio_driver_t get_audio_driver_by_name( const char *name );
2.8 +
2.9 /**
2.10 * Set the output driver, sample rate and format. Also initializes the
2.11 * output buffers, flushing any current data and reallocating as
3.1 --- a/src/display.c Mon Nov 19 08:46:30 2007 +0000
3.2 +++ b/src/display.c Mon Nov 19 08:47:39 2007 +0000
3.3 @@ -24,6 +24,11 @@
3.4 #include "display.h"
3.5 #include "pvr2/pvr2.h"
3.6
3.7 +display_driver_t display_driver_list[] = {
3.8 + &display_gtk_driver,
3.9 + &display_null_driver,
3.10 + NULL };
3.11 +
3.12 typedef struct keymap_entry {
3.13 uint16_t keycode;
3.14 input_key_callback_t callback;
3.15 @@ -148,6 +153,20 @@
3.16 }
3.17 }
3.18
3.19 +display_driver_t get_display_driver_by_name( const char *name )
3.20 +{
3.21 + int i;
3.22 + if( name == NULL ) {
3.23 + return display_driver_list[0];
3.24 + }
3.25 + for( i=0; display_driver_list[i] != NULL; i++ ) {
3.26 + if( strcasecmp( display_driver_list[i]->name, name ) == 0 ) {
3.27 + return display_driver_list[i];
3.28 + }
3.29 + }
3.30 +
3.31 + return NULL;
3.32 +}
3.33
3.34
3.35 gboolean display_set_driver( display_driver_t driver )
3.36 @@ -159,8 +178,8 @@
3.37 display_driver = driver;
3.38 if( driver->init_driver != NULL )
3.39 rv = driver->init_driver();
3.40 - if( rv ) {
3.41 - texcache_gl_init();
3.42 + if( !rv ) {
3.43 + display_driver = NULL;
3.44 }
3.45 return rv;
3.46 }
4.1 --- a/src/display.h Mon Nov 19 08:46:30 2007 +0000
4.2 +++ b/src/display.h Mon Nov 19 08:47:39 2007 +0000
4.3 @@ -159,6 +159,7 @@
4.4
4.5 } *display_driver_t;
4.6
4.7 +display_driver_t get_display_driver_by_name( const char *name );
4.8 gboolean display_set_driver( display_driver_t driver );
4.9
4.10 extern uint32_t pvr2_frame_counter;
5.1 --- a/src/drivers/video_x11.c Mon Nov 19 08:46:30 2007 +0000
5.2 +++ b/src/drivers/video_x11.c Mon Nov 19 08:47:39 2007 +0000
5.3 @@ -19,6 +19,7 @@
5.4 #include <X11/Xlib.h>
5.5 #include <GL/glx.h>
5.6 #include "dream.h"
5.7 +#include "pvr2/pvr2.h"
5.8 #include "drivers/video_x11.h"
5.9 #include "drivers/gl_common.h"
5.10
5.11 @@ -167,6 +168,8 @@
5.12 return FALSE;
5.13 }
5.14 XFree(visual);
5.15 +
5.16 + texcache_gl_init();
5.17 return TRUE;
5.18 }
5.19
6.1 --- a/src/main.c Mon Nov 19 08:46:30 2007 +0000
6.2 +++ b/src/main.c Mon Nov 19 08:47:39 2007 +0000
6.3 @@ -4,8 +4,6 @@
6.4 * Main program, initializes dreamcast and gui, then passes control off to
6.5 * the gtk main loop (currently).
6.6 *
6.7 - * FIXME: Remove explicit GTK/Gnome references from this file
6.8 - *
6.9 * Copyright (c) 2005 Nathan Keynes.
6.10 *
6.11 * This program is free software; you can redistribute it and/or modify
6.12 @@ -41,8 +39,8 @@
6.13 char *aica_program = NULL;
6.14 char *s3m_file = NULL;
6.15 const char *disc_file = NULL;
6.16 -char *display_driver_name = "gtk";
6.17 -char *audio_driver_name = "esd";
6.18 +char *display_driver_name = NULL;
6.19 +char *audio_driver_name = NULL;
6.20 gboolean start_immediately = FALSE;
6.21 gboolean headless = FALSE;
6.22 gboolean without_bios = FALSE;
6.23 @@ -52,25 +50,18 @@
6.24 uint32_t time_nanos = 0;
6.25 extern uint32_t sh4_cpu_multiplier;
6.26
6.27 -audio_driver_t audio_driver_list[] = { &audio_null_driver,
6.28 - &audio_esd_driver,
6.29 - NULL };
6.30 -
6.31 -display_driver_t display_driver_list[] = { &display_null_driver,
6.32 - &display_gtk_driver,
6.33 - NULL };
6.34 -
6.35 int main (int argc, char *argv[])
6.36 {
6.37 int opt, i;
6.38 double t;
6.39 + gboolean display_ok;
6.40
6.41 install_crash_handler();
6.42 #ifdef ENABLE_NLS
6.43 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
6.44 textdomain (PACKAGE);
6.45 #endif
6.46 - gui_parse_cmdline(&argc, &argv);
6.47 + display_ok = gui_parse_cmdline(&argc, &argv);
6.48
6.49 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {
6.50 switch( opt ) {
6.51 @@ -140,17 +131,13 @@
6.52 dcload_install();
6.53 }
6.54
6.55 - for( i=0; audio_driver_list[i] != NULL; i++ ) {
6.56 - if( strcasecmp( audio_driver_list[i]->name, audio_driver_name ) == 0 ) {
6.57 - if( audio_set_driver( audio_driver_list[i], 44100, AUDIO_FMT_16ST ) == FALSE ) {
6.58 - audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
6.59 - }
6.60 - break;
6.61 - }
6.62 -
6.63 - }
6.64 - if( audio_driver_list[i] == NULL ) {
6.65 - ERROR( "Audio driver '%s' not found, using null driver", audio_driver_name );
6.66 + audio_driver_t audio_driver = get_audio_driver_by_name(audio_driver_name);
6.67 + if( audio_driver == NULL ) {
6.68 + ERROR( "Audio driver '%s' not found, aborting.", audio_driver_name );
6.69 + exit(2);
6.70 + } else if( audio_set_driver( audio_driver, 44100, AUDIO_FMT_16ST ) == FALSE ) {
6.71 + ERROR( "Failed to initialize audio driver '%s', using null driver",
6.72 + audio_driver->name );
6.73 audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
6.74 }
6.75
6.76 @@ -159,20 +146,14 @@
6.77 } else {
6.78 gui_init(show_debugger);
6.79
6.80 - gboolean initialized = FALSE;
6.81 - for( i=0; display_driver_list[i] != NULL; i++ ) {
6.82 - if( strcasecmp( display_driver_list[i]->name, display_driver_name ) == 0 ) {
6.83 - initialized = display_set_driver( display_driver_list[i] );
6.84 - break;
6.85 - }
6.86 - }
6.87 - if( !initialized ) {
6.88 - if( display_driver_list[i] == NULL ) {
6.89 - ERROR( "Video driver '%s' not found, using null driver", display_driver_name );
6.90 - } else {
6.91 - ERROR( "Video driver '%s' failed to initialize, falling back to null driver", display_driver_name );
6.92 - }
6.93 - display_set_driver( &display_null_driver );
6.94 + display_driver_t display_driver = get_display_driver_by_name(display_driver_name);
6.95 + if( display_driver == NULL ) {
6.96 + ERROR( "Video driver '%s' not found, aborting.", display_driver_name );
6.97 + exit(2);
6.98 + } else if( display_set_driver( display_driver ) == FALSE ) {
6.99 + ERROR( "Video driver '%s' failed to initialize (could not connect to display?)",
6.100 + display_driver->name );
6.101 + exit(2);
6.102 }
6.103 }
6.104
.