mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
stream: add SEQ_READ/SEQ_WRITE macros
This commit is contained in:
parent
ae457625d3
commit
bc88e1cbf8
2 changed files with 11 additions and 5 deletions
|
|
@ -370,6 +370,12 @@ struct pw_node_activation {
|
|||
uint64_t max_delay; /* max of all xruns in microseconds */
|
||||
};
|
||||
|
||||
#define SEQ_WRITE(s) __atomic_add_fetch((s), 1, __ATOMIC_SEQ_CST)
|
||||
#define SEQ_WRITE_SUCCESS(s1,s2) ((s1) + 1 == (s2) && (s2 & 1) == 0)
|
||||
|
||||
#define SEQ_READ(s) __atomic_load_n((s), __ATOMIC_SEQ_CST)
|
||||
#define SEQ_READ_SUCCESS(s1,s2) ((s1) == (s2) && (s2 & 1) == 0)
|
||||
|
||||
#define pw_node_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_node_events, m, v, ##__VA_ARGS__)
|
||||
#define pw_node_emit_destroy(n) pw_node_emit(n, destroy, 0)
|
||||
#define pw_node_emit_free(n) pw_node_emit(n, free, 0)
|
||||
|
|
|
|||
|
|
@ -729,13 +729,13 @@ static inline void copy_position(struct stream *impl, int64_t queued)
|
|||
{
|
||||
struct spa_io_position *p = impl->position;
|
||||
if (p != NULL) {
|
||||
__atomic_add_fetch(&impl->seq, 1, __ATOMIC_SEQ_CST);
|
||||
SEQ_WRITE(&impl->seq);
|
||||
impl->time.now = p->clock.nsec;
|
||||
impl->time.rate = p->clock.rate;
|
||||
impl->time.ticks = p->clock.position;
|
||||
impl->time.delay = p->clock.delay;
|
||||
impl->time.queued = queued;
|
||||
__atomic_add_fetch(&impl->seq, 1, __ATOMIC_SEQ_CST);
|
||||
SEQ_WRITE(&impl->seq);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1638,10 +1638,10 @@ int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
|
|||
uintptr_t seq1, seq2;
|
||||
|
||||
do {
|
||||
seq1 = __atomic_load_n(&impl->seq, __ATOMIC_SEQ_CST);
|
||||
seq1 = SEQ_READ(&impl->seq);
|
||||
*time = impl->time;
|
||||
seq2 = __atomic_load_n(&impl->seq, __ATOMIC_SEQ_CST);
|
||||
} while (seq1 != seq2 || seq1 & 1);
|
||||
seq2 = SEQ_READ(&impl->seq);
|
||||
} while (!SEQ_READ_SUCCESS(seq1, seq2));
|
||||
|
||||
if (impl->direction == SPA_DIRECTION_INPUT)
|
||||
time->queued = (int64_t)(time->queued - impl->dequeued.outcount);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue