mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-31 09:43:45 -04:00
[player] Combine stream_stop and stream_cleanup into one function
This commit is contained in:
parent
e44a160b9a
commit
2b037b67d9
56
src/player.c
56
src/player.c
@ -264,7 +264,7 @@ static uint64_t pb_pos;
|
|||||||
static uint64_t last_rtptime;
|
static uint64_t last_rtptime;
|
||||||
|
|
||||||
/* AirPlay devices */
|
/* AirPlay devices */
|
||||||
static int dev_autoselect;
|
static int dev_autoselect; //TODO [player] Is this still necessary?
|
||||||
static struct raop_device *dev_list;
|
static struct raop_device *dev_list;
|
||||||
|
|
||||||
/* Device status */
|
/* Device status */
|
||||||
@ -1092,55 +1092,10 @@ stream_seek(struct player_source *ps, int seek_ms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stops playback for the given player source
|
* Stops playback and cleanup for the given player source
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
stream_stop(struct player_source *ps)
|
stream_stop(struct player_source *ps)
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!ps)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Stream stop called with no active streaming player source\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ps->setup_done)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Given player source not setup, stop not possible\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause playback depending on data kind
|
|
||||||
switch (ps->data_kind)
|
|
||||||
{
|
|
||||||
case DATA_KIND_HTTP:
|
|
||||||
case DATA_KIND_FILE:
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef HAVE_SPOTIFY_H
|
|
||||||
case DATA_KIND_SPOTIFY:
|
|
||||||
ret = spotify_playback_stop();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case DATA_KIND_PIPE:
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cleanup given player source
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
stream_cleanup(struct player_source *ps)
|
|
||||||
{
|
{
|
||||||
if (!ps)
|
if (!ps)
|
||||||
{
|
{
|
||||||
@ -1223,7 +1178,6 @@ source_stop()
|
|||||||
struct player_source *ps_temp;
|
struct player_source *ps_temp;
|
||||||
|
|
||||||
stream_stop(cur_streaming);
|
stream_stop(cur_streaming);
|
||||||
stream_cleanup(cur_streaming);
|
|
||||||
|
|
||||||
ps_playing = source_now_playing();
|
ps_playing = source_now_playing();
|
||||||
|
|
||||||
@ -1269,10 +1223,6 @@ source_pause(uint64_t pos)
|
|||||||
ret = stream_stop(cur_streaming);
|
ret = stream_stop(cur_streaming);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = stream_cleanup(cur_streaming);
|
|
||||||
if (ret < 0)
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1450,7 +1400,7 @@ source_open(struct queue_item_info *qii, uint64_t start_pos, int seek)
|
|||||||
static int
|
static int
|
||||||
source_close(uint64_t end_pos)
|
source_close(uint64_t end_pos)
|
||||||
{
|
{
|
||||||
stream_cleanup(cur_streaming);
|
stream_stop(cur_streaming);
|
||||||
|
|
||||||
cur_streaming->end = end_pos;
|
cur_streaming->end = end_pos;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user