<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.hydrogenaudio.org/index.php?action=history&amp;feed=atom&amp;title=Foobar2000%3ADevelopment%3AGlobal_Callbacks</id>
	<title>Foobar2000:Development:Global Callbacks - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hydrogenaudio.org/index.php?action=history&amp;feed=atom&amp;title=Foobar2000%3ADevelopment%3AGlobal_Callbacks"/>
	<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Development:Global_Callbacks&amp;action=history"/>
	<updated>2026-05-04T21:49:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Development:Global_Callbacks&amp;diff=35757&amp;oldid=prev</id>
		<title>DEATH: Created page with &quot;Category:Foobar2000 Development == Tracking foobar2000 lifetime events: global callbacks ==  Multiple service classes presented by the SDK allow your component to receive ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Development:Global_Callbacks&amp;diff=35757&amp;oldid=prev"/>
		<updated>2022-06-21T20:04:10Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=Category:Foobar2000_Development&quot; title=&quot;Category:Foobar2000 Development&quot;&gt;Category:Foobar2000 Development&lt;/a&gt; == Tracking foobar2000 lifetime events: global callbacks ==  Multiple service classes presented by the SDK allow your component to receive ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Foobar2000 Development]]&lt;br /&gt;
== Tracking foobar2000 lifetime events: global callbacks ==&lt;br /&gt;
&lt;br /&gt;
Multiple service classes presented by the SDK allow your component to receive notifications about various events.&lt;br /&gt;
We&amp;#039;ll refer to these classes as global callbacks.&lt;br /&gt;
&lt;br /&gt;
Essential examples of global callbacks:&lt;br /&gt;
* &amp;lt;code&amp;gt;initquit&amp;lt;/code&amp;gt; - notification about app startup and shutdown.&lt;br /&gt;
* &amp;lt;code&amp;gt;init_stage_callback&amp;lt;/code&amp;gt; - more detailed notification about app startup and shutdown.&lt;br /&gt;
* &amp;lt;code&amp;gt;file_operation_callback&amp;lt;/code&amp;gt; - tracking file move/copy/delete operations.&lt;br /&gt;
* &amp;lt;code&amp;gt;library_callback&amp;lt;/code&amp;gt; - tracking Media Library content changes.&lt;br /&gt;
* &amp;lt;code&amp;gt;metadb_io_callback&amp;lt;/code&amp;gt; - tracking tag read / write operations altering cached/displayed media information.&lt;br /&gt;
* &amp;lt;code&amp;gt;play_callback&amp;lt;/code&amp;gt; - tracking playback related events.&lt;br /&gt;
* &amp;lt;code&amp;gt;playback_statistics_collector&amp;lt;/code&amp;gt; - collecting information about played tracks.&lt;br /&gt;
* &amp;lt;code&amp;gt;playlist_callback&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;playlist_callback_single&amp;lt;/code&amp;gt; - tracking playlist changes (the latter tracks only active playlist changes).&lt;br /&gt;
* &amp;lt;code&amp;gt;playback_queue_callback&amp;lt;/code&amp;gt; - tracking playback queue changes.&lt;br /&gt;
* &amp;lt;code&amp;gt;titleformat_config_callback&amp;lt;/code&amp;gt; - tracking changes of title formatting configuration.&lt;br /&gt;
* &amp;lt;code&amp;gt;ui_drop_item_callback&amp;lt;/code&amp;gt; - filtering items dropped into the UI.&lt;br /&gt;
All of global callbacks operate only within main app thread, allowing easy cooperation with your user interface - for an example, you perform playlist view window repainting directly from your &amp;lt;code&amp;gt;playlist_callback&amp;lt;/code&amp;gt; implementation.&lt;br /&gt;
&lt;br /&gt;
== Global callback recursion issues ==&lt;br /&gt;
&lt;br /&gt;
There are restrictions on things that are legal to call from within global callbacks. For an example, you can&amp;#039;t modify a playlist from inside a playlist callback, because there are other registered callbacks tracking playlist changes that haven&amp;#039;t been notified about the change being currently processed yet.&lt;br /&gt;
&lt;br /&gt;
You must not enter modal message loops from inside global callbacks, as those allow any unrelated code (queued messages, user input, etc.) to be executed, without being aware that a global callback is being processed. Certain global API methods such as &amp;lt;code&amp;gt;metadb_io::load_info_multi&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;threaded_process::run_modal&amp;lt;/code&amp;gt; enter modal loops when called. Use &amp;lt;code&amp;gt;main_thread_callback&amp;lt;/code&amp;gt; service to avoid this problem and delay execution of problematic code.&lt;br /&gt;
&lt;br /&gt;
You should also avoid firing a cross-thread &amp;lt;code&amp;gt;SendMessage()&amp;lt;/code&amp;gt; inside global callbacks as well as performing any operations that dispatch global callbacks when handling a message that was sent through a cross-thread &amp;lt;code&amp;gt;SendMessage()&amp;lt;/code&amp;gt;. Doing so may result in rare unwanted recursions - &amp;lt;code&amp;gt;SendMessage()&amp;lt;/code&amp;gt; call will block the calling thread and immediately process any incoming cross-thread &amp;lt;code&amp;gt;SendMessage()&amp;lt;/code&amp;gt; messages. If you&amp;#039;re handling a cross-thread &amp;lt;code&amp;gt;SendMessage()&amp;lt;/code&amp;gt; and need to perform such operation, delay it using &amp;lt;code&amp;gt;PostMessage()&amp;lt;/code&amp;gt; or main_thread_callback.&lt;/div&gt;</summary>
		<author><name>DEATH</name></author>
	</entry>
</feed>