From 4d79a857807306394df585b73121adffe27ee99d Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 17 May 2014 15:33:35 +0200 Subject: [PATCH 1/2] Change behavior of skip to previous song to start the current song from the beginning, if it is playing for more than 3 seconds --- src/player.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/player.c b/src/player.c index e2e3f7be..f192e5ff 100644 --- a/src/player.c +++ b/src/player.c @@ -2633,6 +2633,7 @@ static int playback_prev_bh(struct player_command *cmd) { int ret; + int pos_sec; if (!cur_streaming) { @@ -2646,12 +2647,34 @@ playback_prev_bh(struct player_command *cmd) source_stop(cur_streaming); - ret = source_prev(); - if (ret < 0) - { - playback_abort(); + /* Compute the playing time in seconds for the current song. */ + if (cur_streaming->end > cur_streaming->stream_start) + pos_sec = (cur_streaming->end - cur_streaming->stream_start) / 44100; + else + pos_sec = 0; - return -1; + /* Only skip to the previous song if the playing time is less than 3 seconds, + otherwise restart the current song. */ + DPRINTF(E_DBG, L_PLAYER, "Skipping song played %d sec\n", pos_sec); + if (pos_sec < 3) + { + ret = source_prev(); + if (ret < 0) + { + playback_abort(); + + return -1; + } + } + else + { + ret = source_open(cur_streaming, 1); + if (ret < 0) + { + playback_abort(); + + return -1; + } } if (player_state == PLAY_STOPPED) @@ -2668,6 +2691,7 @@ playback_prev_bh(struct player_command *cmd) return 0; } + static int playback_next_bh(struct player_command *cmd) { From 74622904e3af155c78b120c41555b15c4d8f2b5c Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 17 May 2014 15:40:25 +0200 Subject: [PATCH 2/2] local audio: do not add pcm_buf_threshold to pcm_pos (leads to wrong position in Remote) --- src/laudio_alsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laudio_alsa.c b/src/laudio_alsa.c index e401898b..51d07da8 100644 --- a/src/laudio_alsa.c +++ b/src/laudio_alsa.c @@ -362,7 +362,7 @@ laudio_start(uint64_t cur_pos, uint64_t next_pkt) pcm_start_pos = next_pkt + pcm_buf_threshold; /* Compensate threshold, as it's taken into account by snd_pcm_delay() */ - pcm_pos += pcm_buf_threshold; + //pcm_pos += pcm_buf_threshold; DPRINTF(E_DBG, L_LAUDIO, "PCM pos %" PRIu64 ", start pos %" PRIu64 "\n", pcm_pos, pcm_start_pos);