Help - Search - Members - Calendar
Full Version: pause and stop a threaded_process_callback
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
blimey
hey there,

I'm writing a plugin to log playback data (basically played songs) and that's working pretty well, but i'd like to do something like audioscrobbler, meaning log only after a number of seconds have been played (e.g. 30 seconds). My idea would be to spawn a thread for this.
What i haven't found is a way to pause the thread (or get it to wait for an event, or stop it for that matter).
Is there a way to do this with code? i guess "sending" an abort_callback would do the trick.
Is there another easy way to create threads and control them in a more "normal" way?

thanks
blimey
okay, a threaded_process_callback pops up a dialog, not good for this.
how does one usually handle threads the user doesn't necessarily have to know about?
or, is there a way to not show the dialog?

also, to signal stop/pause of the thread i used the old ugly and problematic way of using flags settable from the "outside", if there's a cleaner way i'm all for it.

thanks
foosion
QUOTE(blimey @ Feb 5 2008, 02:41) *
I'm writing a plugin to log playback data (basically played songs) and that's working pretty well, but i'd like to do something like audioscrobbler, meaning log only after a number of seconds have been played (e.g. 30 seconds). My idea would be to spawn a thread for this.

You really don't need a separate thread for that. A play_callback (which always runs in the main thread) is fully sufficient.
Yirkha
Imho you should use "playback_statistics_collector", which has been specially made for this kind of things. As the SDK says, the notification occurs when at least 60s of the track has been played, or the track has reached its end after at least 1/3 of it has been played through.

About the thread & synchronization stuff... well, you obviously don't know how threads work and/or how to use them in Windows environment. Fortunately, it's not needed for what you are trying to accomplish, just make an instance of the aforementioned class and its callback method will be automatically called at the appropriate times.
blimey
QUOTE(Yirkha @ Feb 6 2008, 08:57) *

Imho you should use "playback_statistics_collector", which has been specially made for this kind of things.

awesome, thanks

QUOTE(Yirkha @ Feb 6 2008, 08:57) *

About the thread & synchronization stuff... well, you obviously don't know how threads work and/or how to use them in Windows environment.


Well, i obviously don't know how threads work in a windows environment, basically all the C i've done was in unix, in fact i'm running fb2k in linux so i have to make my own plugins cause not all of them work correctly. Also, i've done very little programming in c++, there are not many docs on the sdk and not that many plugin sources available for me to learn by example, which seems to be the way it goes with the sdk.
That's all cool, i'm not complaining and i've spent a lot of days looking at the sdk code and examples so there's no need to get nasty.
foosion
Synchronization on MSDN
Note that this is technical documentation and does not replace a proper introduction to synchronization in general. I do not mean to offend you; your earlier comments just make it hard to tell how much you really know about this topic.
Yirkha
QUOTE(blimey @ Feb 6 2008, 15:41) *
That's all cool, i'm not complaining and i've spent a lot of days looking at the sdk code and examples so there's no need to get nasty.
I'm sorry if it sounded nasty, it just seemed to me that you are trying to do it in a particularly weird way, even abusing some unrelated fb2k interfaces for emulating functionality normally implemented at the system level (regardless of the OS).
Whatever, you know more now, good luck with your plugin.
david_dl
QUOTE(blimey @ Feb 6 2008, 15:33) *

how does one usually handle threads the user doesn't necessarily have to know about?
or, is there a way to not show the dialog?


Google CreateThread
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.