summaryrefslogtreecommitdiff
path: root/src/libsink
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsink')
-rw-r--r--src/libsink/sink.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/libsink/sink.c b/src/libsink/sink.c
index f588cfa..97f1d66 100644
--- a/src/libsink/sink.c
+++ b/src/libsink/sink.c
@@ -235,21 +235,23 @@ static void add_or_queue_entry(struct camu_sink_entry *entry)
static void sink_local_pause(struct camu_sink *sink, struct camu_sink_entry *entry)
{
if (camu_clock_is_paused(&entry->clock)) {
+ entry->audio.buffer_paused = false;
camu_clock_resume(&entry->clock, 0);
if (AUDIO_NOT_EMPTY(entry) && sink->audio.state == SINK_PAUSED) {
sink->callback(sink->userdata, CAMU_SINK_START, CAMU_SINK_AUDIO, NULL);
sink->audio.state = SINK_PLAYING;
}
#ifndef CAMU_SINK_NO_VIDEO
- if (!VIDEO_IS_SINGLE_FRAME(entry) && sink->video.state == SINK_PAUSED) {
+ if (!VIDEO_EMPTY(entry) && !VIDEO_IS_SINGLE_FRAME(entry) && sink->video.state == SINK_PAUSED) {
sink->callback(sink->userdata, CAMU_SINK_START, CAMU_SINK_VIDEO, NULL);
sink->video.state = SINK_PLAYING;
}
#endif
} else {
+ entry->audio.buffer_paused = true;
camu_clock_pause(&entry->clock, 0);
#ifndef CAMU_SINK_NO_VIDEO
- if (!VIDEO_IS_SINGLE_FRAME(entry) && sink->video.state == SINK_PLAYING) {
+ if (!VIDEO_EMPTY(entry) && !VIDEO_IS_SINGLE_FRAME(entry) && sink->video.state == SINK_PLAYING) {
sink->callback(sink->userdata, CAMU_SINK_STOP, CAMU_SINK_VIDEO, NULL);
sink->video.state = SINK_PAUSED;
}
@@ -1279,33 +1281,40 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn,
if (op == LIANA_SINK_BUFFER) {
goto out;
} else if (op == LIANA_SINK_BUFFER_AND_QUEUE) {
+#ifdef CAMU_SINK_LOCAL
+ camu_clock_resume(&entry->clock, 0);
+#else
if (pause == LIANA_PAUSE_RESUME) {
camu_clock_resume(&entry->clock, at);
}
+#endif
sink->queued = entry;
goto out;
}
+ struct camu_sink_entry *current = sink->current;
+
#ifdef CAMU_SINK_LOCAL
- (void)at;
- (void)pause;
- if (sink->current && !sink->current->ended && !camu_clock_is_armed(&sink->current->clock)) {
- camu_clock_pause(&sink->current->clock, 0);
+ if (current && !current->ended && !camu_clock_is_paused(&current->clock)) {
+ camu_clock_pause(&current->clock, 0);
}
- switch_to(sink, entry);
- if (!entry->ended && camu_clock_is_armed(&entry->clock)) {
+
+ if (!entry->ended && camu_clock_is_paused(&entry->clock)) {
// This will resume user-paused entries, but whatever.
+ entry->audio.buffer_paused = false;
camu_clock_resume(&entry->clock, 0);
}
+
+ switch_to(sink, entry);
#else
switch (pause) {
case LIANA_PAUSE_NONE: {
if (sink->target) {
sink->target = NULL;
} else {
- al_assert(entry != sink->current);
+ al_assert(entry != current);
}
- if (entry != sink->current) {
+ if (entry != current) {
switch_to(sink, entry);
}
break;
@@ -1314,9 +1323,9 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn,
if (sink->target) {
sink->target = NULL;
} else {
- al_assert(entry != sink->current);
+ al_assert(entry != current);
}
- if (entry != sink->current) {
+ if (entry != current) {
switch_to(sink, entry);
} else {
camu_audio_buffer_unpause(&entry->audio.buf);
@@ -1329,16 +1338,16 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn,
if (prev_target) {
// For target to be set that must mean that current is
// set, armed to pause, and not ended.
- al_assert(sink->current && !sink->current->ended);
+ al_assert(current && !current->ended);
al_assert(prev_target != entry);
- if (sink->current != entry) {
+ if (current != entry) {
sink->target = entry;
} else {
sink->target = NULL;
}
camu_clock_pause(&prev_target->clock, at);
} else {
- al_assert(sink->current != entry);
+ al_assert(current != entry);
pause_and_swap_to(sink, entry, at);
}
break;
@@ -1346,9 +1355,9 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn,
case LIANA_PAUSE_BOTH: {
struct camu_sink_entry *prev_target = sink->target;
if (prev_target) {
- al_assert(sink->current && !sink->current->ended);
+ al_assert(current && !current->ended);
al_assert(prev_target != entry);
- if (sink->current != entry) {
+ if (current != entry) {
sink->target = entry;
} else {
sink->target = NULL;
@@ -1356,7 +1365,7 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn,
}
camu_clock_pause(&prev_target->clock, at);
} else {
- al_assert(sink->current != entry);
+ al_assert(current != entry);
pause_and_swap_to(sink, entry, at);
}
camu_clock_resume(&entry->clock, at);