meta_db_io Callback Registration |
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).
![]() ![]() |
meta_db_io Callback Registration |
Jan 2 2012, 05:09
Post
#1
|
|
|
Group: Members Posts: 4 Joined: 29-December 11 Member No.: 96092 |
I'm wondering what exactly I have to do to register for callbacks when meta_db entries are modified.
Right now I am doing my testing by modifying the foo_tutorial1 plugin. Based off of how the menu entry is registered and how I saw things being done in foo_httpcontrol, in foo_tutorial1.cpp I added CODE class metadb_io_callback_tutorial1 : public metadb_io_callback_dynamic_impl_base { virtual void on_change_sorted(const pfc::list_base_const_t<metadb_handle_ptr>& p_items_sorted, bool p_fromhook) { SharedVars::num_callbacks++; } }; static metadb_io_callback_tutorial1 mdb_callback; static service_ptr_t<metadb_io_v3> mdb_io; and in on_init() I added: CODE mdb_io->register_callback(&mdb_callback); This code all compiles just fine, but when I try to run Foobar with the plugin I get this error: Failed to load DLL: foo_tutorial1.dll Reason: Invalid access to memory location. And, even though it says it didn't load the DLL, Foobar crashes when I close it. This post has been edited by Ambit: Jan 2 2012, 05:10 |
|
|
|
Jan 2 2012, 06:27
Post
#2
|
|
![]() Group: Admin Posts: 4218 Joined: 15-December 02 Member No.: 4082 |
You probably want to use static_api_ptr_t<metadb_io_v3> to access that service. Oh, and I don't know if you can get away with using a static instance of the callback, that may or may not work.
|
|
|
|
Jan 2 2012, 16:56
Post
#3
|
|
|
Group: Members Posts: 4 Joined: 29-December 11 Member No.: 96092 |
You probably want to use static_api_ptr_t<metadb_io_v3> to access that service. Oh, and I don't know if you can get away with using a static instance of the callback, that may or may not work. I made those changes and moved the static_api_ptr_t line inside the oninit function and it is no longer crashing. However, I am not getting callbacks for the events I expected. Since the metadb_handle has a format title function, I thought I would be getting notified whenever a tag updates. Is there a way to get a callback for that or will I have to make a thread that continuously calls format_title on every item in the library until the result changes? |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 18th May 2013 - 22:55 |