mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 16:25:03 -05:00
[spotify] Retry playback setup if song is still loading
This commit is contained in:
parent
f108b6b498
commit
d562cb9b6b
@ -22,14 +22,30 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "logger.h"
|
||||||
#include "spotify.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
|
static int
|
||||||
setup(struct player_source *ps)
|
setup(struct player_source *ps)
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
int ret;
|
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)
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ playback_setup(void *arg, int *retval)
|
|||||||
if (SP_ERROR_OK != err)
|
if (SP_ERROR_OK != err)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_SPOTIFY, "Playback setup failed: %s\n", fptr_sp_error_message(err));
|
DPRINTF(E_LOG, L_SPOTIFY, "Playback setup failed: %s\n", fptr_sp_error_message(err));
|
||||||
*retval = -1;
|
*retval = (SP_ERROR_IS_LOADING == err) ? SPOTIFY_SETUP_ERROR_IS_LOADING : -1;
|
||||||
return COMMAND_END;
|
return COMMAND_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ struct spotify_status_info
|
|||||||
char libspotify_user[100];
|
char libspotify_user[100];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SPOTIFY_SETUP_ERROR_IS_LOADING -2
|
||||||
|
|
||||||
int
|
int
|
||||||
spotify_playback_setup(const char *path);
|
spotify_playback_setup(const char *path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user