From 2b037b67d94f8ebec47a14a1b9beeae9fc2cdf0b Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 18 Sep 2015 19:19:02 +0200 Subject: [PATCH] [player] Combine stream_stop and stream_cleanup into one function --- src/player.c | 56 +++------------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) diff --git a/src/player.c b/src/player.c index c47a8271..5787123b 100644 --- a/src/player.c +++ b/src/player.c @@ -264,7 +264,7 @@ static uint64_t pb_pos; static uint64_t last_rtptime; /* AirPlay devices */ -static int dev_autoselect; +static int dev_autoselect; //TODO [player] Is this still necessary? static struct raop_device *dev_list; /* 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 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) { @@ -1223,7 +1178,6 @@ source_stop() struct player_source *ps_temp; stream_stop(cur_streaming); - stream_cleanup(cur_streaming); ps_playing = source_now_playing(); @@ -1269,10 +1223,6 @@ source_pause(uint64_t pos) ret = stream_stop(cur_streaming); if (ret < 0) return -1; - - ret = stream_cleanup(cur_streaming); - if (ret < 0) - return -1; } else { @@ -1450,7 +1400,7 @@ source_open(struct queue_item_info *qii, uint64_t start_pos, int seek) static int source_close(uint64_t end_pos) { - stream_cleanup(cur_streaming); + stream_stop(cur_streaming); cur_streaming->end = end_pos;