summaryrefslogtreecommitdiff
path: root/src/liana/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/liana/list.c')
-rw-r--r--src/liana/list.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/liana/list.c b/src/liana/list.c
index cd073ad..d12caab 100644
--- a/src/liana/list.c
+++ b/src/liana/list.c
@@ -3,7 +3,7 @@
#include <al/log.h>
#include <al/lib.h>
#include <al/random.h>
-#include <nnwt/thread.h>
+#include <nnwt/time.h>
#include "list.h"
#include "list_cmp.h"
@@ -355,8 +355,11 @@ static bool handle_skipto(struct lia_list *list, s32 sequence, s32 index)
bool error;
if (!entry_load_and_get_duration(list, target, index, &error)) {
if (error) {
- // On an error, sequence will address the same entry but index may not.
- return handle_skipto(list, sequence, index);
+ // On an error, sequence will address the same entry but index might not.
+ // entry_load_and_get_duration() may also adjust the current cmd's sequence,
+ // so use cmd->sequence here.
+ struct lia_list_cmd *cmd = list->cmd;
+ return handle_skipto(list, cmd->sequence, index);
}
return false;
}
@@ -452,18 +455,25 @@ static void handle_toggle_pause(struct lia_list *list, s32 sequence, f64 pts)
case LIANA_PAUSE_PAUSE: {
al_assert(entry->start != LIANA_TIMESTAMP_INVALID);
entry->paused_at = now + LIANA_PAUSE_DELAY;
- // @TODO: There is no reason we couldn't pause during a pre-roll.
if (entry->paused_at < entry->start) {
entry->paused_at = entry->start;
+ // @TODO: Delay would need to apply to newly added sinks and skipto().
+ //entry->delay = entry->start - entry->paused_at;
+ } else {
+ entry->offset += entry->paused_at - entry->start;
}
- entry->offset += entry->paused_at - entry->start;
entry->start = LIANA_TIMESTAMP_INVALID;
at = entry->paused_at;
break;
}
case LIANA_PAUSE_RESUME: {
al_assert(entry->start == LIANA_TIMESTAMP_INVALID);
- entry->start = now + LIANA_PAUSE_DELAY;
+ if (entry->delay != LIANA_TIMESTAMP_INVALID) {
+ entry->start = now + MAX(entry->delay, LIANA_PAUSE_DELAY);
+ entry->delay = LIANA_TIMESTAMP_INVALID;
+ } else {
+ entry->start = now + LIANA_PAUSE_DELAY;
+ }
entry->paused_at = LIANA_TIMESTAMP_INVALID;
at = entry->start;
break;
@@ -813,6 +823,7 @@ void lia_list_add(struct lia_list *list, str *brief, void *opaque, u64 duration,
entry->start = LIANA_TIMESTAMP_INVALID;
entry->paused_at = LIANA_TIMESTAMP_INVALID;
entry->offset = 0;
+ entry->delay = LIANA_TIMESTAMP_INVALID;
entry->duration = duration;
entry->load = load;
entry->held = false;
@@ -929,7 +940,6 @@ void lia_list_close(struct lia_list *list)
void lia_list_free(struct lia_list *list)
{
- al_assert(list->closed);
struct lia_list_cmd *cmd;
al_array_foreach(list->command_queue, i, cmd) {
al_free(cmd);