Commit c161298d authored by Felix Paul Kühne's avatar Felix Paul Kühne

screen: added error handling to prevent this module from failing silently

parent 2dc88a48
...@@ -87,6 +87,8 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -87,6 +87,8 @@ int screen_InitCapture( demux_t *p_demux )
CGLPixelFormatObj pix; CGLPixelFormatObj pix;
GLint npix; GLint npix;
GLint viewport[4]; GLint viewport[4];
GLuint displayMask;
CGLError returnedError;
p_sys->p_data = p_data = p_sys->p_data = p_data =
( screen_data_t * )malloc( sizeof( screen_data_t ) ); ( screen_data_t * )malloc( sizeof( screen_data_t ) );
...@@ -96,12 +98,25 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -96,12 +98,25 @@ int screen_InitCapture( demux_t *p_demux )
attribs[2] = CGDisplayIDToOpenGLDisplayMask( CGMainDisplayID() ); attribs[2] = CGDisplayIDToOpenGLDisplayMask( CGMainDisplayID() );
attribs[3] = 0; attribs[3] = 0;
CGLChoosePixelFormat( attribs, &pix, &npix ); returnedError = CGLChoosePixelFormat( attribs, &pix, &npix );
CGLCreateContext( pix, NULL, &( p_data->screen ) ); if (returnedError)
CGLDestroyPixelFormat( pix ); goto errorHandling;
CGLSetCurrentContext( p_data->screen ); returnedError = CGLCreateContext( pix, NULL, &( p_data->screen ) );
CGLSetFullScreen( p_data->screen ); if (returnedError)
goto errorHandling;
returnedError = CGLDestroyPixelFormat( pix );
if (returnedError)
goto errorHandling;
returnedError = CGLSetCurrentContext( p_data->screen );
if (returnedError)
goto errorHandling;
returnedError = CGLSetFullScreen( p_data->screen );
if (returnedError)
goto errorHandling;
glGetIntegerv( GL_VIEWPORT, viewport ); glGetIntegerv( GL_VIEWPORT, viewport );
...@@ -124,15 +139,28 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -124,15 +139,28 @@ int screen_InitCapture( demux_t *p_demux )
attribs [2] = 32; attribs [2] = 32;
attribs [3] = 0; attribs [3] = 0;
CGLChoosePixelFormat( attribs, &pix, &npix ); returnedError = CGLChoosePixelFormat( attribs, &pix, &npix );
CGLCreateContext( pix, NULL, &( p_data->scaled ) ); if (returnedError)
CGLDestroyPixelFormat( pix ); goto errorHandling;
returnedError = CGLCreateContext( pix, NULL, &( p_data->scaled ) );
if (returnedError)
goto errorHandling;
returnedError = CGLDestroyPixelFormat( pix );
if (returnedError)
goto errorHandling;
returnedError = CGLSetCurrentContext( p_data->scaled );
if (returnedError)
goto errorHandling;
CGLSetCurrentContext( p_data->scaled );
p_data->scaled_image = ( char * )malloc( p_data->dest_width p_data->scaled_image = ( char * )malloc( p_data->dest_width
* p_data->dest_height * 4 ); * p_data->dest_height * 4 );
CGLSetOffScreen( p_data->scaled, p_data->dest_width, p_data->dest_height, #warning FIXME: CGLSetOffScreen is no longer supported in the future!
p_data->dest_width * 4, p_data->scaled_image ); returnedError = CGLSetOffScreen( p_data->scaled, p_data->dest_width, p_data->dest_height, p_data->dest_width * 4, p_data->scaled_image );
if (returnedError)
goto errorHandling;
es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_RGB32 ); es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_RGB32 );
...@@ -164,6 +192,10 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -164,6 +192,10 @@ int screen_InitCapture( demux_t *p_demux )
CGSNewConnection( NULL, &( p_data->connection ) ); CGSNewConnection( NULL, &( p_data->connection ) );
return VLC_SUCCESS; return VLC_SUCCESS;
errorHandling:
msg_Err( p_demux, "Core OpenGL failure: %s", CGLErrorString( returnedError ) );
return VLC_EGENERIC;
} }
int screen_CloseCapture( demux_t *p_demux ) int screen_CloseCapture( demux_t *p_demux )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment