diff options
Diffstat (limited to 'src/libsink')
| -rw-r--r-- | src/libsink/desktop.c | 2 | ||||
| -rw-r--r-- | src/libsink/sink.c | 33 |
2 files changed, 17 insertions, 18 deletions
diff --git a/src/libsink/desktop.c b/src/libsink/desktop.c index ccc34a3..e9ccedb 100644 --- a/src/libsink/desktop.c +++ b/src/libsink/desktop.c @@ -256,7 +256,7 @@ bool camu_desktop_connect(struct camu_desktop *c, str *name, struct nn_event_loo bool camu_desktop_tick(struct camu_desktop *c) { bool force; - if (camu_screen_tick(&c->scr, &force) && !c->should_quit) { + if (!c->should_quit && camu_screen_tick(&c->scr, &force)) { if (!c->renderer->render(c->renderer, &c->scr, force)) { log_error("render() failed, forcing exit."); c->should_quit = 1; diff --git a/src/libsink/sink.c b/src/libsink/sink.c index 6c061a5..783f242 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -65,7 +65,7 @@ AL_STATIC_ASSERT(max_age_lt_lru, ENTRY_MAX_AGE, <, SINK_LRU_MAX); // Store connection number in the upper 16 bits so IDs don't conflict after a server restart. // If the sink disconnects but the server didn't restart, this will invalidate IDs that _do_ map // to the same resource. That could be wasteful. It's also currently (ab)used by reseek(). -#define LOCAL_ENTRY_ID(sink, id) (((u64)(sink)->connection_number) << 48 | (u64)(id)) +#define LOCAL_ENTRY_ID(sink, id) (((u64)(sink)->connection_number) << 48 | (u64)(id)) // id is a u32. #define REMOTE_ENTRY_ID(id) ((u32)(id & 0x7fffffff)) #define CONNECTION_NUMBER(id) ((id >> 48) & 0xffff) @@ -73,13 +73,8 @@ AL_STATIC_ASSERT(max_age_lt_lru, ENTRY_MAX_AGE, <, SINK_LRU_MAX); #define ENTRY_IS_VALID(entry) ((entry) && (entry) != (struct camu_sink_entry *)0xb00b) // printf format for entries. -#ifdef AL_DEBUG -#define ENTRY_FMT "#%u(%p)" // @TODO: Put static and ended here at least. -#define ENTRY_ARG(entry) (ENTRY_IS_VALID(entry) ? REMOTE_ENTRY_ID((entry)->id) : 0), ((entry) ? (entry) : 0x0) -#else -#define ENTRY_FMT "#%u" -#define ENTRY_ARG(entry) (ENTRY_IS_VALID(entry) ? REMOTE_ENTRY_ID((entry)->id) : 0) -#endif +#define ENTRY_FMT "#%u(%p)" +#define ENTRY_ARG(entry) (ENTRY_IS_VALID(entry) ? REMOTE_ENTRY_ID((entry)->id) : 0), (entry) #define AUDIO_STATE(entry) ((entry)->audio.state) #define VIDEO_STATE(entry) ((entry)->video.state) @@ -100,6 +95,7 @@ AL_STATIC_ASSERT(max_age_lt_lru, ENTRY_MAX_AGE, <, SINK_LRU_MAX); #define ENTRY_EVAL_ENDED(entry) \ ((AUDIO_ENDED(entry) && (VIDEO_ENDED(entry) || VIDEO_EMPTY(entry) || VIDEO_IS_STATIC(entry))) || \ (AUDIO_EMPTY(entry) && VIDEO_ENDED(entry))) +// This assert would fail if using ENTRY_ENDED() in end_entry_and_advance_queue() before setting entry->ended. #define ENTRY_ENDED(entry) (al_assert(entry->ended == ENTRY_EVAL_ENDED(entry)), entry->ended) // IGNORED = ENDED or EMPTY. @@ -921,16 +917,18 @@ static void evaluate_and_set_buffer_params(struct camu_sink *sink, struct camu_s camu_audio_buffer_set_latency(&entry->audio.buf, audio); camu_audio_buffer_set_no_video(&entry->audio.buf, ignore_video); camu_video_buffer_set_latency(&entry->video.buf, video); - log_info("video_latency: %f (%u frames), audio_latency: %f.", video, frames, audio); + log_info("video_latency: %fs (%u frames), audio_latency: %fs.", video, frames, audio); if (sink->local) { camu_audio_buffer_set_ignore_desync(&entry->audio.buf, ignore_video); // When the video buffer starts the clock, we have to consider the audio - // buffer is treating the last period of silence sent during a paused clock + // buffer is treating the last period of silence sent while the clock was paused // as part of the stream. This poses an issue for sync because it requires more - // than a period-length offset to not skip data at the start. Combined with the - // fact that the timing of a request for the next period doesn't have be uniform. - // Could make a diagram of this. // @TODO - camu_clock_offset(&entry->clock, MAX(audio, video)); + // than a period-length offset to not skip audio data at the start of the stream. + // Combined with the fact that the timing of a request for the next period + // doesn't have to be uniform. Something that is expected behavior but becomes + // a consideration when thinking about "Has the clock started yet?". + // @TODO: Could make a diagram of this. + camu_clock_offset(&entry->clock, MAX(audio, video) * 1.25); } } @@ -1053,10 +1051,11 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str case LIANA_CLIENT_REMOVE_BUFFERS: { struct lia_reconnect_info *rec = (struct lia_reconnect_info *)opaque; nn_mutex_lock(&sink->lock); + log_trace("remove_buffers("ENTRY_FMT", %s, %s), entry == current: %s, static: %s.", - ENTRY_ARG(entry), BOOLSTR(rec->reconnect), - BOOLSTR(rec->unconfigured), BOOLSTR(entry == sink->current), - BOOLSTR(!VIDEO_EMPTY(entry) ? VIDEO_IS_STATIC(entry) : false)); + ENTRY_ARG(entry), BOOLSTR(rec->reconnect), BOOLSTR(rec->unconfigured), + BOOLSTR(entry == sink->current), + BOOLSTR(!VIDEO_EMPTY(entry) && VIDEO_IS_STATIC(entry))); if (entry == sink->current) { if (rec->reconnect) { |