Foobar as a UPnP renderer (player |
This forum is for developer discussions only. If you have a problem / bug report / idea / feature request that isn't related to foobar2000 SDK, post it in an appropiate forum instead - tech support questions go to support forum, everything else goes to general forum.
All non-developer posts on this forum will be removed. Continued abuse of this forum will result in admin actions (warnings, account suspension).
![]() ![]() |
Foobar as a UPnP renderer (player |
Jan 2 2009, 20:57
Post
#26
|
|
|
Group: Members Posts: 60 Joined: 10-December 08 Member No.: 64276 |
Now I need to know what functions to call:
to add filename to playlist to play the file pause stop get file position ifo during playback and set the seek postiion Can anyone help with this? Darren |
|
|
|
Jan 2 2009, 22:07
Post
#27
|
|
|
Group: Members Posts: 60 Joined: 10-December 08 Member No.: 64276 |
Can I do that from the UPnP code that is now running in another thread? Yes.If I include the foobar.h header on the upnp.c i get the 100+ errors report. Because including C++ code from C file won't work. You will need to convert upnp.c to C++.I tried invoking a foobar play command in the thread that is running the UPnP stack. I get an error that the command must be run in the original thread. How can I do that? Thank you Darren Getting to the home stretch on this! (although my try to rewrite it later more colsly assoc. with Foobar2000) This post has been edited by Wadsbrau: Jan 2 2009, 22:14 |
|
|
|
Jan 2 2009, 22:33
Post
#28
|
|
![]() Group: FB2K Moderator Posts: 2359 Joined: 30-November 07 Member No.: 49158 |
Use main_thread_callback.
ETA: Sorry about that previous statement, it should have been rather "yes, unless the command can be called from the main thread only". Not all API functions have to. This post has been edited by Yirkha: Jan 2 2009, 22:55 -------------------- Full-quoting makes you scroll past the same junk over and over.
|
|
|
|
Jan 2 2009, 23:10
Post
#29
|
|
|
Group: Members Posts: 60 Joined: 10-December 08 Member No.: 64276 |
Thank you! Could you please give me an example of using the main_thread_callback in conjunction with the play command? Please?
Darren This post has been edited by Wadsbrau: Jan 6 2009, 00:06 |
|
|
|
Jan 2 2009, 23:59
Post
#30
|
|
![]() Group: FB2K Moderator Posts: 2359 Joined: 30-November 07 Member No.: 49158 |
Depends on where you want to use it. If it's from an existing class, you can simply derive from main_thread_callback and provide its service interface. I assume you want to plug it into existing C code instead, so I'd use a helper class for delegation like this (not guaranteed to be 100% correct, I'm writing it out of my head only):
CODE class PlayAction : public main_thread_callback { Note I didn't know what "play command" you really had had in mind, but I used playback_control::start() as to show how to pass any arguments.protected: playback_control::t_track_command m_command; bool m_paused; public: PlayAction(playback_control::t_track_command p_command = playback_control::track_command_play, bool p_paused = false) : m_command(p_command), m_paused(p_paused) { } virtual void callback_run() { static_api_ptr_t<playback_control> pc; pc->start(m_command, m_paused); } }; // ... void on_command_play() { static_api_ptr_t<main_thread_callback_manager> mtcm; mtcm->add_callback(new service_impl_t<PlayAction>(playback_control::track_command_play)); } Anyway, this is a generic example. If you are going to support several commands, creating such class for each of them might be unnecessarily complex. In that case, it might be better to have just one class, encompassing interface for more commands at once, which will then invoke different methods in its callback_run() depending on what has been set. Or have most of the logic in the class itself and pass only the original events into it. There are many solutions as always, use the one which suits you best. This post has been edited by Yirkha: Jan 3 2009, 00:01 -------------------- Full-quoting makes you scroll past the same junk over and over.
|
|
|
|
Jan 3 2009, 01:54
Post
#31
|
|
|
Group: Members Posts: 60 Joined: 10-December 08 Member No.: 64276 |
I am figuring this out. Still having a little trouble. Is there a way to access the main_thread_callback for only one instance of one command? What would the code look like for that? (instead of creating a class)
Thank you Darren This post has been edited by Wadsbrau: Jan 6 2009, 16:59 |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd May 2013 - 06:43 |