Page 1 of 1

problems with callback

Posted: 26 Mar 2013 12:14
by perquin
Hi,

I try to make a player with something like a "watch folder".

To refresh the list i write a callback find in this forum:
callback=false

Code: Select all

function input_callback(action) -- action=add/del/toggle if (action=="toggle" and callback==false) then action="add" elseif (action=="toggle" and callback==true) then action="del" end local input = vlc.object.input() vlc.msg.dbg("valeur input : "..input) if input and callback==false and action=="add" then callback=true vlc.var.add_callback(input, "intf-event", input_events_handler, "Hello world!") elseif input and callback==true and action=="del" then callback=false vlc.var.del_callback(input, "intf-event", input_events_handler, "Hello world!") end end
it work well when i launch.

My problem is when the playlist start to read a new file(or loop), i stop my function. I have added this two functions:

Code: Select all

function input_changed() vlc.msg.dbg("000000000000000000000000000000000000000000000000000") input_callback("toggle") end
and

Code: Select all

function meta_changed() vlc.msg.dbg("111111111111111111111111111111111111111") input_callback("toggle") end
but none are fired

testing in 2.0.5 mac osx.

Can some one help me?
I'm new in lua scrip and find any doc about callback.

Regards,

Philippe

Re: problems with callback

Posted: 26 Mar 2013 15:13
by mederi
Here I played a bit with it:

Code: Select all

flag="" function descriptor() return { title = "test callbacking", -- capabilities = {"menu", "input-listener", "meta-listener", "playing-listener"} capabilities = {"input-listener"} } end function input_changed() vlc.msg.info("--- input_changed --- BEGIN") vlc.msg.info(flag) input_callback("toggle") vlc.msg.info(flag) vlc.msg.info("--- input_changed --- END") end function meta_changed() vlc.msg.info("... meta_changed ...") --input_callback("toggle") end function activate() input_callback("add") end function deactivate() input_callback("del") end ------------------------------- callback=false function input_callback(action) -- action=add/del/toggle flag="action=\""..action.."\"" if (action=="toggle" and callback==false) then action="add" elseif (action=="toggle" and callback==true) then action="del" end local input = vlc.object.input() vlc.msg.info("valeur input : "..tostring(input)) flag=flag.." & action=\""..action.."\" / input="..tostring(input).." / " if input and callback==false and action=="add" then callback=true vlc.var.add_callback(input, "intf-event", input_events_handler, "Hello world!") elseif input and callback==true and action=="del" then callback=false vlc.var.del_callback(input, "intf-event", input_events_handler, "Hello world!") end end function input_events_handler(var, old, new, data) -- Actually you probably do not need to hadle input ivents here. -- You would like to do something periodically using this callback function. vlc.msg.info("Callback function: "..os.clock()) end
You can watch behaviour logs in messages window with verbosity 0.
I am not telling you that this way it is 100% correct, but it works very well within my first VLC Extension: Time

Here is another interpretation: viewtopic.php?f=29&t=98295#p341634

I was thinking of implementation of some kinds of locking of actual iteration to prevent possible collision with following iteration. I do not know if I am right in this.

Re: problems with callback

Posted: 26 Mar 2013 15:54
by perquin
hi mederi,

Can you explain me how to remove "main warning", "main debug" and other in the messages windows?

Regards,

Re: problems with callback

Posted: 26 Mar 2013 16:48
by perquin
Hi,

I test your with a playlist that have two files and it seem to be the same problem, when the file change it break the callback without fire input_changed or meta_changed.

At the change there is:
main debug:dead input
main debug : changing item without a request

and after this, no more trace of the lua code. if i relaunch the extension i have a the lua:..END..

I'm on a mac with mac osx 10.7.5

Regards,

Re: problems with callback

Posted: 26 Mar 2013 22:03
by mederi
Image

Here is my log:

Code: Select all

