From 25e388fab0b2b3ae1c4bdfceee202b426efcace9 Mon Sep 17 00:00:00 2001 From: Johns Date: Sat, 16 Feb 2013 19:47:59 +0100 Subject: Stop/kill external player. --- player.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/player.c b/player.c index fac99be..fd02dff 100644 --- a/player.c +++ b/player.c @@ -620,6 +620,37 @@ void PlayerStop(void) { PlayerThreadExit(); + // + // stop mplayer, if it is still running. + // + if (PlayerIsRunning()) { + int waittime; + int timeout; + + waittime = 0; + timeout = 500; // 0.5s + + kill(PlayerPid, SIGTERM); + // wait for player finishing, with timeout + while (PlayerIsRunning() && waittime++ < timeout) { + usleep(1 * 1000); + } + if (PlayerIsRunning()) { // still running + waittime = 0; + timeout = 500; // 0.5s + + kill(PlayerPid, SIGKILL); + // wait for player finishing, with timeout + while (PlayerIsRunning() && waittime++ < timeout) { + usleep(1 * 1000); + } + if (PlayerIsRunning()) { + Error(_("play: can't stop player\n")); + } + } + } + PlayerPid = 0; + if (ConfigOsdOverlay) { DisableDummyDevice(); VideoExit(); -- cgit v1.2.3