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

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

parent 921123fd
......@@ -87,6 +87,8 @@ int screen_InitCapture( demux_t *p_demux )
CGLPixelFormatObj pix;
GLint npix;
GLint viewport[4];
GLuint displayMask;
CGLError returnedError;
p_sys->p_data = p_data =
( screen_data_t * )malloc( sizeof( screen_data_t ) );
......@@ -96,12 +98,25 @@ int screen_InitCapture( demux_t *p_demux )
attribs[2] = CGDisplayIDToOpenGLDisplayMask( CGMainDisplayID() );
attribs[3] = 0;
CGLChoosePixelFormat( attribs, &pix, &npix );
CGLCreateContext( pix, NULL, &( p_data->screen ) );
CGLDestroyPixelFormat( pix );
returnedError = CGLChoosePixelFormat( attribs, &pix, &npix );
if (returnedError)
goto errorHandling;
CGLSetCurrentContext( p_data->screen );
CGLSetFullScreen( p_data->screen );
returnedError = CGLCreateContext( pix, NULL, &( 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 );
......@@ -124,15 +139,28 @@ int screen_InitCapture( demux_t *p_demux )
attribs [2] = 32;
attribs [3] = 0;
CGLChoosePixelFormat( attribs, &pix, &npix );
CGLCreateContext( pix, NULL, &( p_data->scaled ) );
CGLDestroyPixelFormat( pix );
returnedError = CGLChoosePixelFormat( attribs, &pix, &npix );
if (returnedError)
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->dest_height * 4 );
CGLSetOffScreen( p_data->scaled, p_data->dest_width, p_data->dest_height,
p_data->dest_width * 4, p_data->scaled_image );
#warning FIXME: CGLSetOffScreen is no longer supported in the future!
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 );
......@@ -164,6 +192,10 @@ int screen_InitCapture( demux_t *p_demux )
CGSNewConnection( NULL, &( p_data->connection ) );
return VLC_SUCCESS;
errorHandling:
msg_Err( p_demux, "Core OpenGL failure: %s", CGLErrorString( returnedError ) );
return VLC_EGENERIC;
}
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