[listener/library] Notify listeners about start/finish of library update

This commit is contained in:
chme 2017-08-06 17:39:32 +02:00
parent 0b2ee5a9eb
commit f81d33701b
2 changed files with 11 additions and 6 deletions

View File

@ -549,7 +549,7 @@ rescan(void *arg, int *ret)
int i;
DPRINTF(E_LOG, L_LIB, "Library rescan triggered\n");
listener_notify(LISTENER_UPDATE);
starttime = time(NULL);
for (i = 0; sources[i]; i++)
@ -569,8 +569,9 @@ rescan(void *arg, int *ret)
endtime = time(NULL);
DPRINTF(E_LOG, L_LIB, "Library rescan completed in %.f sec\n", difftime(endtime, starttime));
scanning = false;
listener_notify(LISTENER_UPDATE);
*ret = 0;
return COMMAND_END;
}
@ -583,7 +584,7 @@ fullrescan(void *arg, int *ret)
int i;
DPRINTF(E_LOG, L_LIB, "Library full-rescan triggered\n");
listener_notify(LISTENER_UPDATE);
starttime = time(NULL);
player_playback_stop();
@ -605,8 +606,9 @@ fullrescan(void *arg, int *ret)
endtime = time(NULL);
DPRINTF(E_LOG, L_LIB, "Library full-rescan completed in %.f sec\n", difftime(endtime, starttime));
scanning = false;
listener_notify(LISTENER_UPDATE);
*ret = 0;
return COMMAND_END;
}
@ -665,6 +667,7 @@ initscan()
scanning = true;
starttime = time(NULL);
listener_notify(LISTENER_UPDATE);
// Only clear the queue if enabled (default) in config
clear_queue_disabled = cfg_getbool(cfg_getsec(cfg, "mpd"), "clear_queue_on_stop_disable");
@ -691,7 +694,7 @@ initscan()
DPRINTF(E_LOG, L_LIB, "Library init scan completed in %.f sec\n", difftime(endtime, starttime));
scanning = false;
listener_notify(LISTENER_UPDATE);
listener_notify(LISTENER_DATABASE);
}

View File

@ -16,8 +16,10 @@ enum listener_event_type
LISTENER_OPTIONS = (1 << 4),
/* The library has been modified */
LISTENER_DATABASE = (1 << 5),
/* A stored playlist has been modified (create, delete, add, rename) */
/* A stored playlist has ben modified (create, delete, add, rename) */
LISTENER_STORED_PLAYLIST = (1 << 6),
/* A library update has started or finished */
LISTENER_UPDATE = (1 << 7),
};
typedef void (*notify)(enum listener_event_type type);