[player/spotify] adjust spotify integration to refactoring of player

This commit is contained in:
chme 2015-09-12 07:45:31 +02:00
parent e1147c00a1
commit 58069e67f8
3 changed files with 72 additions and 12 deletions

View File

@ -874,7 +874,7 @@ stream_setup(struct player_source *ps, struct media_file_info *mfi)
case DATA_KIND_SPOTIFY:
#ifdef HAVE_SPOTIFY_H
ret = spotify_playback_play(mfi); //TODO [player] split spotify setup/play into separate functions
ret = spotify_playback_setup(mfi);
#else
ret = -1;
#endif
@ -904,13 +904,13 @@ stream_play(struct player_source *ps)
if (!ps)
{
DPRINTF(E_LOG, L_PLAYER, "Stream pause called with no active streaming player source\n");
DPRINTF(E_LOG, L_PLAYER, "Stream play called with no active streaming player source\n");
return -1;
}
if (!ps->setup_done)
{
DPRINTF(E_LOG, L_PLAYER, "Given player source not setup, pause not possible\n");
DPRINTF(E_LOG, L_PLAYER, "Given player source not setup, play not possible\n");
return -1;
}
@ -924,7 +924,7 @@ stream_play(struct player_source *ps)
#ifdef HAVE_SPOTIFY_H
case DATA_KIND_SPOTIFY:
ret = spotify_playback_resume();
ret = spotify_playback_play();
break;
#endif
@ -1022,7 +1022,7 @@ stream_pause(struct player_source *ps)
#ifdef HAVE_SPOTIFY_H
case DATA_KIND_SPOTIFY:
spotify_playback_pause_nonblock(); //TODO [player] spotify blocking pause command missing
spotify_playback_pause();
ret = 0;
break;
#endif
@ -1162,7 +1162,7 @@ stream_cleanup(struct player_source *ps)
case DATA_KIND_SPOTIFY:
#ifdef HAVE_SPOTIFY_H
spotify_playback_stop(); //TODO [player] spotify cleanup functions
spotify_playback_stop(); //TODO [player] spotify cleanup functions?
#endif
break;
@ -1530,6 +1530,10 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
if (ret < 0)
return -1;
ret = source_play();
if (ret < 0)
return -1;
}
else
{

View File

@ -912,12 +912,12 @@ audio_fifo_flush(void)
}
static int
playback_play(struct spotify_command *cmd)
playback_setup(struct spotify_command *cmd)
{
sp_track *track;
sp_error err;
DPRINTF(E_DBG, L_SPOTIFY, "Starting playback\n");
DPRINTF(E_DBG, L_SPOTIFY, "Setting up for playback\n");
if (SP_CONNECTION_STATE_LOGGED_IN != fptr_sp_session_connectionstate(g_sess))
{
@ -947,6 +947,16 @@ playback_play(struct spotify_command *cmd)
audio_fifo_flush();
return 0;
}
static int
playback_play(struct spotify_command *cmd)
{
sp_error err;
DPRINTF(E_DBG, L_SPOTIFY, "Starting playback\n");
err = fptr_sp_session_player_play(g_sess, 1);
if (SP_ERROR_OK != err)
{
@ -1626,13 +1636,13 @@ notify_cb(int fd, short what, void *arg)
/* Thread: player */
int
spotify_playback_play(struct media_file_info *mfi)
spotify_playback_setup(struct media_file_info *mfi)
{
struct spotify_command cmd;
sp_link *link;
int ret;
DPRINTF(E_DBG, L_SPOTIFY, "Playback request\n");
DPRINTF(E_DBG, L_SPOTIFY, "Playback setup request\n");
link = fptr_sp_link_create_from_string(mfi->path);
if (!link)
@ -1643,7 +1653,7 @@ spotify_playback_play(struct media_file_info *mfi)
command_init(&cmd);
cmd.func = playback_play;
cmd.func = playback_setup;
cmd.arg.link = link;
ret = sync_command(&cmd);
@ -1653,6 +1663,46 @@ spotify_playback_play(struct media_file_info *mfi)
return ret;
}
int
spotify_playback_play()
{
struct spotify_command cmd;
int ret;
DPRINTF(E_DBG, L_SPOTIFY, "Playback request\n");
command_init(&cmd);
cmd.func = playback_play;
cmd.arg.noarg = NULL;
ret = sync_command(&cmd);
command_deinit(&cmd);
return ret;
}
int
spotify_playback_pause()
{
struct spotify_command cmd;
int ret;
DPRINTF(E_DBG, L_SPOTIFY, "Pause request\n");
command_init(&cmd);
cmd.func = playback_pause;
cmd.arg.noarg = NULL;
ret = sync_command(&cmd);
command_deinit(&cmd);
return ret;
}
/* Thread: libspotify */
void
spotify_playback_pause_nonblock(void)

View File

@ -11,7 +11,13 @@
#endif
int
spotify_playback_play(struct media_file_info *mfi);
spotify_playback_setup(struct media_file_info *mfi);
int
spotify_playback_play();
int
spotify_playback_pause();
void
spotify_playback_pause_nonblock(void);