summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2011-09-02 01:34:07 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2011-09-02 01:34:07 +0000
commit5965cf014f23624ddb13020f01d1df25970d36ae (patch)
tree365e3ede1c77343897e07f67ae46aa11e856a778 /legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
parentacda54440efd2921987c49aa91f6963e5d707b96 (diff)
emotion/generic/vlc: die when parent dies.
nasty fix for a nasty emotion behavior :-/ SVN revision: 63080
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
index 773bbe9b7a..a9b8fd72ae 100644
--- a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
+++ b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
@@ -14,6 +14,9 @@
14#include <pthread.h> 14#include <pthread.h>
15#include <poll.h> 15#include <poll.h>
16 16
17#include <sys/prctl.h>
18#include <signal.h>
19
17#include <vlc/vlc.h> 20#include <vlc/vlc.h>
18#include <Emotion_Generic_Plugin.h> 21#include <Emotion_Generic_Plugin.h>
19 22
@@ -616,7 +619,7 @@ main(int argc, const char *argv[])
616{ 619{
617 struct _App app; 620 struct _App app;
618 Emotion_Generic_Video_Shared *vs; 621 Emotion_Generic_Video_Shared *vs;
619 struct pollfd fds[2]; // watching on 2 file descriptors 622 struct pollfd fds[3];
620 int tpipe[2]; // pipe for comunicating events from threads 623 int tpipe[2]; // pipe for comunicating events from threads
621 char shmname[256]; 624 char shmname[256];
622 char cwidth[64], cheight[64], cpitch[64], chroma[64]; 625 char cwidth[64], cheight[64], cpitch[64], chroma[64];
@@ -642,6 +645,17 @@ main(int argc, const char *argv[])
642 snprintf(cpitch, sizeof(cpitch), "%d", DEFAULTWIDTH * 4); 645 snprintf(cpitch, sizeof(cpitch), "%d", DEFAULTWIDTH * 4);
643 snprintf(chroma, sizeof(chroma), "RV32"); 646 snprintf(chroma, sizeof(chroma), "RV32");
644 647
648 /*
649 * Naughty xattr in emotion uses ecore_thread to run its thing, this
650 * may leave emotion's reference count high and it won't kill us...
651 * letting us play the video in the background. not good.
652 *
653 * prctl(PR_SET_PDEATHSIG) is a linux only thing. Need to find ways
654 * to do it on other platforms. Until then leave it breaking on
655 * such platforms so people port it instead of ignoring.
656 */
657 prctl(PR_SET_PDEATHSIG, SIGHUP);
658
645 app.libvlc = libvlc_new(vlc_argc, vlc_argv); 659 app.libvlc = libvlc_new(vlc_argc, vlc_argv);
646 app.mp = NULL; 660 app.mp = NULL;
647 app.filename = NULL; 661 app.filename = NULL;
@@ -672,24 +686,43 @@ main(int argc, const char *argv[])
672 fds[0].events = POLLIN; 686 fds[0].events = POLLIN;
673 fds[1].fd = app.fd_read; 687 fds[1].fd = app.fd_read;
674 fds[1].events = POLLIN; 688 fds[1].events = POLLIN;
689 fds[2].fd = STDERR_FILENO;
690 fds[2].events = 0;
675 691
676 while (1) 692 while (1)
677 { 693 {
678 int r; 694 int r;
679 695
680 r = poll(fds, 2, 30); 696 r = poll(fds, 3, -1);
681 if (r == 0) 697 if (r == 0)
682 continue; 698 continue;
683 else if (r < 0) 699 else if (r < 0)
684 { 700 {
685 fprintf(stderr, "an error ocurred on poll().\n"); 701 fprintf(stderr,
702 "emotion_generic_vlc: an error ocurred on poll(): %s\n",
703 strerror(errno));
686 break; 704 break;
687 } 705 }
688 706
707 if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))
708 {
709 fputs("emotion_generic_vlc: error communicating with stdin\n",
710 stderr);
711 break;
712 }
713 if (fds[1].revents & (POLLERR | POLLHUP | POLLNVAL))
714 {
715 fputs("emotion_generic_vlc: error communicating with thread\n",
716 stderr);
717 break;
718 }
719
689 if (fds[0].revents & POLLIN) 720 if (fds[0].revents & POLLIN)
690 _process_emotion_commands(&app); 721 _process_emotion_commands(&app);
691 if (fds[1].revents & POLLIN) 722 if (fds[1].revents & POLLIN)
692 _process_thread_events(&app); 723 _process_thread_events(&app);
724 if (fds[2].revents & (POLLERR | POLLHUP | POLLNVAL))
725 break;
693 } 726 }
694 727
695 libvlc_release(app.libvlc); 728 libvlc_release(app.libvlc);