From bbf3314165182e402ff25acccddc004a87f81ef0 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Mon, 12 Feb 2024 21:09:10 -0500 Subject: Initial cmc implementation, sink fixes Signed-off-by: Andrew Opalach --- src/bimu/vcr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/bimu') diff --git a/src/bimu/vcr.c b/src/bimu/vcr.c index fcef62e..109edd7 100644 --- a/src/bimu/vcr.c +++ b/src/bimu/vcr.c @@ -26,8 +26,7 @@ static aki_thread_result AKI_THREADCALL vcr_stream_thread(void *userdata) { struct bmu_vcr_stream *stream = (struct bmu_vcr_stream *)userdata; struct bmu_vcr *vcr = stream->vcr; - do { - if (!aki_packet_cache_wait(&stream->cache)) break; + while (aki_packet_cache_wait(&stream->cache)) { struct aki_packet *packet = aki_packet_cache_pop(&stream->cache); if (!packet) { stream->client->handle_eof(stream->client); @@ -47,7 +46,7 @@ static aki_thread_result AKI_THREADCALL vcr_stream_thread(void *userdata) } stream->client->handle_data_packet(stream->client, packet); aki_packet_free(packet); - } while (1); + } return 0; } @@ -101,6 +100,8 @@ bool bmu_vcr_push_packet(struct bmu_vcr *vcr, struct aki_packet *packet) aki_packet_free(packet); al_log_warn("bimu", "Unhandled error packet."); break; + default: + al_assert(false); } return true; } @@ -114,7 +115,9 @@ static void vcr_stream_close_internal(struct bmu_vcr_stream *stream) aki_cond_signal(&stream->cond); } aki_mutex_unlock(&stream->mutex); - aki_thread_join(&stream->thread); + if (stream->running) { + aki_thread_join(&stream->thread); + } struct aki_packet *packet; while ((packet = aki_packet_cache_pop(&stream->cache))) { aki_packet_free(packet); -- cgit v1.2.3-101-g0448