Clean up properly if preinit() fails.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14930 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
syrjala 2005-03-07 22:45:47 +00:00
parent 883b0fad3e
commit 0046a87017
1 changed files with 16 additions and 2 deletions

View File

@ -224,6 +224,8 @@ get_layer_by_name( DFBDisplayLayerID id,
return DFENUM_OK; return DFENUM_OK;
} }
static void uninit( void );
static uint32_t static uint32_t
preinit( const char *arg ) preinit( const char *arg )
{ {
@ -425,11 +427,13 @@ preinit( const char *arg )
if (l.res != DFB_OK) { if (l.res != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get primary layer - %s\n", mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get primary layer - %s\n",
DirectFBErrorString( l.res ) ); DirectFBErrorString( l.res ) );
uninit();
return -1; return -1;
} }
if ((res = primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE )) != DFB_OK) { if ((res = primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE )) != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to primary layer - %s\n", mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to primary layer - %s\n",
DirectFBErrorString( res ) ); DirectFBErrorString( res ) );
uninit();
return -1; return -1;
} }
use_input = 1; use_input = 1;
@ -451,11 +455,13 @@ preinit( const char *arg )
if (l.res != DFB_OK) { if (l.res != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR, "Can't get BES layer - %s\n", mp_msg( MSGT_VO, MSGL_ERR, "Can't get BES layer - %s\n",
DirectFBErrorString( l.res ) ); DirectFBErrorString( l.res ) );
uninit();
return -1; return -1;
} }
if ((res = bes->SetCooperativeLevel( bes, DLSCL_EXCLUSIVE )) != DFB_OK) { if ((res = bes->SetCooperativeLevel( bes, DLSCL_EXCLUSIVE )) != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to BES - %s\n", mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to BES - %s\n",
DirectFBErrorString( res ) ); DirectFBErrorString( res ) );
uninit();
return -1; return -1;
} }
dlc.flags = DLCONF_PIXELFORMAT; dlc.flags = DLCONF_PIXELFORMAT;
@ -481,11 +487,13 @@ preinit( const char *arg )
if (l.res != DFB_OK) { if (l.res != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR, "Can't get CRTC2 layer - %s\n", mp_msg( MSGT_VO, MSGL_ERR, "Can't get CRTC2 layer - %s\n",
DirectFBErrorString( l.res ) ); DirectFBErrorString( l.res ) );
uninit();
return -1; return -1;
} }
if ((res = crtc2->SetCooperativeLevel( crtc2, DLSCL_EXCLUSIVE )) != DFB_OK) { if ((res = crtc2->SetCooperativeLevel( crtc2, DLSCL_EXCLUSIVE )) != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to CRTC2 - %s\n", mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to CRTC2 - %s\n",
DirectFBErrorString( res ) ); DirectFBErrorString( res ) );
uninit();
return -1; return -1;
} }
} }
@ -495,10 +503,16 @@ preinit( const char *arg )
mp_msg( MSGT_VO, MSGL_ERR, mp_msg( MSGT_VO, MSGL_ERR,
"vo_dfbmga: Can't get keyboard - %s\n", "vo_dfbmga: Can't get keyboard - %s\n",
DirectFBErrorString( res ) ); DirectFBErrorString( res ) );
uninit();
return -1;
}
if ((res = keyboard->CreateEventBuffer( keyboard, &buffer )) != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR,
"vo_dfbmga: Can't create event buffer - %s\n",
DirectFBErrorString( res ) );
uninit();
return -1; return -1;
} }
keyboard->CreateEventBuffer( keyboard, &buffer );
buffer->Reset( buffer );
} }
return 0; return 0;