Skip to main content
Topic: fb2k API questions (Read 761 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

fb2k API questions

@Peter , could you help with the following, please?

1. playlist_manager_v4::create_playlist_ex / playlist_manager_v4::create_playlist_ex: in which case can it return pfc_infinite? Is it more like paranoia check (i.e. assert would suffice) or should I always validate it?
2. What is assigned to the return value of playlist_manager::playlist_insert_items? Is it the new position of the first track (i.e. same as p_base argument)?
3. Is there any difference between using u* methods from shared.dll and using corresponding WinAPI methods? E.g. uCreateFile vs CreateFile

Thanks in advance =)

Re: fb2k API questions

Reply #1
Playlist creation will fail if called from an illegal context - wrong thread, called from a global callback, fb2k shutdown in progress.
If your code already ensures running in main thread, an assert check should be sufficient.
You cannot call any methods that alter the state of playback, playlist, etc from a global callback - such as playlist/playback/etc callback - because the method by itself dispatches callbacks, which cannot be done recursively.
Returned value from playlist_insert_items is the index of the first inserted track - or pfc_infinite on failure (conditions above or an autoplaylist that refuses insertions).
u* methods used to be relevant when Win9X was still supported - Win9X users got a different build of the DLL which called non-Unicode APIs. By now there's no difference. These methods are mainly retained for backwards compatibility. Though you can sometimes reduce the size of your component by calling them instead of converting UTF-8 to wchar_t by yourself.

Re: fb2k API questions

Reply #2

Playlist creation will fail if called from an illegal context - ... fb2k shutdown in progress ...
Am I right to assume that this condition won't be triggered until after initquit::on_quit callback is executed?

And another small question:
Can autoplaylist_manager::add_client_simple(p_query, p_sort, p_playlist, p_flags) fail on a newly created playlist?

Re: fb2k API questions

Reply #3
If your component creates playlist in direct response to user events, it is safe to assume that shutdown is not yet in progress.
initquit::on_quit() is one way to know about shutdown in progress, but if some other component decides to do stuff that triggers your code in their on_quit(), your on_quit() might not yet have executed.

autoplaylist_manager::add_client_simple() on a newly created playlist should never fail. The current implementation throws an exception if the specified playlist index is invalid, or if the playlist is already an autoplaylist, neither of which can be true in your case.

Re: fb2k API questions

Reply #7
Everything modal dialog related should only ever be called from main thread.

modal_dialog_scope::can_create() returns false when either called from a non main thread or there already is a known modal dialog running.

SimplePortal 1.0.0 RC1 © 2008-2019