[spotify] Retry playback setup if song is still loading

This commit is contained in:
chme
2018-03-01 17:29:10 +01:00
parent f108b6b498
commit d562cb9b6b
3 changed files with 20 additions and 2 deletions

View File

@@ -22,14 +22,30 @@
#include <stdint.h>
#include "input.h"
#include "logger.h"
#include "spotify.h"
// How many retries to start playback if resource is still loading
#define SPOTIFY_SETUP_RETRIES 5
// How long to wait between retries in microseconds (500000 = 0.5 seconds)
#define SPOTIFY_SETUP_RETRY_WAIT 500000
static int
setup(struct player_source *ps)
{
int i = 0;
int ret;
ret = spotify_playback_setup(ps->path);
while((ret = spotify_playback_setup(ps->path)) == SPOTIFY_SETUP_ERROR_IS_LOADING)
{
if (i >= SPOTIFY_SETUP_RETRIES)
break;
DPRINTF(E_DBG, L_SPOTIFY, "Resource still loading (%d)\n", i);
usleep(SPOTIFY_SETUP_RETRY_WAIT);
i++;
}
if (ret < 0)
return -1;