mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-24 00:56:42 +00:00
Allocate pipe only for EGL
This commit is contained in:
@@ -170,7 +170,7 @@ void egl_init(EGLNativeDisplayType native_display, NativeWindowType native_windo
|
|||||||
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
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) {
|
if (!current) {
|
||||||
eglMakeCurrent(display, surface, surface, context);
|
eglMakeCurrent(display, surface, surface, context);
|
||||||
current = True;
|
current = True;
|
||||||
|
|||||||
@@ -20,5 +20,5 @@
|
|||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
void egl_init(EGLNativeDisplayType native_display, NativeWindowType native_window, int display_width, int display_height);
|
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();
|
void egl_destroy();
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ static Display *display = NULL;
|
|||||||
static int pipefd[2];
|
static int pipefd[2];
|
||||||
|
|
||||||
static int frame_handle(int pipefd) {
|
static int frame_handle(int pipefd) {
|
||||||
const unsigned char** data = NULL;
|
AVFrame* frame = NULL;
|
||||||
while (read(pipefd, &data, sizeof(void*)) > 0);
|
while (read(pipefd, &frame, sizeof(void*)) > 0);
|
||||||
if (data)
|
if (frame)
|
||||||
egl_draw(data);
|
egl_draw(frame->data);
|
||||||
|
|
||||||
return LOOP_OK;
|
return LOOP_OK;
|
||||||
}
|
}
|
||||||
@@ -123,8 +123,15 @@ int x11_setup(int videoFormat, int width, int height, int redrawRate, void* cont
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ffmpeg_decoder == SOFTWARE)
|
if (ffmpeg_decoder == SOFTWARE) {
|
||||||
egl_init(display, window, width, height);
|
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
|
#ifdef HAVE_VDPAU
|
||||||
else if (ffmpeg_decoder == VDPAU)
|
else if (ffmpeg_decoder == VDPAU)
|
||||||
vdpau_init_presentation(window, width, height, display_width, display_height);
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,10 +163,9 @@ int x11_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
|||||||
ffmpeg_decode(ffmpeg_buffer, length);
|
ffmpeg_decode(ffmpeg_buffer, length);
|
||||||
AVFrame* frame = ffmpeg_get_frame(true);
|
AVFrame* frame = ffmpeg_get_frame(true);
|
||||||
if (frame != NULL) {
|
if (frame != NULL) {
|
||||||
if (ffmpeg_decoder == SOFTWARE) {
|
if (ffmpeg_decoder == SOFTWARE)
|
||||||
void* pointer = frame->data;
|
write(pipefd[1], &frame, sizeof(void*));
|
||||||
write(pipefd[1], &pointer, sizeof(void*));
|
else if (ffmpeg_decoder == VDPAU)
|
||||||
} else
|
|
||||||
vdpau_queue(frame);
|
vdpau_queue(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user