Seperate main loop for SDL

This commit is contained in:
Iwan Timmer 2015-07-12 13:43:01 +02:00
parent 2945c13181
commit 676f39e197
4 changed files with 85 additions and 9 deletions

View File

@ -24,6 +24,7 @@
#include "audio.h" #include "audio.h"
#include "discover.h" #include "discover.h"
#include "platform.h" #include "platform.h"
#include "sdl.h"
#include "input/evdev.h" #include "input/evdev.h"
#include "input/udev.h" #include "input/udev.h"
@ -71,14 +72,14 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
client_start_app(config, address, appId, sops, localaudio); client_start_app(config, address, appId, sops, localaudio);
evdev_init();
#ifdef HAVE_LIBCEC
cec_init();
#endif /* HAVE_LIBCEC */
LiStartConnection(address, config, &connection_callbacks, platform_get_video(system), &audio_callbacks, NULL, NULL, 0, client_get_server_version()); LiStartConnection(address, config, &connection_callbacks, platform_get_video(system), &audio_callbacks, NULL, NULL, 0, client_get_server_version());
if (IS_EMBEDDED(system))
loop_main(); loop_main();
#ifdef HAVE_SDL
else if (system == SDL)
sdl_loop();
#endif
LiStopConnection(); LiStopConnection();
} }
@ -303,11 +304,18 @@ int main(int argc, char* argv[]) {
pair_check(); pair_check();
applist(address); applist(address);
} else if (strcmp("stream", action) == 0) { } else if (strcmp("stream", action) == 0) {
udev_init(autoadd, mapping);
pair_check(); pair_check();
if (IS_EMBEDDED(system)) {
for (int i=0;i<inputsCount;i++) for (int i=0;i<inputsCount;i++)
evdev_create(inputs[i].path, inputs[i].mapping); evdev_create(inputs[i].path, inputs[i].mapping);
udev_init(autoadd, mapping);
evdev_init();
#ifdef HAVE_LIBCEC
cec_init();
#endif /* HAVE_LIBCEC */
}
stream(&config, address, app, sops, localaudio, system); stream(&config, address, app, sops, localaudio, system);
} else if (strcmp("pair", action) == 0) } else if (strcmp("pair", action) == 0)
client_pair(address); client_pair(address);

View File

@ -19,7 +19,13 @@
#include "limelight-common/Limelight.h" #include "limelight-common/Limelight.h"
#define IS_EMBEDDED(SYSTEM) SYSTEM != SDL
enum platform { SDL, OMX, IMX, FAKE }; enum platform { SDL, OMX, IMX, FAKE };
enum platform platform_check(char*); enum platform platform_check(char*);
DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system); DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system);
#ifdef HAVE_SDL
void sdl_loop();
#endif

38
src/sdl.c Normal file
View File

@ -0,0 +1,38 @@
/*
* 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/>.
*/
#ifdef HAVE_SDL
#include <stdbool.h>
#include <SDL.h>
static bool done;
void sdl_loop() {
SDL_Event event;
while(!done && SDL_WaitEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
done = true;
}
}
}
#endif /* HAVE_SDL */

24
src/sdl.h Normal file
View File

@ -0,0 +1,24 @@
/*
* 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/>.
*/
#ifdef HAVE_SDL
void sdl_loop();
#endif /* HAVE_SDL */