mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
[pipe] Support for Shairport sync metadata flush event
This commit is contained in:
parent
f1c41e113d
commit
363bd5644b
@ -370,6 +370,12 @@ handle_progress(struct input_metadata *m, char *progress)
|
||||
DPRINTF(E_DBG, L_PLAYER, "Received Shairport metadata progress: %" PRIi64 "/%" PRIi64 "/%" PRIi64 " => %d/%u ms\n", start, pos, end, m->pos_ms, m->len_ms);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_flush(void)
|
||||
{
|
||||
player_playback_flush();
|
||||
}
|
||||
|
||||
static void
|
||||
handle_volume(const char *volume)
|
||||
{
|
||||
@ -506,6 +512,12 @@ handle_item(struct input_metadata *m, const char *item)
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
if (code == dmapval("pfls"))
|
||||
{
|
||||
handle_flush();
|
||||
goto out_nothing;
|
||||
}
|
||||
|
||||
if (code == dmapval("asal"))
|
||||
dstptr = &m->album;
|
||||
else if (code == dmapval("asar"))
|
||||
|
62
src/player.c
62
src/player.c
@ -2463,6 +2463,33 @@ playback_pause(void *arg, int *retval)
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
static enum command_state
|
||||
playback_flush(void *arg, int *retval)
|
||||
{
|
||||
if (player_state == PLAY_STOPPED)
|
||||
{
|
||||
*retval = -1;
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
if (player_state == PLAY_PAUSED)
|
||||
{
|
||||
*retval = 0;
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
input_flush(NULL);
|
||||
|
||||
*retval = outputs_flush(device_flush_cb);
|
||||
outputs_metadata_purge();
|
||||
|
||||
if (*retval > 0)
|
||||
return COMMAND_PENDING; // async
|
||||
|
||||
// Otherwise we are done
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
static enum command_state
|
||||
playback_seek(void *arg, int *retval)
|
||||
{
|
||||
@ -2831,6 +2858,20 @@ speaker_authorize(void *arg, int *retval)
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
static enum command_state
|
||||
speaker_start_all(void *arg, int *retval)
|
||||
{
|
||||
outputs_stop_delayed_cancel();
|
||||
|
||||
*retval = outputs_start(device_activate_cb, device_shutdown_cb, false);
|
||||
|
||||
if (*retval > 0)
|
||||
return COMMAND_PENDING; // async
|
||||
|
||||
// Otherwise we are done
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
static enum command_state
|
||||
volume_set(void *arg, int *retval)
|
||||
{
|
||||
@ -3161,6 +3202,27 @@ player_playback_pause(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes outputs and input buffer, but does not stop the input read loop. Used
|
||||
* by the pipe input when a track change is registered. Flushing outputs will
|
||||
* stop them, so the command is two-step, i.e. it starts them again.
|
||||
*
|
||||
* @return Returns 0 on success and a negative value on error
|
||||
*/
|
||||
|
||||
int
|
||||
player_playback_flush(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = commands_exec_sync(cmdbase, playback_flush, NULL, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = commands_exec_sync(cmdbase, speaker_start_all, NULL, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeks to the position "seek_ms", depending on the given "seek_mode" seek_ms is
|
||||
* either the new position in the current track (seek_mode == PLAYER_SEEK_POSITION)
|
||||
|
@ -132,6 +132,9 @@ player_playback_stop(void);
|
||||
int
|
||||
player_playback_pause(void);
|
||||
|
||||
int
|
||||
player_playback_flush(void);
|
||||
|
||||
int
|
||||
player_playback_seek(int seek_ms, enum player_seek_mode seek_mode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user