fixed deadlock in PIP

This commit is contained in:
jojo61 2018-10-05 11:09:55 +02:00
parent c1e5659d35
commit e3d0ccba9a
1 changed files with 44 additions and 40 deletions

12
video.c
View File

@ -1764,8 +1764,6 @@ static void CuvidDestroySurfaces(CuvidDecoder * decoder)
glXMakeCurrent(XlibDisplay, VideoWindow, GlxContext);
GlxCheck();
glDeleteBuffers(1,(GLuint *)&vao_buffer);
if (decoder->cuda_ctx) {
checkCudaErrors(cuCtxPushCurrent(decoder->cuda_ctx));
for (i=0;i<decoder->SurfacesNeeded;i++) {
@ -1778,9 +1776,14 @@ static void CuvidDestroySurfaces(CuvidDecoder * decoder)
glDeleteTextures(CODEC_SURFACES_MAX*2,(GLuint*)&decoder->gl_textures);
GlxCheck();
if (decoder == CuvidDecoders[0]) { // only wenn last decoder closes
Debug(3,"Last decoder closes\n");
glDeleteBuffers(1,(GLuint *)&vao_buffer);
if (gl_prog)
glDeleteProgram(gl_prog);
gl_prog = 0;
}
for (i = 0; i < decoder->SurfaceFreeN; ++i) {
decoder->SurfacesFree[i] = -1;
@ -1978,13 +1981,14 @@ static void CuvidDelHwDecoder(CuvidDecoder * decoder)
{
int i,n;
Debug(3,"cuvid del hw decoder cuda_ctx %p\n",decoder->cuda_ctx);
pthread_mutex_lock(&VideoLockMutex);
// pthread_mutex_lock(&VideoLockMutex);
glXMakeCurrent(XlibDisplay, VideoWindow, GlxSharedContext);
GlxCheck();
if (decoder->SurfaceFreeN || decoder->SurfaceUsedN) {
CuvidDestroySurfaces(decoder);
}
pthread_mutex_unlock(&VideoLockMutex);
// pthread_mutex_unlock(&VideoLockMutex);
#if 0
if (decoder->cuda_ctx) {
cuCtxDestroy (decoder->cuda_ctx);