filename | src/main.c |
changeset | 531:f0fee3ba71d1 |
prev | 495:4db4702b0778 |
next | 537:d924be49e192 |
author | nkeynes |
date | Mon Nov 19 08:47:39 2007 +0000 (14 years ago) |
permissions | -rw-r--r-- |
last change | Move name-to-driver mappings to display.c and audio.c respectively Move responsibility for invoking texcache_gl_init() to the driver |
file | annotate | diff | log | raw |
1.1 --- a/src/main.c Wed Nov 07 11:45:53 2007 +00001.2 +++ b/src/main.c Mon Nov 19 08:47:39 2007 +00001.3 @@ -4,8 +4,6 @@1.4 * Main program, initializes dreamcast and gui, then passes control off to1.5 * the gtk main loop (currently).1.6 *1.7 - * FIXME: Remove explicit GTK/Gnome references from this file1.8 - *1.9 * Copyright (c) 2005 Nathan Keynes.1.10 *1.11 * This program is free software; you can redistribute it and/or modify1.12 @@ -41,8 +39,8 @@1.13 char *aica_program = NULL;1.14 char *s3m_file = NULL;1.15 const char *disc_file = NULL;1.16 -char *display_driver_name = "gtk";1.17 -char *audio_driver_name = "esd";1.18 +char *display_driver_name = NULL;1.19 +char *audio_driver_name = NULL;1.20 gboolean start_immediately = FALSE;1.21 gboolean headless = FALSE;1.22 gboolean without_bios = FALSE;1.23 @@ -52,25 +50,18 @@1.24 uint32_t time_nanos = 0;1.25 extern uint32_t sh4_cpu_multiplier;1.27 -audio_driver_t audio_driver_list[] = { &audio_null_driver,1.28 - &audio_esd_driver,1.29 - NULL };1.30 -1.31 -display_driver_t display_driver_list[] = { &display_null_driver,1.32 - &display_gtk_driver,1.33 - NULL };1.34 -1.35 int main (int argc, char *argv[])1.36 {1.37 int opt, i;1.38 double t;1.39 + gboolean display_ok;1.41 install_crash_handler();1.42 #ifdef ENABLE_NLS1.43 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);1.44 textdomain (PACKAGE);1.45 #endif1.46 - gui_parse_cmdline(&argc, &argv);1.47 + display_ok = gui_parse_cmdline(&argc, &argv);1.49 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {1.50 switch( opt ) {1.51 @@ -140,17 +131,13 @@1.52 dcload_install();1.53 }1.55 - for( i=0; audio_driver_list[i] != NULL; i++ ) {1.56 - if( strcasecmp( audio_driver_list[i]->name, audio_driver_name ) == 0 ) {1.57 - if( audio_set_driver( audio_driver_list[i], 44100, AUDIO_FMT_16ST ) == FALSE ) {1.58 - audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );1.59 - }1.60 - break;1.61 - }1.62 -1.63 - }1.64 - if( audio_driver_list[i] == NULL ) {1.65 - ERROR( "Audio driver '%s' not found, using null driver", audio_driver_name );1.66 + audio_driver_t audio_driver = get_audio_driver_by_name(audio_driver_name);1.67 + if( audio_driver == NULL ) {1.68 + ERROR( "Audio driver '%s' not found, aborting.", audio_driver_name );1.69 + exit(2);1.70 + } else if( audio_set_driver( audio_driver, 44100, AUDIO_FMT_16ST ) == FALSE ) {1.71 + ERROR( "Failed to initialize audio driver '%s', using null driver",1.72 + audio_driver->name );1.73 audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );1.74 }1.76 @@ -159,20 +146,14 @@1.77 } else {1.78 gui_init(show_debugger);1.80 - gboolean initialized = FALSE;1.81 - for( i=0; display_driver_list[i] != NULL; i++ ) {1.82 - if( strcasecmp( display_driver_list[i]->name, display_driver_name ) == 0 ) {1.83 - initialized = display_set_driver( display_driver_list[i] );1.84 - break;1.85 - }1.86 - }1.87 - if( !initialized ) {1.88 - if( display_driver_list[i] == NULL ) {1.89 - ERROR( "Video driver '%s' not found, using null driver", display_driver_name );1.90 - } else {1.91 - ERROR( "Video driver '%s' failed to initialize, falling back to null driver", display_driver_name );1.92 - }1.93 - display_set_driver( &display_null_driver );1.94 + display_driver_t display_driver = get_display_driver_by_name(display_driver_name);1.95 + if( display_driver == NULL ) {1.96 + ERROR( "Video driver '%s' not found, aborting.", display_driver_name );1.97 + exit(2);1.98 + } else if( display_set_driver( display_driver ) == FALSE ) {1.99 + ERROR( "Video driver '%s' failed to initialize (could not connect to display?)",1.100 + display_driver->name );1.101 + exit(2);1.102 }1.103 }
.