mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
Fix Thread locking for softhddrm Version with placebo
This commit is contained in:
parent
7f054f8320
commit
4837f7fa35
@ -1263,7 +1263,8 @@ bool cOglCmdDrawImage::Execute(void) {
|
||||
GLuint texture;
|
||||
|
||||
#ifdef USE_DRM
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
//esyslog("upload Image\n");
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
GlxDrawopengl(); // here we need the Shared Context for upload
|
||||
GlxCheck();
|
||||
#endif
|
||||
@ -1276,10 +1277,10 @@ bool cOglCmdDrawImage::Execute(void) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glFlush();
|
||||
#ifdef USE_DRM
|
||||
#ifdef USE_DRM
|
||||
GlxInitopengl(); // Reset Context
|
||||
GlxCheck();
|
||||
// pthread_mutex_unlock(&OSDMutex);
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
#endif
|
||||
|
||||
GLfloat x1 = x; // left
|
||||
@ -1369,7 +1370,8 @@ cOglCmdStoreImage::~cOglCmdStoreImage(void) { free(data); }
|
||||
|
||||
bool cOglCmdStoreImage::Execute(void) {
|
||||
#ifdef USE_DRM
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
return false;
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
GlxDrawopengl(); // here we need the Shared Context for upload
|
||||
GlxCheck();
|
||||
#endif
|
||||
@ -1386,7 +1388,7 @@ bool cOglCmdStoreImage::Execute(void) {
|
||||
#ifdef USE_DRM
|
||||
GlxInitopengl(); // Reset Context
|
||||
GlxCheck();
|
||||
// pthread_mutex_lock(&OSDMutex);
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@ -1466,7 +1468,9 @@ int cOglThread::StoreImage(const cImage &image) {
|
||||
if (!maxCacheSize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_DRM
|
||||
return 0;
|
||||
#endif
|
||||
if (image.Width() > maxTextureSize || image.Height() > maxTextureSize) {
|
||||
esyslog("[softhddev] cannot store image of %dpx x %dpx "
|
||||
"(maximum size is %dpx x %dpx) - falling back to "
|
||||
@ -1646,6 +1650,7 @@ void cOglThread::Action(void) {
|
||||
|
||||
bool cOglThread::InitOpenGL(void) {
|
||||
#ifdef USE_DRM
|
||||
esyslog("InitOpenGL\n");
|
||||
GlxInitopengl();
|
||||
#else
|
||||
const char *displayName = X11DisplayName;
|
||||
@ -1657,7 +1662,7 @@ bool cOglThread::InitOpenGL(void) {
|
||||
}
|
||||
}
|
||||
|
||||
dsyslog("[softhddev]OpenGL using display %s", displayName);
|
||||
esyslog("[softhddev]OpenGL using display %s", displayName);
|
||||
|
||||
int argc = 3;
|
||||
char *buffer[3];
|
||||
|
33
video.c
33
video.c
@ -464,7 +464,7 @@ extern void AudioVideoReady(int64_t); ///< tell audio video is ready
|
||||
static pthread_t VideoThread; ///< video decode thread
|
||||
static pthread_cond_t VideoWakeupCond; ///< wakeup condition variable
|
||||
static pthread_mutex_t VideoMutex; ///< video condition mutex
|
||||
static pthread_mutex_t VideoLockMutex; ///< video lock mutex
|
||||
pthread_mutex_t VideoLockMutex; ///< video lock mutex
|
||||
pthread_mutex_t OSDMutex; ///< OSD update mutex
|
||||
#endif
|
||||
|
||||
@ -825,6 +825,8 @@ static uint64_t test_time = 0;
|
||||
#define Lock_and_SharedContext \
|
||||
{ \
|
||||
VideoThreadLock(); \
|
||||
Debug(4,"Lock OSDMutex %s %d\n",__FILE__, __LINE__); \
|
||||
pthread_mutex_lock(&OSDMutex); \
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext); \
|
||||
EglCheck(); \
|
||||
}
|
||||
@ -832,10 +834,14 @@ static uint64_t test_time = 0;
|
||||
{ \
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); \
|
||||
EglCheck(); \
|
||||
Debug(4,"UnLock OSDMutex %s %d\n",__FILE__, __LINE__); \
|
||||
pthread_mutex_unlock(&OSDMutex); \
|
||||
VideoThreadUnlock(); \
|
||||
}
|
||||
#define SharedContext \
|
||||
{ \
|
||||
Debug(4,"Lock OSDMutex %s %d\n",__FILE__, __LINE__); \
|
||||
pthread_mutex_lock(&OSDMutex); \
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext); \
|
||||
EglCheck(); \
|
||||
}
|
||||
@ -843,6 +849,8 @@ static uint64_t test_time = 0;
|
||||
{ \
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); \
|
||||
EglCheck(); \
|
||||
Debug(4,"UnLock OSDMutex %s %d\n",__FILE__, __LINE__); \
|
||||
pthread_mutex_unlock(&OSDMutex); \
|
||||
}
|
||||
#else
|
||||
#ifdef PLACEBO
|
||||
@ -2576,7 +2584,7 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame
|
||||
// vaSyncSurface(decoder->VaDisplay, (VASurfaceID) (uintptr_t)
|
||||
// frame->data[3]);
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);
|
||||
EglCheck();
|
||||
|
||||
@ -2612,6 +2620,7 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
EglCheck();
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
return;
|
||||
|
||||
esh_failed:
|
||||
@ -2620,6 +2629,7 @@ esh_failed:
|
||||
close(desc.objects[n].fd);
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
EglCheck();
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -4410,8 +4420,9 @@ static void CuvidDisplayFrame(void) {
|
||||
}
|
||||
valid_frame = 1;
|
||||
#ifdef PLACEBO
|
||||
//pthread_mutex_lock(&OSDMutex);
|
||||
if (OsdShown == 1) { // New OSD opened
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
|
||||
make_osd_overlay(OSDx, OSDy, OSDxsize, OSDysize);
|
||||
if (posd) {
|
||||
pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){
|
||||
@ -4425,7 +4436,7 @@ static void CuvidDisplayFrame(void) {
|
||||
});
|
||||
}
|
||||
OsdShown = 2;
|
||||
pthread_mutex_unlock(&OSDMutex);
|
||||
|
||||
}
|
||||
|
||||
if (OsdShown == 2) {
|
||||
@ -4433,7 +4444,7 @@ static void CuvidDisplayFrame(void) {
|
||||
} else {
|
||||
CuvidMixVideo(decoder, i, &target, NULL);
|
||||
}
|
||||
|
||||
//pthread_mutex_unlock(&OSDMutex);
|
||||
#else
|
||||
CuvidMixVideo(decoder, i);
|
||||
#endif
|
||||
@ -4518,7 +4529,11 @@ static void CuvidDisplayFrame(void) {
|
||||
Fatal(_("Failed to submit swapchain buffer\n"));
|
||||
VideoThreadUnlock();
|
||||
pl_swapchain_swap_buffers(p->swapchain); // swap buffers
|
||||
NoContext;
|
||||
#ifdef PLACEBO_GL
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
EglCheck();
|
||||
#endif
|
||||
|
||||
|
||||
#else // not PLACEBO
|
||||
#ifdef CUVID
|
||||
@ -7267,16 +7282,16 @@ int GlxInitopengl() {
|
||||
if (!eglOSDContext) {
|
||||
EglCheck();
|
||||
Fatal(_("video/egl: can't create thread egl context\n"));
|
||||
return NULL;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglOSDContext);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GlxDrawopengl() {
|
||||
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GlxDestroy() {
|
||||
|
Loading…
Reference in New Issue
Block a user