diff --git a/src/main.c b/src/main.c
index bfc3538..9c03646 100644
--- a/src/main.c
+++ b/src/main.c
@@ -109,6 +109,8 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
drFlags |= FORCE_HARDWARE_ACCELERATION;
printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate);
+
+ platform_start(system);
LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system), NULL, drFlags);
if (IS_EMBEDDED(system)) {
@@ -122,6 +124,7 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
#endif
LiStopConnection();
+ platform_stop(system);
}
static void help() {
diff --git a/src/platform.c b/src/platform.c
index 404eb7d..01cb4d7 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -21,6 +21,8 @@
#include "platform.h"
+#include "util.h"
+
#include "audio/audio.h"
#include "video/video.h"
@@ -71,6 +73,38 @@ enum platform platform_check(char* name) {
return 0;
}
+void platform_start(enum platform system) {
+ switch (system) {
+ #ifdef HAVE_AML
+ case AML:
+ blank_fb("/sys/class/graphics/fb0/blank", true);
+ blank_fb("/sys/class/graphics/fb1/blank", true);
+ break;
+ #endif
+ #ifdef HAVE_PI
+ case PI:
+ blank_fb("/sys/class/graphics/fb0/blank", true);
+ break;
+ #endif
+ }
+}
+
+void platform_stop(enum platform system) {
+ switch (system) {
+ #ifdef HAVE_AML
+ case AML:
+ blank_fb("/sys/class/graphics/fb0/blank", false);
+ blank_fb("/sys/class/graphics/fb1/blank", false);
+ break;
+ #endif
+ #ifdef HAVE_PI
+ case PI:
+ blank_fb("/sys/class/graphics/fb0/blank", false);
+ break;
+ #endif
+ }
+}
+
DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) {
switch (system) {
#ifdef HAVE_X11
diff --git a/src/platform.h b/src/platform.h
index c271834..642f8e8 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -32,3 +32,6 @@ enum platform platform_check(char*);
PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system);
PAUDIO_RENDERER_CALLBACKS platform_get_audio(enum platform system);
bool platform_supports_hevc(enum platform system);
+
+void platform_start(enum platform system);
+void platform_stop(enum platform system);
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 0000000..79b79c8
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,39 @@
+/*
+ * This file is part of Moonlight Embedded.
+ *
+ * Copyright (C) 2017 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 .
+ */
+
+#include "util.h"
+
+#include
+#include
+#include
+#include
+
+int blank_fb(char *path, bool clear) {
+ int fd = open(path, O_RDWR);
+
+ if(fd >= 0) {
+ int ret = write(fd, clear ? "1" : "0", 1);
+ if (ret < 0)
+ fprintf(stderr, "Failed to clear framebuffer %s: %d\n", path, ret);
+
+ close(fd);
+ return 0;
+ } else
+ return -1;
+}
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..7e6541c
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,22 @@
+/*
+ * This file is part of Moonlight Embedded.
+ *
+ * Copyright (C) 2017 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 .
+ */
+
+#include
+
+int blank_fb(char *path, bool clear);
diff --git a/src/video/aml.c b/src/video/aml.c
index 6015977..90139f6 100755
--- a/src/video/aml.c
+++ b/src/video/aml.c
@@ -35,29 +35,7 @@
static codec_para_t codecParam = { 0 };
-static int osd_blank(char *path,int cmd) {
- int fd;
- char bcmd[16];
-
- fd = open(path, O_CREAT|O_RDWR | O_TRUNC, 0644);
-
- if(fd>=0) {
- sprintf(bcmd,"%d",cmd);
- int ret = write(fd,bcmd,strlen(bcmd));
- if (ret < 0) {
- printf("osd_blank error during write: %x\n", ret);
- }
- close(fd);
- return 0;
- }
-
- return -1;
-}
-
int aml_setup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) {
- osd_blank("/sys/class/graphics/fb0/blank",1);
- osd_blank("/sys/class/graphics/fb1/blank",0);
-
codecParam.stream_type = STREAM_TYPE_ES_VIDEO;
codecParam.has_video = 1;
codecParam.noblock = 0;
@@ -108,9 +86,7 @@ int aml_setup(int videoFormat, int width, int height, int redrawRate, void* cont
}
void aml_cleanup() {
- int api = codec_close(&codecParam);
- osd_blank("/sys/class/graphics/fb0/blank",0);
- osd_blank("/sys/class/graphics/fb1/blank",0);
+ codec_close(&codecParam);
}
int aml_submit_decode_unit(PDECODE_UNIT decodeUnit) {