Commit d4914fc9 authored by Max Kellermann's avatar Max Kellermann

idle: added "update" event

Some clients have visual feedback for "database update is running". Using the "database" idle event is unreliable, because it is only emitted when the database was actually modified. This patch adds the "update" event, which is emitted when the update is started, and again when the update is finished, disregarding whether it has been modified.
parent 46c19b82
ver 0.16 (20??/??/??) ver 0.16 (20??/??/??)
* protocol: * protocol:
- send song modification time to client - send song modification time to client
- added "update" idle event
* decoders: * decoders:
- ffmpeg: support multiple tags - ffmpeg: support multiple tags
* mixers: * mixers:
......
...@@ -134,7 +134,16 @@ ...@@ -134,7 +134,16 @@
<listitem> <listitem>
<para> <para>
<returnvalue>database</returnvalue>: the song database <returnvalue>database</returnvalue>: the song database
has been updated has been modified
</para>
</listitem>
<listitem>
<para>
<returnvalue>update</returnvalue>: a database update
has started or finished. If the database was
modified during the update, the
<returnvalue>database</returnvalue> event is also
emitted.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
......
...@@ -40,6 +40,7 @@ static const char *const idle_names[] = { ...@@ -40,6 +40,7 @@ static const char *const idle_names[] = {
"output", "output",
"options", "options",
"sticker", "sticker",
"update",
NULL NULL
}; };
......
...@@ -50,6 +50,9 @@ enum { ...@@ -50,6 +50,9 @@ enum {
/** a sticker has been modified. */ /** a sticker has been modified. */
IDLE_STICKER = 0x80, IDLE_STICKER = 0x80,
/** a database update has started or finished. */
IDLE_UPDATE = 0x100,
}; };
/** /**
......
...@@ -822,6 +822,9 @@ directory_update_init(char *path) ...@@ -822,6 +822,9 @@ directory_update_init(char *path)
return next_task_id > update_task_id_max ? 1 : next_task_id; return next_task_id > update_task_id_max ? 1 : next_task_id;
} }
spawn_update_task(path); spawn_update_task(path);
idle_add(IDLE_UPDATE);
return update_task_id; return update_task_id;
} }
...@@ -861,6 +864,8 @@ static void update_finished_event(void) ...@@ -861,6 +864,8 @@ static void update_finished_event(void)
g_thread_join(update_thr); g_thread_join(update_thr);
idle_add(IDLE_UPDATE);
if (modified) { if (modified) {
/* send "idle" events */ /* send "idle" events */
playlistVersionChange(&g_playlist); playlistVersionChange(&g_playlist);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment