comparison libvo/vo_dfbmga.c @ 14929:3febdb2983e0

Clean up properly if preinit() fails.
author syrjala
date Mon, 07 Mar 2005 22:45:47 +0000
parents 7b2abc34b737
children 05aa13cdf92f
comparison
equal deleted inserted replaced
14928:35e2d178be91 14929:3febdb2983e0
221 return DFENUM_CANCEL; 221 return DFENUM_CANCEL;
222 #endif 222 #endif
223 223
224 return DFENUM_OK; 224 return DFENUM_OK;
225 } 225 }
226
227 static void uninit( void );
226 228
227 static uint32_t 229 static uint32_t
228 preinit( const char *arg ) 230 preinit( const char *arg )
229 { 231 {
230 DFBResult res; 232 DFBResult res;
423 }; 425 };
424 dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l ); 426 dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );
425 if (l.res != DFB_OK) { 427 if (l.res != DFB_OK) {
426 mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get primary layer - %s\n", 428 mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get primary layer - %s\n",
427 DirectFBErrorString( l.res ) ); 429 DirectFBErrorString( l.res ) );
430 uninit();
428 return -1; 431 return -1;
429 } 432 }
430 if ((res = primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE )) != DFB_OK) { 433 if ((res = primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE )) != DFB_OK) {
431 mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to primary layer - %s\n", 434 mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to primary layer - %s\n",
432 DirectFBErrorString( res ) ); 435 DirectFBErrorString( res ) );
436 uninit();
433 return -1; 437 return -1;
434 } 438 }
435 use_input = 1; 439 use_input = 1;
436 } 440 }
437 441
449 453
450 dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l ); 454 dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );
451 if (l.res != DFB_OK) { 455 if (l.res != DFB_OK) {
452 mp_msg( MSGT_VO, MSGL_ERR, "Can't get BES layer - %s\n", 456 mp_msg( MSGT_VO, MSGL_ERR, "Can't get BES layer - %s\n",
453 DirectFBErrorString( l.res ) ); 457 DirectFBErrorString( l.res ) );
458 uninit();
454 return -1; 459 return -1;
455 } 460 }
456 if ((res = bes->SetCooperativeLevel( bes, DLSCL_EXCLUSIVE )) != DFB_OK) { 461 if ((res = bes->SetCooperativeLevel( bes, DLSCL_EXCLUSIVE )) != DFB_OK) {
457 mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to BES - %s\n", 462 mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to BES - %s\n",
458 DirectFBErrorString( res ) ); 463 DirectFBErrorString( res ) );
464 uninit();
459 return -1; 465 return -1;
460 } 466 }
461 dlc.flags = DLCONF_PIXELFORMAT; 467 dlc.flags = DLCONF_PIXELFORMAT;
462 dlc.pixelformat = DSPF_RGB16; 468 dlc.pixelformat = DSPF_RGB16;
463 if (bes->TestConfiguration( bes, &dlc, &failed ) != DFB_OK) { 469 if (bes->TestConfiguration( bes, &dlc, &failed ) != DFB_OK) {
479 485
480 dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l ); 486 dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );
481 if (l.res != DFB_OK) { 487 if (l.res != DFB_OK) {
482 mp_msg( MSGT_VO, MSGL_ERR, "Can't get CRTC2 layer - %s\n", 488 mp_msg( MSGT_VO, MSGL_ERR, "Can't get CRTC2 layer - %s\n",
483 DirectFBErrorString( l.res ) ); 489 DirectFBErrorString( l.res ) );
490 uninit();
484 return -1; 491 return -1;
485 } 492 }
486 if ((res = crtc2->SetCooperativeLevel( crtc2, DLSCL_EXCLUSIVE )) != DFB_OK) { 493 if ((res = crtc2->SetCooperativeLevel( crtc2, DLSCL_EXCLUSIVE )) != DFB_OK) {
487 mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to CRTC2 - %s\n", 494 mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to CRTC2 - %s\n",
488 DirectFBErrorString( res ) ); 495 DirectFBErrorString( res ) );
496 uninit();
489 return -1; 497 return -1;
490 } 498 }
491 } 499 }
492 500
493 if (use_input) { 501 if (use_input) {
494 if ((res = dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard )) != DFB_OK) { 502 if ((res = dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard )) != DFB_OK) {
495 mp_msg( MSGT_VO, MSGL_ERR, 503 mp_msg( MSGT_VO, MSGL_ERR,
496 "vo_dfbmga: Can't get keyboard - %s\n", 504 "vo_dfbmga: Can't get keyboard - %s\n",
497 DirectFBErrorString( res ) ); 505 DirectFBErrorString( res ) );
498 return -1; 506 uninit();
499 } 507 return -1;
500 keyboard->CreateEventBuffer( keyboard, &buffer ); 508 }
501 buffer->Reset( buffer ); 509 if ((res = keyboard->CreateEventBuffer( keyboard, &buffer )) != DFB_OK) {
510 mp_msg( MSGT_VO, MSGL_ERR,
511 "vo_dfbmga: Can't create event buffer - %s\n",
512 DirectFBErrorString( res ) );
513 uninit();
514 return -1;
515 }
502 } 516 }
503 517
504 return 0; 518 return 0;
505 } 519 }
506 520