mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-02-16 10:30:47 +00:00
98 lines
2.5 KiB
C
98 lines
2.5 KiB
C
/*
|
|
* This file is part of Moonlight Embedded.
|
|
*
|
|
* Copyright (C) 2015 Iwan Timmer
|
|
*
|
|
* Moonlight is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Moonlight is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include "platform.h"
|
|
#include "audio.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <dlfcn.h>
|
|
|
|
typedef bool(*ImxInit)();
|
|
|
|
enum platform platform_check(char* name) {
|
|
bool std = strcmp(name, "default") == 0;
|
|
#ifdef HAVE_IMX
|
|
if (std || strcmp(name, "imx") == 0) {
|
|
void *handle = dlopen("libmoonlight-imx.so", RTLD_NOW | RTLD_GLOBAL);
|
|
ImxInit video_imx_init = (ImxInit) dlsym(RTLD_DEFAULT, "video_imx_init");
|
|
if (handle != NULL) {
|
|
if (video_imx_init())
|
|
return IMX;
|
|
}
|
|
}
|
|
#endif
|
|
#ifdef HAVE_PI
|
|
if (std || strcmp(name, "pi") == 0) {
|
|
void *handle = dlopen("libmoonlight-pi.so", RTLD_NOW | RTLD_GLOBAL);
|
|
if (handle != NULL && dlsym(RTLD_DEFAULT, "bcm_host_init") != NULL)
|
|
return PI;
|
|
}
|
|
#endif
|
|
#ifdef HAVE_SDL
|
|
if (std || strcmp(name, "sdl") == 0)
|
|
return SDL;
|
|
#endif
|
|
#ifdef HAVE_FAKE
|
|
if (std || strcmp(name, "fake") == 0)
|
|
return FAKE;
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) {
|
|
switch (system) {
|
|
#ifdef HAVE_SDL
|
|
case SDL:
|
|
return &decoder_callbacks_sdl;
|
|
#endif
|
|
#ifdef HAVE_IMX
|
|
case IMX:
|
|
return (PDECODER_RENDERER_CALLBACKS) dlsym(RTLD_DEFAULT, "decoder_callbacks_imx");
|
|
#endif
|
|
#ifdef HAVE_PI
|
|
case PI:
|
|
return (PDECODER_RENDERER_CALLBACKS) dlsym(RTLD_DEFAULT, "decoder_callbacks_pi");
|
|
#endif
|
|
#ifdef HAVE_FAKE
|
|
case FAKE:
|
|
return &decoder_callbacks_fake;
|
|
#endif
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system) {
|
|
switch (system) {
|
|
#ifdef HAVE_SDL
|
|
case SDL:
|
|
return &audio_callbacks_sdl;
|
|
#endif
|
|
default:
|
|
#ifdef HAVE_PULSE
|
|
return &audio_callbacks_pulse;
|
|
#endif
|
|
return &audio_callbacks_alsa;
|
|
}
|
|
return NULL;
|
|
}
|