summaryrefslogtreecommitdiff
path: root/src/bimu
diff options
context:
space:
mode:
Diffstat (limited to 'src/bimu')
-rw-r--r--src/bimu/vcr.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/bimu/vcr.c b/src/bimu/vcr.c
index 6c39d86..c5bb0e8 100644
--- a/src/bimu/vcr.c
+++ b/src/bimu/vcr.c
@@ -3,6 +3,10 @@
#include "vcr.h"
#include "handler.h"
+#define VCR_BUFFER_HIGH 1024
+#define VCR_BUFFER_BUFFERED (VCR_BUFFER_HIGH - 64)
+#define VCR_BUFFER_LOW (VCR_BUFFER_HIGH - 256)
+
static void signal_callback(void *userdata)
{
struct bmu_vcr *vcr = (struct bmu_vcr *)userdata;
@@ -29,7 +33,7 @@ static aki_thread_result AKI_THREADCALL vcr_stream_thread(void *userdata)
stream->client->handle_eof(stream->client);
break;
}
- if (al_atomic_u64_sub(&vcr->count, 1, AL_ATOMIC_RELAXED) < 128 && stream->buffered) {
+ if (al_atomic_u64_sub(&vcr->count, 1, AL_ATOMIC_RELAXED) < VCR_BUFFER_LOW && stream->buffered) {
aki_signal_send(&vcr->signal);
}
if (al_atomic_s32_load(&stream->state, AL_ATOMIC_RELAXED) == BIMU_STREAM_STOPPED) {
@@ -52,7 +56,7 @@ void bmu_vcr_add_stream(struct bmu_vcr *vcr, struct bmu_vcr_stream *stream)
stream->vcr = vcr;
aki_cond_init(&stream->cond);
aki_mutex_init(&stream->mutex);
- aki_packet_cache_init(&stream->cache, 256);
+ aki_packet_cache_init(&stream->cache, VCR_BUFFER_HIGH);
stream->buffered = false;
al_array_push(vcr->streams, stream);
al_atomic_s32_store(&stream->state, BIMU_STREAM_RUNNING, AL_ATOMIC_RELAXED);
@@ -80,7 +84,7 @@ bool bmu_vcr_push_packet(struct bmu_vcr *vcr, struct aki_packet *packet)
}
if (!aki_packet_cache_send_packet(&stream->cache, packet)) {
aki_packet_free(packet);
- } else if (al_atomic_u64_add(&vcr->count, 1, AL_ATOMIC_RELAXED) >= 196) {
+ } else if (al_atomic_u64_add(&vcr->count, 1, AL_ATOMIC_RELAXED) >= VCR_BUFFER_BUFFERED) {
aki_packet_stream_cork(vcr->data, true);
al_array_foreach(vcr->streams, i, stream) {
stream->buffered = true;