aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-19 04:19:49 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-19 04:19:49 -0700
commit508ae1c18d3bdc99a1bb06181762e5ec859cf072 (patch)
tree2ca07424977fcdd72bda53eae0266d6b1bddc337 /src/outputBuffer.c
parent548385ac6cc0bc344762e19117f94258e7ea2251 (diff)
downloadmpd-508ae1c18d3bdc99a1bb06181762e5ec859cf072.tar.gz
mpd-508ae1c18d3bdc99a1bb06181762e5ec859cf072.tar.xz
mpd-508ae1c18d3bdc99a1bb06181762e5ec859cf072.zip
Remove ob_wait_sync and cleanup triggering in playlist
ob_wait_sync was a gross hack anyways. We are one step closer to being able to trigger actions in our worker threads asynchronously. Just need to make input (file opening) in decoder happen _after_ our decoder returns an ACK.
Diffstat (limited to '')
-rw-r--r--src/outputBuffer.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 26d31b2cd..aca84d07f 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -207,18 +207,24 @@ static void ob_seq_player_set(unsigned int seq_num)
cond_leave(&ob_seq_cond);
}
+static enum action_status ob_do_reset(void)
+{
+ assert(pthread_equal(pthread_self(), ob.thread));
+ ob.elapsed_time = 0;
+ ob.total_time = 0;
+ reader_reset_buffer();
+ ob.xfade_state = XFADE_DISABLED;
+ ob_seq_player_set((unsigned int)ob.seq_decoder);
+ return ob_finalize_action();
+}
+
static enum action_status ob_do_stop(void)
{
assert(pthread_equal(pthread_self(), ob.thread));
- if (ob.state != OB_STATE_STOP) {
- ob.elapsed_time = 0;
- reader_reset_buffer();
- ob.xfade_state = XFADE_DISABLED;
- close_audio_devices();
- ob.state = OB_STATE_STOP;
- ob_seq_player_set((unsigned int)ob.seq_decoder);
- }
- return AS_INPROGRESS;
+ if (ob.state == OB_STATE_STOP)
+ return AS_INPROGRESS;
+ ob.state = OB_STATE_STOP;
+ return ob_do_reset();
}
/*
@@ -299,6 +305,7 @@ static enum action_status ob_take_action(void)
}
break;
case OB_ACTION_STOP: return ob_do_stop();
+ case OB_ACTION_RESET: return ob_do_reset();
case OB_ACTION_QUIT:
close_audio_devices();
ob.state = OB_STATE_QUIT;
@@ -350,24 +357,6 @@ void ob_drop_audio(enum ob_drop_type type)
/* DEBUG("done dropping %u\n", ob.seq_drop); */
}
-void ob_wait_sync(void)
-{
- assert(!pthread_equal(pthread_self(), dc.thread));
- assert(!pthread_equal(pthread_self(), ob.thread));
-
- /* DEBUG(__FILE__": %s %d\n", __func__, __LINE__); */
- cond_enter(&ob_seq_cond);
- while (ob.seq_player != ob.seq_decoder) {
- /* DEBUG("%s %d seq_player:%u seq_decoder:%u\n", */
- /* __func__, __LINE__, ob.seq_player, ob.seq_decoder); */
- cond_wait(&ob_seq_cond);
- /* DEBUG("%s %d seq_player:%u seq_decoder:%u\n", */
- /* __func__, __LINE__, ob.seq_player, ob.seq_decoder); */
- }
- cond_leave(&ob_seq_cond);
- /* DEBUG(__FILE__": %s %d\n", __func__, __LINE__); */
-}
-
/* call this exactly once before decoding each song */
void ob_advance_sequence(void)
{
@@ -527,7 +516,7 @@ void ob_flush(void)
case OB_STATE_SEEK:
assert(0);
case OB_STATE_PLAY:
- case OB_STATE_PAUSE: /* should we assert if paused? */
+ case OB_STATE_PAUSE:
ringbuf_write_advance(ob.index, 1);
break;
case OB_STATE_STOP: