aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-25 08:44:31 +0200
committerMax Kellermann <max@duempel.org>2012-08-25 09:38:41 +0200
commitf351550534939478d7ddc791dc76aafd5f2a3503 (patch)
tree3672f6b43ee97f00ba7812cdfce92dda2c901437
parent66ecf39efe703185b1d54775e052d1c6a3f76903 (diff)
player_thread: disable cross-fading in "single" mode
This commit reimplements the core of the "single" mode. Instead of doing the detection in the playlist code from the outside, it is moved to the player thread, which gets a new option called "border_pause". It will now pause playback exactly at the beginning of the new song, making the feature more reliable. Now that the player thread knows what will happen, it can suppress cross-fading. Fixes mantis tickets 0003055 and 0003166.
-rw-r--r--NEWS1
-rw-r--r--src/player_control.c8
-rw-r--r--src/player_control.h15
-rw-r--r--src/player_thread.c15
-rw-r--r--src/playlist.c17
5 files changed, 48 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 7bdfa353..717151de 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ ver 0.17.2 (2012/??/??)
* playlist: fix use-after-free bug
* playlist: fix memory leak
* state_file: save song priorities
+* player: disable cross-fading in "single" mode
ver 0.17.1 (2012/07/31)
diff --git a/src/player_control.c b/src/player_control.c
index d8d54dfd..90f616d7 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -211,6 +211,14 @@ pc_set_pause(struct player_control *pc, bool pause_flag)
}
void
+pc_set_border_pause(struct player_control *pc, bool border_pause)
+{
+ player_lock(pc);
+ pc->border_pause = border_pause;
+ player_unlock(pc);
+}
+
+void
pc_get_status(struct player_control *pc, struct player_status *status)
{
player_lock(pc);
diff --git a/src/player_control.h b/src/player_control.h
index 5a04ab0f..a77d31ec 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -115,6 +115,15 @@ struct player_control {
float mixramp_db;
float mixramp_delay_seconds;
double total_play_time;
+
+ /**
+ * If this flag is set, then the player will be auto-paused at
+ * the end of the song, before the next song starts to play.
+ *
+ * This is a copy of the queue's "single" flag most of the
+ * time.
+ */
+ bool border_pause;
};
struct player_control *
@@ -207,6 +216,12 @@ pc_set_pause(struct player_control *pc, bool pause_flag);
void
pc_pause(struct player_control *pc);
+/**
+ * Set the player's #border_pause flag.
+ */
+void
+pc_set_border_pause(struct player_control *pc, bool border_pause);
+
void
pc_kill(struct player_control *pc);
diff --git a/src/player_thread.c b/src/player_thread.c
index eaf6df30..707fb27a 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -842,6 +842,16 @@ player_song_border(struct player *player)
if (!player_wait_for_decoder(player))
return false;
+ struct player_control *const pc = player->pc;
+ player_lock(pc);
+
+ if (pc->border_pause) {
+ player->paused = true;
+ pc->state = PLAYER_STATE_PAUSE;
+ }
+
+ player_unlock(pc);
+
return true;
}
@@ -957,7 +967,10 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
player_dc_start(&player, music_pipe_new());
}
- if (player_dc_at_next_song(&player) &&
+ if (/* no cross-fading if MPD is going to pause at the
+ end of the current song */
+ !pc->border_pause &&
+ player_dc_at_next_song(&player) &&
player.xfade == XFADE_UNKNOWN &&
!decoder_lock_is_starting(dc)) {
/* enable cross fading in this song? if yes,
diff --git a/src/playlist.c b/src/playlist.c
index d62865dd..dc6d8c34 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -109,11 +109,6 @@ playlist_song_started(struct playlist *playlist, struct player_control *pc)
playlist->current = playlist->queued;
playlist->queued = -1;
- /* Pause if we are in single mode. */
- if(playlist->queue.single && !playlist->queue.repeat) {
- pc_set_pause(pc, true);
- }
-
if(playlist->queue.consume)
playlist_delete(playlist, pc,
queue_order_to_position(&playlist->queue,
@@ -310,7 +305,11 @@ playlist_set_repeat(struct playlist *playlist, struct player_control *pc,
if (status == playlist->queue.repeat)
return;
- playlist->queue.repeat = status;
+ struct queue *queue = &playlist->queue;
+
+ queue->repeat = status;
+
+ pc_set_border_pause(pc, queue->single && !queue->repeat);
/* if the last song is currently being played, the "next song"
might change when repeat mode is toggled */
@@ -338,7 +337,11 @@ playlist_set_single(struct playlist *playlist, struct player_control *pc,
if (status == playlist->queue.single)
return;
- playlist->queue.single = status;
+ struct queue *queue = &playlist->queue;
+
+ queue->single = status;
+
+ pc_set_border_pause(pc, queue->single && !queue->repeat);
/* if the last song is currently being played, the "next song"
might change when single mode is toggled */