Allocate pipe only for EGL

This commit is contained in:
Iwan Timmer
2017-06-10 20:48:17 +02:00
parent 0ea71fc635
commit ae54a30ea0
3 changed files with 17 additions and 18 deletions

View File

@@ -170,7 +170,7 @@ void egl_init(EGLNativeDisplayType native_display, NativeWindowType native_windo
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
void egl_draw(const uint8_t* image[3]) {
void egl_draw(uint8_t* image[3]) {
if (!current) {
eglMakeCurrent(display, surface, surface, context);
current = True;

View File

@@ -20,5 +20,5 @@
#include <EGL/egl.h>
void egl_init(EGLNativeDisplayType native_display, NativeWindowType native_window, int display_width, int display_height);
void egl_draw(const uint8_t* image[3]);
void egl_draw(uint8_t* image[3]);
void egl_destroy();

View File

@@ -44,10 +44,10 @@ static Display *display = NULL;
static int pipefd[2];
static int frame_handle(int pipefd) {
const unsigned char** data = NULL;
while (read(pipefd, &data, sizeof(void*)) > 0);
if (data)
egl_draw(data);
AVFrame* frame = NULL;
while (read(pipefd, &frame, sizeof(void*)) > 0);
if (frame)
egl_draw(frame->data);
return LOOP_OK;
}
@@ -123,8 +123,15 @@ int x11_setup(int videoFormat, int width, int height, int redrawRate, void* cont
return -1;
}
if (ffmpeg_decoder == SOFTWARE)
if (ffmpeg_decoder == SOFTWARE) {
egl_init(display, window, width, height);
if (pipe(pipefd) == -1) {
fprintf(stderr, "Can't create communication channel between threads\n");
return -2;
}
loop_add_fd(pipefd[0], &frame_handle, POLLIN);
fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
}
#ifdef HAVE_VDPAU
else if (ffmpeg_decoder == VDPAU)
vdpau_init_presentation(window, width, height, display_width, display_height);
@@ -132,13 +139,6 @@ int x11_setup(int videoFormat, int width, int height, int redrawRate, void* cont
x11_input_init(display, window);
if (pipe(pipefd) == -1) {
fprintf(stderr, "Can't create communication channel between threads\n");
return -2;
}
loop_add_fd(pipefd[0], &frame_handle, POLLIN);
fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
return 0;
}
@@ -163,10 +163,9 @@ int x11_submit_decode_unit(PDECODE_UNIT decodeUnit) {
ffmpeg_decode(ffmpeg_buffer, length);
AVFrame* frame = ffmpeg_get_frame(true);
if (frame != NULL) {
if (ffmpeg_decoder == SOFTWARE) {
void* pointer = frame->data;
write(pipefd[1], &pointer, sizeof(void*));
} else
if (ffmpeg_decoder == SOFTWARE)
write(pipefd[1], &frame, sizeof(void*));
else if (ffmpeg_decoder == VDPAU)
vdpau_queue(frame);
}
}