diff --git a/include/callback.h b/include/callback.h index 71f334cf..1f8cec49 100644 --- a/include/callback.h +++ b/include/callback.h @@ -13,6 +13,7 @@ struct Callbacks { void (*on_play)(); void (*on_pause)(); void (*on_track_loaded)(library :: Song &); + void (*on_pause_count_changed)(bool, unsigned int); /* Library callbacks */ void (*on_library_add)(unsigned int, library :: Library *); diff --git a/lib/audio.cpp b/lib/audio.cpp index f3bf7da2..c9348bb9 100644 --- a/lib/audio.cpp +++ b/lib/audio.cpp @@ -40,6 +40,7 @@ static void handle_pause_count() o_pause_enabled = false; } else o_pause_count--; + get_callbacks()->on_pause_count_changed(o_pause_enabled, o_pause_count); } static gboolean on_message(GstBus *bus, GstMessage *message, gpointer data) @@ -224,8 +225,12 @@ long audio :: duration() void audio :: pause_after(bool enabled, unsigned int n) { + if (n > o_pause_count) + enabled = true; + o_pause_enabled = enabled; o_pause_count = n; + get_callbacks()->on_pause_count_changed(enabled, n); } bool audio :: pause_enabled() diff --git a/lib/callback.cpp b/lib/callback.cpp index df40c7b6..c6cadd04 100644 --- a/lib/callback.cpp +++ b/lib/callback.cpp @@ -6,6 +6,7 @@ static void no_op() {} static void no_op(unsigned int) {} +static void no_op(bool, unsigned int) {} static void no_op(unsigned int id, library :: Library *path) {} static void no_op(Playqueue *, unsigned int) {} static void no_op(library :: Song &) {} @@ -15,6 +16,7 @@ static struct Callbacks callbacks = { .on_play = no_op, .on_pause = no_op, .on_track_loaded = no_op, + .on_pause_count_changed = no_op, .on_library_add = no_op, .on_library_update = no_op,