Initialize video in same thread as decoding

This commit is contained in:
Iwan Timmer 2015-08-16 20:58:09 +02:00
parent 8442e50bb8
commit 26661f7ea1
2 changed files with 22 additions and 18 deletions

View File

@ -37,12 +37,6 @@ void sdl_init(int width, int height) {
exit(1); exit(1);
} }
sdl_window = SDL_CreateWindow("Moonlight", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, 0);
if(!sdl_window) {
fprintf(stderr, "SDL: could not create window - exiting\n");
exit(1);
}
SDL_SetRelativeMouseMode(SDL_TRUE);
sdlinput_init(); sdlinput_init();
} }

View File

@ -45,18 +45,8 @@ static void sdl_setup(int width, int height, int redrawRate, void* context, int
exit(1); exit(1);
} }
SDL_Window *window = (SDL_Window*) context; screen_width = width;
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); screen_height = height;
if (!renderer) {
fprintf(stderr, "SDL: could not create renderer - exiting\n");
exit(1);
}
bmp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_TARGET, width, height);
if (!bmp) {
fprintf(stderr, "SDL: could not create texture - exiting\n");
exit(1);
}
} }
static void sdl_cleanup() { static void sdl_cleanup() {
@ -64,6 +54,26 @@ static void sdl_cleanup() {
} }
static int sdl_submit_decode_unit(PDECODE_UNIT decodeUnit) { static int sdl_submit_decode_unit(PDECODE_UNIT decodeUnit) {
if (window == NULL) {
window = SDL_CreateWindow("Moonlight", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width, screen_height, SDL_WINDOW_OPENGL);
if(!window) {
fprintf(stderr, "SDL: could not create window - exiting\n");
exit(1);
}
SDL_SetRelativeMouseMode(SDL_TRUE);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (!renderer) {
printf("SDL_CreateRenderer failed: %s\n", SDL_GetError());
exit(1);
}
bmp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
if (!bmp) {
fprintf(stderr, "SDL: could not create texture - exiting\n");
exit(1);
}
}
if (decodeUnit->fullLength < DECODER_BUFFER_SIZE) { if (decodeUnit->fullLength < DECODER_BUFFER_SIZE) {
PLENTRY entry = decodeUnit->bufferList; PLENTRY entry = decodeUnit->bufferList;
int length = 0; int length = 0;