1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

Kill uibc viewer subprocess

closes #93
This commit is contained in:
albfan 2016-07-16 12:26:40 +02:00
parent 42820c00ba
commit 3f2266e254
2 changed files with 24 additions and 13 deletions

View file

@ -1,8 +1,19 @@
#!/bin/bash #!/bin/bash
function kill_child() {
CHILDREN="$(ps -o pid= --ppid $$)"
echo killing $CHILDREN
kill $CHILDREN
}
IP=$1 IP=$1
shift shift
UIBC_PORT=$1 UIBC_PORT=$1
shift shift
gstplayer $@ | miracle-uibcctl $IP $UIBC_PORT --daemon echo $$
trap 'kill_child' SIGTERM
gstplayer $@ | miracle-uibcctl $IP $UIBC_PORT --daemon &
wait

View file

@ -58,7 +58,7 @@ int main(int argc, char *argv[]) {
if (buffer == NULL) { if (buffer == NULL) {
break; break;
} }
if (daemon) { if (!daemon) {
printf("input: %s", buffer); printf("input: %s", buffer);
} }
char type = buffer[0]; char type = buffer[0];
@ -68,7 +68,9 @@ int main(int argc, char *argv[]) {
} else if (type == '3' || type == '4') { } else if (type == '3' || type == '4') {
uibcmessage = buildUibcMessage(GENERIC_KEY_DOWN, buffer, 1, 1); uibcmessage = buildUibcMessage(GENERIC_KEY_DOWN, buffer, 1, 1);
} else { } else {
if (!daemon) {
printf("unknow event type: %s", buffer); printf("unknow event type: %s", buffer);
}
continue; continue;
} }
@ -86,8 +88,7 @@ const char *int2binary(int x, int padding)
{ {
char *b; char *b;
int min_padding = x > 0 ? floor(log2(x)) : 0; int min_padding = x > 0 ? floor(log2(x)) : 0;
if (padding < min_padding) if (padding < min_padding) {
{
padding = min_padding; padding = min_padding;
} }
@ -95,8 +96,7 @@ const char *int2binary(int x, int padding)
strcpy(b, ""); strcpy(b, "");
int z; int z;
for (z = pow(2,padding); z > 0; z >>= 1) for (z = pow(2,padding); z > 0; z >>= 1) {
{
strcat(b, ((x & z) == z) ? "1" : "0"); strcat(b, ((x & z) == z) ? "1" : "0");
} }