Close properly from VLC

This commit is contained in:
Et0h 2014-06-02 20:27:53 +01:00
parent 97a499a34a
commit e23609edf5
2 changed files with 82 additions and 68 deletions

View File

@ -5,7 +5,7 @@
Principal author: Etoh Principal author: Etoh
Other contributors: DerGenaue, jb Other contributors: DerGenaue, jb
Project: http://syncplay.pl/ Project: http://syncplay.pl/
Version: 0.2.0 Version: 0.2.1
Note: Note:
* This interface module is intended to be used in conjunction with Syncplay. * This interface module is intended to be used in conjunction with Syncplay.
@ -86,9 +86,10 @@ else
require "common" require "common"
end end
local connectorversion = "0.2.0" local connectorversion = "0.2.1"
local durationdelay = 500000 -- Pause for get_duration command etc for increased reliability (uses microseconds) local durationdelay = 500000 -- Pause for get_duration command etc for increased reliability (uses microseconds)
local loopsleepduration = 5000 -- Pause for every event loop (uses microseconds) local loopsleepduration = 5000 -- Pause for every event loop (uses microseconds)
local quitcheckfrequency = 20 -- Check whether VLC has closed every X loops
local host = "localhost" local host = "localhost"
local port local port
@ -480,8 +481,9 @@ end
while running == true do while running == true do
--accept new connections and select active clients --accept new connections and select active clients
local fd = l:accept() local quitcheckcounter = 0
local buffer, inputbuffer, responsebuffer = "", "", "" local fd = l:accept()
local buffer, inputbuffer, responsebuffer = ""
while fd >= 0 and running == true do while fd >= 0 and running == true do
-- handle read mode -- handle read mode
@ -532,6 +534,18 @@ while running == true do
end end
vlc.misc.mwait(vlc.misc.mdate() + loopsleepduration) -- Don't waste processor time vlc.misc.mwait(vlc.misc.mdate() + loopsleepduration) -- Don't waste processor time
-- check if VLC has been closed
quitcheckcounter = quitcheckcounter + 1
if quitcheckcounter > quitcheckfrequency then
if vlc.volume.get() == -256 then
running = false
end
quitcheckcounter = 0
end
end end
end end

View File

@ -43,7 +43,7 @@ COMMANDS_ROOM = ["r", "room"]
COMMANDS_HELP = ['help', 'h', '?', '/?', r'\?'] COMMANDS_HELP = ['help', 'h', '?', '/?', r'\?']
MPC_MIN_VER = "1.6.4" MPC_MIN_VER = "1.6.4"
VLC_MIN_VERSION = "2.0.0" VLC_MIN_VERSION = "2.0.0"
VLC_INTERFACE_MIN_VERSION = "0.2.0" VLC_INTERFACE_MIN_VERSION = "0.2.1"
MPC_PATHS = [ MPC_PATHS = [
r"C:\Program Files (x86)\MPC-HC\mpc-hc.exe", r"C:\Program Files (x86)\MPC-HC\mpc-hc.exe",
r"C:\Program Files\MPC-HC\mpc-hc.exe", r"C:\Program Files\MPC-HC\mpc-hc.exe",