diff options
| -rwxr-xr-x | scripts/line_count.sh | 3 | ||||
| -rw-r--r-- | src/buffer/clock.c | 5 | ||||
| -rw-r--r-- | src/buffer/clock.h | 1 | ||||
| -rw-r--r-- | src/libsink/sink.c | 45 |
4 files changed, 29 insertions, 25 deletions
diff --git a/scripts/line_count.sh b/scripts/line_count.sh index 9da3e7e..e7abdf4 100755 --- a/scripts/line_count.sh +++ b/scripts/line_count.sh @@ -1,4 +1,5 @@ #! /usr/bin/env sh +export LC_ALL="C" find ./src -type f \ -not -path "*__pycache__*" \ -not -path "./src/fruits/droid/*" \ @@ -7,6 +8,6 @@ find ./src -type f \ -not -path "./src/portal/patches/*" \ -not -path "./src/portal/py/tests/*" \ -not -path "./src/portal/vendor/*" \ - -exec wc -l {} + + -exec sloccount {} + #-exec sed -i 's///g' {} + diff --git a/src/buffer/clock.c b/src/buffer/clock.c index 3e3efc0..3f2168c 100644 --- a/src/buffer/clock.c +++ b/src/buffer/clock.c @@ -93,11 +93,6 @@ void camu_clock_resume(struct camu_clock *clock, u64 target) clock->paused_at = -1.0; } -bool camu_clock_is_armed(struct camu_clock *clock) -{ - return al_atomic_load(f64)(&clock->pause, AL_ATOMIC_RELAXED) != RUNNING; -} - bool camu_clock_is_paused(struct camu_clock *clock) { return al_atomic_load(f64)(&clock->pause, AL_ATOMIC_RELAXED) == PAUSED; diff --git a/src/buffer/clock.h b/src/buffer/clock.h index a2762a6..dd3f015 100644 --- a/src/buffer/clock.h +++ b/src/buffer/clock.h @@ -44,7 +44,6 @@ void camu_clock_offset(struct camu_clock *clock, f64 amount); void camu_clock_pause(struct camu_clock *clock, u64 target); void camu_clock_resume(struct camu_clock *clock, u64 target); -bool camu_clock_is_armed(struct camu_clock *clock); bool camu_clock_is_paused(struct camu_clock *clock); f64 camu_clock_get_base_pts(struct camu_clock *clock); 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(¤t->clock)) { + camu_clock_pause(¤t->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); |