Search
lxdream.org :: lxdream :: r370:3131ba1440fc
lxdream 0.9.1
released Jun 29
Download Now
changeset370:3131ba1440fc
parent369:4b4223e7d720
child371:f2fe152cfc9b
authornkeynes
dateSat Sep 08 04:05:35 2007 +0000 (12 years ago)
Handle video driver init failure cleanly (fallback to headless)
Hookup shutdown for the GTK driver
src/display.c
src/display.h
src/drivers/video_gtk.c
src/drivers/video_x11.c
src/drivers/video_x11.h
src/main.c
1.1 --- a/src/display.c Sat Sep 08 03:12:21 2007 +0000
1.2 +++ b/src/display.c Sat Sep 08 04:05:35 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: display.c,v 1.7 2007-02-13 08:28:50 nkeynes Exp $
1.6 + * $Id: display.c,v 1.8 2007-09-08 04:05:35 nkeynes Exp $
1.7 *
1.8 * Generic support for keyboard and other input sources. The active display
1.9 * driver is expected to deliver events here, where they're translated and
1.10 @@ -144,13 +144,17 @@
1.11
1.12
1.13
1.14 -void display_set_driver( display_driver_t driver )
1.15 +gboolean display_set_driver( display_driver_t driver )
1.16 {
1.17 - if( display_driver != NULL && display_driver->shutdown_driver != NULL )
1.18 + gboolean rv = TRUE;
1.19 + if( display_driver != NULL && display_driver->shutdown_driver != NULL )
1.20 display_driver->shutdown_driver();
1.21
1.22 display_driver = driver;
1.23 if( driver->init_driver != NULL )
1.24 - driver->init_driver();
1.25 - texcache_gl_init();
1.26 + rv = driver->init_driver();
1.27 + if( rv ) {
1.28 + texcache_gl_init();
1.29 + }
1.30 + return rv;
1.31 }
2.1 --- a/src/display.h Sat Sep 08 03:12:21 2007 +0000
2.2 +++ b/src/display.h Sat Sep 08 04:05:35 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: display.h,v 1.5 2007-02-11 10:09:32 nkeynes Exp $
2.6 + * $Id: display.h,v 1.6 2007-09-08 04:05:35 nkeynes Exp $
2.7 *
2.8 * The PC side of the video support (responsible for actually displaying /
2.9 * rendering frames)
2.10 @@ -149,9 +149,7 @@
2.11
2.12 } *display_driver_t;
2.13
2.14 -void video_open( void );
2.15 -void video_update_frame( void );
2.16 -void video_update_size( int, int, int );
2.17 +gboolean display_set_driver( display_driver_t driver );
2.18
2.19 extern uint32_t pvr2_frame_counter;
2.20
3.1 --- a/src/drivers/video_gtk.c Sat Sep 08 03:12:21 2007 +0000
3.2 +++ b/src/drivers/video_gtk.c Sat Sep 08 04:05:35 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: video_gtk.c,v 1.10 2007-02-11 10:09:32 nkeynes Exp $
3.6 + * $Id: video_gtk.c,v 1.11 2007-09-08 04:05:35 nkeynes Exp $
3.7 *
3.8 * The PC side of the video support (responsible for actually displaying /
3.9 * rendering frames)
3.10 @@ -34,7 +34,7 @@
3.11 void video_gtk_shutdown();
3.12 uint16_t video_gtk_resolve_keysym( const gchar *keysym );
3.13
3.14 -struct display_driver display_gtk_driver = { "gtk", video_gtk_init, NULL,
3.15 +struct display_driver display_gtk_driver = { "gtk", video_gtk_init, video_gtk_shutdown,
3.16 video_gtk_resolve_keysym,
3.17 NULL, NULL, NULL, NULL, NULL, NULL, NULL };
3.18
3.19 @@ -84,16 +84,16 @@
3.20
3.21 gtk_window_set_default_size( video_win, video_width, video_height );
3.22
3.23 - video_glx_init( gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(video_win))),
3.24 + return video_glx_init( gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(video_win))),
3.25 gdk_x11_screen_get_xscreen( gtk_widget_get_screen(GTK_WIDGET(video_win))),
3.26 GDK_WINDOW_XWINDOW( GTK_WIDGET(video_win)->window ),
3.27 video_width, video_height, &display_gtk_driver );
3.28 - return TRUE;
3.29 }
3.30
3.31 void video_gtk_shutdown()
3.32 {
3.33 -
3.34 + video_glx_shutdown();
3.35 + gtk_widget_destroy( GTK_WIDGET(video_win) );
3.36
3.37 }
3.38
4.1 --- a/src/drivers/video_x11.c Sat Sep 08 03:12:21 2007 +0000
4.2 +++ b/src/drivers/video_x11.c Sat Sep 08 04:05:35 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: video_x11.c,v 1.12 2007-02-11 10:09:32 nkeynes Exp $
4.6 + * $Id: video_x11.c,v 1.13 2007-09-08 04:05:35 nkeynes Exp $
4.7 *
4.8 * Shared functions for all X11-based display drivers.
4.9 *
4.10 @@ -135,11 +135,18 @@
4.11 }
4.12 return TRUE;
4.13 }
4.14 +
4.15 void video_glx_shutdown()
4.16 {
4.17 - XDestroyWindow( video_x11_display, glx_window );
4.18 - XFreeColormap( video_x11_display, win_attrs.colormap );
4.19 - glXDestroyContext( video_x11_display, glx_context );
4.20 + if( glx_window != None ) {
4.21 + XDestroyWindow( video_x11_display, glx_window );
4.22 + XFreeColormap( video_x11_display, win_attrs.colormap );
4.23 + glx_window = None;
4.24 + }
4.25 + if( glx_context != NULL ) {
4.26 + glXDestroyContext( video_x11_display, glx_context );
4.27 + glx_context = NULL;
4.28 + }
4.29 }
4.30
4.31
5.1 --- a/src/drivers/video_x11.h Sat Sep 08 03:12:21 2007 +0000
5.2 +++ b/src/drivers/video_x11.h Sat Sep 08 04:05:35 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: video_x11.h,v 1.4 2007-02-11 10:09:32 nkeynes Exp $
5.6 + * $Id: video_x11.h,v 1.5 2007-09-08 04:05:35 nkeynes Exp $
5.7 *
5.8 * Parent for all X11 display drivers.
5.9 *
5.10 @@ -24,5 +24,5 @@
5.11
5.12 gboolean video_glx_init( Display *display, Screen *screen, Window window,
5.13 int width, int height, display_driver_t driver );
5.14 -
5.15 +void video_glx_shutdown();
5.16 #endif
6.1 --- a/src/main.c Sat Sep 08 03:12:21 2007 +0000
6.2 +++ b/src/main.c Sat Sep 08 04:05:35 2007 +0000
6.3 @@ -1,5 +1,5 @@
6.4 /**
6.5 - * $Id: main.c,v 1.20 2006-08-07 13:18:16 nkeynes Exp $
6.6 + * $Id: main.c,v 1.21 2007-09-08 04:05:35 nkeynes Exp $
6.7 *
6.8 * Main program, initializes dreamcast and gui, then passes control off to
6.9 * the gtk main loop (currently).
6.10 @@ -145,14 +145,19 @@
6.11 if( headless ) {
6.12 display_set_driver( &display_null_driver );
6.13 } else {
6.14 + gboolean initialized = FALSE;
6.15 for( i=0; display_driver_list[i] != NULL; i++ ) {
6.16 if( strcasecmp( display_driver_list[i]->name, display_driver_name ) == 0 ) {
6.17 - display_set_driver( display_driver_list[i] );
6.18 + initialized = display_set_driver( display_driver_list[i] );
6.19 break;
6.20 }
6.21 }
6.22 - if( display_driver_list[i] == NULL ) {
6.23 - ERROR( "Video driver '%s' not found, using null driver", display_driver_name );
6.24 + if( !initialized ) {
6.25 + if( display_driver_list[i] == NULL ) {
6.26 + ERROR( "Video driver '%s' not found, using null driver", display_driver_name );
6.27 + } else {
6.28 + ERROR( "Video driver '%s' failed to initialize, falling back to null driver", display_driver_name );
6.29 + }
6.30 display_set_driver( &display_null_driver );
6.31 }
6.32 }
.