lua info: valeur input : nil lua info: --- input_changed --- BEGIN lua info: action="add" & action="add" / input=nil / lua info: valeur input : userdata: 01A013F0 lua info: action="toggle" & action="add" / input=userdata: 01A013F0 / lua info: --- input_changed --- END lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: Callback function: 2053.953 lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2054.023 lua info: Callback function: 2054.293 lua info: Callback function: 2054.293 lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.354 lua info: Callback function: 2054.364 lua info: Callback function: 2054.364 lua info: Callback function: 2054.364 lua info: Callback function: 2054.364 lua info: Callback function: 2054.364 lua info: Callback function: 2054.364 lua info: Callback function: 2054.374 lua info: Callback function: 2054.374 lua info: Callback function: 2054.374 lua info: Callback function: 2054.374 lua info: Callback function: 2054.374 lua info: Callback function: 2054.374 lua info: ... meta_changed ... lua info: Callback function: 2054.534 lua info: Callback function: 2054.574 lua info: Callback function: 2054.714 lua info: Callback function: 2054.714 lua info: Callback function: 2054.754 lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2054.964 lua info: Callback function: 2055.235 lua info: Callback function: 2055.365 lua info: Callback function: 2055.485 lua info: Callback function: 2055.736 lua info: Callback function: 2055.986 lua info: Callback function: 2056.256 lua info: Callback function: 2056.386 lua info: Callback function: 2056.537 lua info: Callback function: 2056.807 lua info: Callback function: 2057.087 lua info: Callback function: 2057.338 lua info: Callback function: 2057.388 lua info: Callback function: 2057.588 lua info: Callback function: 2057.839 lua info: Callback function: 2058.089 lua info: Callback function: 2058.359 lua info: Callback function: 2058.389 lua info: Callback function: 2058.64 lua info: Callback function: 2058.91 lua info: Callback function: 2059.18 lua info: Callback function: 2059.231 lua info: Callback function: 2059.241 lua info: Callback function: 2059.251 lua info: Callback function: 2059.421 lua info: Callback function: 2059.431 lua info: Callback function: 2059.451 lua info: Callback function: 2059.461 lua info: Callback function: 2059.461 lua info: Callback function: 2059.461 lua info: Callback function: 2059.461 lua info: ... meta_changed ... lua info: --- input_changed --- BEGIN lua info: action="toggle" & action="add" / input=userdata: 01A013F0 / lua info: valeur input : userdata: 0198B1D0 lua info: action="toggle" & action="del" / input=userdata: 0198B1D0 / lua info: --- input_changed --- END lua info: --- input_changed --- BEGIN lua info: action="toggle" & action="del" / input=userdata: 0198B1D0 / lua info: valeur input : userdata: 0198EDF0 lua info: action="toggle" & action="add" / input=userdata: 0198EDF0 / lua info: --- input_changed --- END lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2059.521 lua info: Callback function: 2059.521 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.591 lua info: Callback function: 2059.821 lua info: Callback function: 2059.821 lua info: Callback function: 2059.901 lua info: Callback function: 2059.901 lua info: Callback function: 2059.922 lua info: Callback function: 2059.922 lua info: Callback function: 2059.922 lua info: Callback function: 2059.922 lua info: Callback function: 2059.982 lua info: Callback function: 2059.982 lua info: Callback function: 2059.982 lua info: Callback function: 2059.982 lua info: Callback function: 2059.982 lua info: Callback function: 2059.992 lua info: Callback function: 2059.992 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.002 lua info: Callback function: 2060.102 lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2060.222 lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2060.322 lua info: Callback function: 2060.322 lua info: Callback function: 2060.352 lua info: ... meta_changed ... lua info: Callback function: 2060.592 lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: ... meta_changed ... lua info: Callback function: 2060.843 lua info: Callback function: 2061.023 lua info: Callback function: 2061.093 lua info: Callback function: 2061.374 lua info: Callback function: 2061.644 lua info: Callback function: 2061.894 lua info: Callback function: 2062.025 lua info: Callback function: 2062.175 lua info: Callback function: 2062.445 lua info: Callback function: 2062.696 lua info: Callback function: 2062.976 lua info: Callback function: 2063.046 lua info: Callback function: 2063.246 lua info: Callback function: 2063.527 lua info: Callback function: 2063.787 lua info: Callback function: 2064.047 lua info: Callback function: 2064.057 lua info: Callback function: 2064.248 lua info: Callback function: 2064.268 lua info: Callback function: 2064.278 lua info: Callback function: 2064.358 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: Callback function: 2064.368 lua info: ... meta_changed ... lua info: --- input_changed --- BEGIN lua info: action="toggle" & action="add" / input=userdata: 0198EDF0 / lua info: valeur input : userdata: 05F0AD38 lua info: action="toggle" & action="del" / input=userdata: 05F0AD38 / lua info: --- input_changed --- END
1.) activate extension
2.) Play the first film in the playlist
3.) press Next to play next film in the playlist
4.) press Stop
Interesting is, that meta_changed( ) is active even without "meta-listener" in capabilities in descriptor( ). Then callback function input_events_handler( ) is called several times in the same time while meta_changed( ) is acting.

If you cannot get something similar on your Mac OSX, then it is quite different from Windows and Linux. You cannot even create a custom dialog box in Lua extension on Mac.

Re: problems with callback

Posted: 27 Mar 2013 09:45
by perquin
Hi,

I just test your code under windows and osx.

Windows, it's working else when changing clip with a meta_changed() and input_changed()
osx, same code not working nothing is fired when the clip chane.

It's an osx bug.

Really thank for your help. I can finish my code under windows, i have the chance that it will be the target os.

Regards,

Re: problems with callback

Posted: 02 Oct 2016 20:21
by brozikcz
Hi,

is the bug still actual on macOS?