Help - Search - Members - Calendar
Full Version: on_playback_starting not being called for /play
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
AlexVallat
Hello,

It seems that the callback for playback starting:

CODE
play_callback::on_playback_starting


is not being called when foobar is started with the /play switch. If playback is stopped or paused and then started again, it is called as normal.

If anyone could confirm this as a bug, perhaps it could be put on the list to fix for the next version?

Thanks,

Alex
Peter
Sorry, can't reproduce.
AlexVallat
Hmm... could it be that initquit::on_init is not called until after the first play_callback::on_playback_starting takes place then?

I've put together some minimal code to demonstrate this. It is supposed to write "on_playback_starting" to the console whenever that callback is called, but does not do so when playback starts from /play on the command line.

CODE
#include "../SDK/foobar2000.h"
#include "../helpers/helpers.h"

class play_callback_listener : private play_callback {
private:

public:
play_callback_listener();
~play_callback_listener();

// play_callback methods (the ones we're interested in)
virtual void on_playback_starting(play_control::t_track_command p_command, bool p_paused) { console::info("on_playback_starting"); }

// play_callback methods (the rest)
virtual void on_playback_new_track(metadb_handle_ptr p_track) {}
virtual void on_playback_stop(play_control::t_stop_reason reason) {}
virtual void on_playback_dynamic_info_track(const file_info & p_info) {}
virtual void on_playback_seek(double p_time) {}
virtual void on_playback_pause(bool p_state) {}
virtual void on_playback_edited(metadb_handle_ptr p_track) {}
virtual void on_playback_dynamic_info(const file_info & p_info) {}
virtual void on_playback_time(double p_time) {}
virtual void on_volume_change(float p_new_val) {}
};

play_callback_listener::play_callback_listener() {
// Register play callback.
try {
static_api_ptr_t<play_callback_manager> pcm;
pcm->register_callback(this,
flag_on_playback_starting, false);

console::info("Registered");
}
catch (const exception_service_not_found &) {
console::error("Could not register callback");
}
}

play_callback_listener::~play_callback_listener() {
// Unregister play callback.
try {
static_api_ptr_t<play_callback_manager> pcm;
pcm->unregister_callback(this);
}
catch (const exception_service_not_found &) {
console::error("Could not unregister callback");
}
}

static play_callback_listener* g_listner;

class initquit_tutorial1 : public initquit {
virtual void on_init() {
g_listner = new play_callback_listener();
}

virtual void on_quit() {
delete g_listner;
g_listner = NULL;
}
};

static initquit_factory_t< initquit_tutorial1 > foo_initquit;
Mangix
which foobar2000 version are you using?
foosion
QUOTE(AlexVallat @ Sep 17 2006, 12:15) *
Hmm... could it be that initquit::on_init is not called until after the first play_callback::on_playback_starting takes place then?
That's entirely possible. The solution is to either use play_callback_static, or to pass true as the third parameter to play_callback_manager::register_callback().
AlexVallat
QUOTE(foosion @ Sep 17 2006, 12:10) *

That's entirely possible. The solution is to either use play_callback_static, or to pass true as the third parameter to play_callback_manager::register_callback().

Thanks, foosion, both of those workarounds solve the problem nicely!

@Magnix*: I am using v0.9.4 beta 2.
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.