Skip to content

Commit

Permalink
Emit Stopped signal on exit
Browse files Browse the repository at this point in the history
Fixes: #61, #22
  • Loading branch information
hoyon committed Mar 5, 2022
1 parent 72945f9 commit c688351
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 15 additions & 1 deletion mpris.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,19 @@ static void emit_seeked_signal(UserData *ud)
}
}

static void set_stopped_status(UserData *ud)
{
const char *prop_name = "PlaybackStatus";
GVariant *prop_value = g_variant_new_string(STATUS_STOPPED);

ud->status = STATUS_STOPPED;

g_hash_table_insert(ud->changed_properties,
(gpointer)prop_name, prop_value);

emit_property_changes(ud);
}

// Register D-Bus object and interfaces
static void on_bus_acquired(GDBusConnection *connection,
G_GNUC_UNUSED const char *name,
Expand Down Expand Up @@ -912,10 +925,11 @@ static gboolean event_handler(int fd, G_GNUC_UNUSED GIOCondition condition, gpoi
has_event = FALSE;
break;
case MPV_EVENT_SHUTDOWN:
set_stopped_status(ud);
g_main_loop_quit(ud->loop);
break;
case MPV_EVENT_IDLE:
ud->status = STATUS_STOPPED;
set_stopped_status(ud);
break;
case MPV_EVENT_PROPERTY_CHANGE: {
mpv_event_property *prop_event = (mpv_event_property*)event->data;
Expand Down
9 changes: 1 addition & 8 deletions test/stop
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,9 @@ if [ $ret_ipc -eq 0 ] ; then
echo 'probably mpv did not stop when asked to!' >&2
fi

if [ ! -s "$socat_log" ] ; then
echo 'socat log should contain an error!' >&2
else
echo 'socat log contains these *expected* errors:'
cat "$socat_log"
fi

playerctl status 2>&1 > /dev/null |
grep '^No players found$'

if [ $ret_ipc -eq 0 ] || [ ! -s "$socat_log" ] ; then
if [ $ret_ipc -eq 0 ] ; then
exit 1
fi

0 comments on commit c688351

Please sign in to comment.