summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-01-15 20:52:07 -0500
committerAndrew Opalach <andrew@akon.city> 2024-01-15 20:52:07 -0500
commit863eda6c45a0ed0bf5f460dde6177c257d57cff8 (patch)
tree231d1e7a4dc62e365152a205de82feab3dcb11cd /src
parentbe3367fdbfaf7b62b94105cd55d1b9f1e30e9e58 (diff)
downloadcamu-863eda6c45a0ed0bf5f460dde6177c257d57cff8.tar.gz
camu-863eda6c45a0ed0bf5f460dde6177c257d57cff8.tar.bz2
camu-863eda6c45a0ed0bf5f460dde6177c257d57cff8.zip
Major build improvments (Windows sink)
- This commit won't run correctly because the signedness change is not handled by bimu server yet. Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src')
-rw-r--r--src/bimu/client.c5
-rw-r--r--src/bimu/client.h6
-rw-r--r--src/bimu/handler.h8
-rw-r--r--src/bimu/handlers/codec_server.c6
-rw-r--r--src/bimu/server.c4
-rw-r--r--src/bimu/server.h6
-rw-r--r--src/buffer/video.c2
-rw-r--r--src/codec/codec.h4
-rw-r--r--src/codec/libav/demuxer.c17
-rw-r--r--src/codec/libav/demuxer.h4
-rw-r--r--src/codec/libav/resampler.c2
-rw-r--r--src/codec/meson.build17
-rw-r--r--src/codec/spng/impl.c4
-rw-r--r--src/codec/stb_image/impl.c4
-rw-r--r--src/codec/wuffs/impl.c4
-rw-r--r--src/fruits/sink/meson.build8
-rw-r--r--src/mixer/meson.build11
-rw-r--r--src/mixer/mixer.c1
-rw-r--r--src/render/queue_libplacebo.c2
-rw-r--r--src/render/queue_tiger.h2
-rw-r--r--src/render/renderer_tiger.h2
-rw-r--r--src/screen/screen.c1
-rw-r--r--src/screen/view.c4
23 files changed, 62 insertions, 62 deletions
diff --git a/src/bimu/client.c b/src/bimu/client.c
index 8a72753..c592906 100644
--- a/src/bimu/client.c
+++ b/src/bimu/client.c
@@ -2,7 +2,10 @@
#include "../codec/libav/packet_ext.h"
+#include "handlers/codec.h"
+
#include "client.h"
+#include "common.h"
static void data_connection_callback(void *userdata, struct aki_packet_stream *stream)
{
@@ -109,7 +112,7 @@ static void control_connection_closed_callback(void *userdata, struct aki_packet
static void parse_info_packet(struct bmu_client *client, struct aki_packet *packet)
{
- client->duration = aki_packet_read_s64(packet);
+ client->duration = aki_packet_read_u64(packet);
u32 count = aki_packet_read_u32(packet);
for (u32 i = 0; i < count; i++) {
struct bmu_client_stream *stream = al_alloc_object(struct bmu_client_stream);
diff --git a/src/bimu/client.h b/src/bimu/client.h
index 0ebf282..8c9803b 100644
--- a/src/bimu/client.h
+++ b/src/bimu/client.h
@@ -3,9 +3,7 @@
#include <al/types.h>
#include <aki/packet_stream.h>
-#include "handlers/codec.h"
-
-#include "common.h"
+#include "../codec/codec.h"
struct bmu_client_stream {
u8 type;
@@ -23,7 +21,7 @@ struct bmu_client {
struct aki_packet_stream control;
struct aki_packet_stream data;
bool corked;
- s64 duration;
+ u64 duration;
array(s32) subscribed;
array(struct bmu_client_stream *) streams;
void (*callback)(void *, u8, struct bmu_client_stream *stream, void *);
diff --git a/src/bimu/handler.h b/src/bimu/handler.h
index 9b9d348..3646dd6 100644
--- a/src/bimu/handler.h
+++ b/src/bimu/handler.h
@@ -9,8 +9,8 @@ struct bmu_server_handler {
bool (*init)(struct bmu_server_handler *, struct cch_handle *, struct aki_packet_pool *);
void (*write_info)(struct bmu_server_handler *, struct aki_packet *);
void (*subscribe)(struct bmu_server_handler *, s32, bool);
- s64 (*get_duration)(struct bmu_server_handler *);
- bool (*seek)(struct bmu_server_handler *, s64);
+ u64 (*get_duration)(struct bmu_server_handler *);
+ bool (*seek)(struct bmu_server_handler *, u64);
bool (*step)(struct bmu_server_handler *);
void (*free)(struct bmu_server_handler **);
void *userdata;
@@ -23,8 +23,8 @@ enum {
};
enum {
- BIMU_CLIENT_SET = 0,
- BIMU_CLIENT_CONFIGURE,
+ BIMU_CLIENT_CONFIGURE = 0,
+ BIMU_CLIENT_SET,
BIMU_CLIENT_DATA,
BIMU_CLIENT_REMOVE_BUFFERS,
BIMU_CLIENT_EOF,
diff --git a/src/bimu/handlers/codec_server.c b/src/bimu/handlers/codec_server.c
index ca1c1b8..a30ce68 100644
--- a/src/bimu/handlers/codec_server.c
+++ b/src/bimu/handlers/codec_server.c
@@ -30,7 +30,7 @@ static bool codec_server_init(struct bmu_server_handler *handler, struct cch_han
static void codec_server_write_info(struct bmu_server_handler *handler, struct aki_packet *packet)
{
struct bmu_codec_server *codec = (struct bmu_codec_server *)handler;
- aki_packet_write_s64(packet, codec->demux->get_duration(codec->demux));
+ aki_packet_write_u64(packet, codec->demux->get_duration(codec->demux));
aki_packet_write_u32(packet, codec->demux->streams.size);
struct camu_stream *stream;
al_array_foreach_ptr(codec->demux->streams, i, stream) {
@@ -58,13 +58,13 @@ static void codec_server_subscribe(struct bmu_server_handler *handler, s32 index
}
}
-static s64 codec_server_get_duration(struct bmu_server_handler *handler)
+static u64 codec_server_get_duration(struct bmu_server_handler *handler)
{
struct bmu_codec_server *codec = (struct bmu_codec_server *)handler;
return codec->demux->get_duration(codec->demux);
}
-static bool codec_server_seek(struct bmu_server_handler *handler, s64 pos)
+static bool codec_server_seek(struct bmu_server_handler *handler, u64 pos)
{
struct bmu_codec_server *codec = (struct bmu_codec_server *)handler;
return codec->demux->seek(codec->demux, pos);
diff --git a/src/bimu/server.c b/src/bimu/server.c
index b823827..e1aedce 100644
--- a/src/bimu/server.c
+++ b/src/bimu/server.c
@@ -86,7 +86,7 @@ static void send_start_packet(struct bmu_node_connection *connection)
struct aki_packet *packet = aki_packet_create();
aki_packet_write_u8(packet, BIMU_CONTROL_START);
u64 ts = aki_get_timestamp() - START_DELAY;
- s64 seek_pos = connection->node->seek_pos;
+ u64 seek_pos = connection->node->seek_pos;
if (!connection->node->paused) {
if (connection->node->start >= 0) {
if ((ts - DELAY_GIVE) < (u64)connection->node->start) {
@@ -98,7 +98,7 @@ static void send_start_packet(struct bmu_node_connection *connection)
connection->node->start = ts;
}
}
- s64 duration = connection->handler->get_duration(connection->handler);
+ u64 duration = connection->handler->get_duration(connection->handler);
if (seek_pos > duration) seek_pos = duration;
// -1 signals to not call seek. We have to distinguish between a seek to 0
// and the start of a stream.
diff --git a/src/bimu/server.h b/src/bimu/server.h
index d954fa9..09fed99 100644
--- a/src/bimu/server.h
+++ b/src/bimu/server.h
@@ -25,7 +25,7 @@ struct bmu_node_connection {
struct aki_packet_pool pool;
s32 running;
u8 paused;
- s64 seek_pos;
+ u64 seek_pos;
struct cch_handle handle;
struct bmu_server_handler *handler;
struct aki_thread thread;
@@ -35,8 +35,8 @@ struct bmu_node {
u16 id;
struct cch_entry *entry;
bool paused;
- s64 start;
- s64 seek_pos;
+ u64 start;
+ u64 seek_pos;
u16 connection_id;
array(struct bmu_node_connection *) connections;
struct bmu_server *server;
diff --git a/src/buffer/video.c b/src/buffer/video.c
index de1f025..26e84b0 100644
--- a/src/buffer/video.c
+++ b/src/buffer/video.c
@@ -149,6 +149,8 @@ bool camu_video_buffer_read(struct camu_video_buffer *buf, void *out)
void camu_video_buffer_free(struct camu_video_buffer *buf)
{
+#ifdef CAMU_VIDEO_BUFFER_FORCE_SCALER
if (buf->fmt.scaler_needed) camu_lav_scaler_close(&buf->scale);
+#endif
buf->queue->free(&buf->queue);
}
diff --git a/src/codec/codec.h b/src/codec/codec.h
index 1309210..f9ba660 100644
--- a/src/codec/codec.h
+++ b/src/codec/codec.h
@@ -96,8 +96,8 @@ struct camu_demuxer {
u8 type;
bool (*init)(struct camu_demuxer *, struct cch_handle *);
s32 (*get_packet)(struct camu_demuxer *, struct camu_packet *);
- s64 (*get_duration)(struct camu_demuxer *);
- bool (*seek)(struct camu_demuxer *, s64);
+ u64 (*get_duration)(struct camu_demuxer *);
+ bool (*seek)(struct camu_demuxer *, u64);
void (*free)(struct camu_demuxer **);
array(struct camu_stream) streams;
array(s32) subscribed;
diff --git a/src/codec/libav/demuxer.c b/src/codec/libav/demuxer.c
index d823d23..18b9020 100644
--- a/src/codec/libav/demuxer.c
+++ b/src/codec/libav/demuxer.c
@@ -1,8 +1,7 @@
#include <al/log.h>
-#include "../common.h"
-
#include "demuxer.h"
+#include "avio.h"
#define BUF_SIZE 16384
@@ -63,11 +62,11 @@ static bool lav_demuxer_init(struct camu_demuxer *demux, struct cch_handle *hand
goto err;
}
- av->duration = 0;
-
#define GUESS_STREAM_IS_IMAGE(stream) \
(stream->duration >= 0 && stream->nb_frames <= 1 && (stream->avg_frame_rate.den == 0 && stream->r_frame_rate.den > 0))
+ av->duration = 0;
+
for (u32 i = 0; i < av->format_context->nb_streams; i++) {
AVStream *stream = av->format_context->streams[i];
enum AVMediaType type = stream->codecpar->codec_type;
@@ -88,7 +87,8 @@ static bool lav_demuxer_init(struct camu_demuxer *demux, struct cch_handle *hand
al_log_warn("lav_demux", "Stream has a negative start_time (%ld).", stream->start_time);
}
s64 duration = av_rescale_q(stream->duration, stream->time_base, AV_TIME_BASE_Q);
- if (duration > av->duration) av->duration = duration;
+ al_assert(duration >= 0);
+ if ((u64)duration > av->duration) av->duration = (u64)duration;
al_array_push(av->demux.streams, ((struct camu_stream){
.type = CAMU_FFMPEG_COMPAT,
.av.stream = stream
@@ -140,16 +140,17 @@ static s32 lav_demuxer_get_packet(struct camu_demuxer *demux, struct camu_packet
return ret;
}
-static s64 lav_demuxer_get_duration(struct camu_demuxer *demux)
+static u64 lav_demuxer_get_duration(struct camu_demuxer *demux)
{
struct camu_lav_demuxer *av = (struct camu_lav_demuxer *)demux;
return av->duration;
}
-static bool lav_demuxer_seek(struct camu_demuxer *demux, s64 pos)
+static bool lav_demuxer_seek(struct camu_demuxer *demux, u64 pos)
{
struct camu_lav_demuxer *av = (struct camu_lav_demuxer *)demux;
- s64 ts = av_rescale_q(pos, (AVRational){ 1, 1000000 }, AV_TIME_BASE_Q);
+ if (pos > av->duration) pos = av->duration;
+ s64 ts = av_rescale_q((s64)pos, (AVRational){ 1, 1000000 }, AV_TIME_BASE_Q);
if (av->eof) {
avformat_flush(av->format_context);
av->eof = false;
diff --git a/src/codec/libav/demuxer.h b/src/codec/libav/demuxer.h
index a9d8c5c..9b2d093 100644
--- a/src/codec/libav/demuxer.h
+++ b/src/codec/libav/demuxer.h
@@ -8,13 +8,11 @@
#include "../codec.h"
-#include "avio.h"
-
struct camu_lav_demuxer {
struct camu_demuxer demux;
AVIOContext *io_context;
AVFormatContext *format_context;
- s64 duration;
+ u64 duration;
bool eof;
};
diff --git a/src/codec/libav/resampler.c b/src/codec/libav/resampler.c
index 3dcb6d4..ba700f4 100644
--- a/src/codec/libav/resampler.c
+++ b/src/codec/libav/resampler.c
@@ -43,7 +43,7 @@ bool camu_lav_resampler_init(struct camu_lav_resampler *resamp, struct camu_lav_
av_opt_set_sample_fmt(ctx, "out_sample_fmt", fmt->req_format, 0);
// Slower but more accurate resampler.
- av_opt_set_int(ctx, "resampler", SWR_ENGINE_SOXR, 0);
+ //av_opt_set_int(ctx, "resampler", SWR_ENGINE_SOXR, 0);
if (swr_init(ctx) != 0) {
swr_free(&ctx);
diff --git a/src/codec/meson.build b/src/codec/meson.build
index a3951f0..676be1c 100644
--- a/src/codec/meson.build
+++ b/src/codec/meson.build
@@ -9,6 +9,7 @@ av_src = [
'libav/avio.c'
]
av_inc = []
+av_ldflags = []
av_deps = []
libavutil = dependency('libavutil', required: false)
@@ -24,28 +25,20 @@ if not (libavutil.found() and libavformat.found() and libavcodec.found() and lib
libavcodec = av_proj.get_variable('avcodec')
libswresample = av_proj.get_variable('swresample')
libswscale = av_proj.get_variable('swscale')
- #libdir = av_proj.get_variable('libdir')
- #libavutil = compiler.find_library('avutil', dirs: libdir)
- #libavformat = compiler.find_library('avformat', dirs: libdir)
- #libavcodec = compiler.find_library('avcodec', dirs: libdir)
- #libswresample = compiler.find_library('swresample', dirs: libdir)
- #libswscale = compiler.find_library('swscale', dirs: libdir)
- zlib = compiler.find_library('z', required: false)
- if zlib.found()
- av_deps += [zlib]
- endif
+ av_inc += [av_proj.get_variable('inc')]
+ av_ldflags += ['-L' + av_proj.get_variable('libdir')]
+ av_deps += [dependency('zlib')]
soxr = compiler.find_library('soxr', required: false)
if soxr.found()
av_deps += [soxr]
endif
av_deps += [compiler.find_library('bcrypt')]
- av_inc += [av_proj.get_variable('inc')]
endif
endif
if libavutil.found() and libavformat.found() and libavcodec.found() and libswresample.found() and libswscale.found()
av_deps += [libavutil, libavformat, libavcodec, libswresample, libswscale]
- av = declare_dependency(sources: av_src, dependencies: av_deps, include_directories: av_inc)
+ av = declare_dependency(sources: av_src, dependencies: av_deps, include_directories: av_inc, link_args: av_ldflags)
add_project_arguments('-DHAVE_FFMPEG', language: ['c', 'cpp'])
endif
diff --git a/src/codec/spng/impl.c b/src/codec/spng/impl.c
index d090bdc..9089e99 100644
--- a/src/codec/spng/impl.c
+++ b/src/codec/spng/impl.c
@@ -53,13 +53,13 @@ static s32 spng_demuxer_get_packet(struct camu_demuxer *demux, struct camu_packe
return CAMU_OK;
}
-static s64 spng_demuxer_get_duration(struct camu_demuxer *demux)
+static u64 spng_demuxer_get_duration(struct camu_demuxer *demux)
{
(void)demux;
return 0;
}
-static bool spng_demuxer_seek(struct camu_demuxer *demux, s64 pos)
+static bool spng_demuxer_seek(struct camu_demuxer *demux, u64 pos)
{
(void)demux;
(void)pos;
diff --git a/src/codec/stb_image/impl.c b/src/codec/stb_image/impl.c
index b7ed928..6058ff2 100644
--- a/src/codec/stb_image/impl.c
+++ b/src/codec/stb_image/impl.c
@@ -51,13 +51,13 @@ static s32 stbi_demuxer_get_packet(struct camu_demuxer *demux, struct camu_packe
return CAMU_OK;
}
-static s64 stbi_demuxer_get_duration(struct camu_demuxer *demux)
+static u64 stbi_demuxer_get_duration(struct camu_demuxer *demux)
{
(void)demux;
return 0;
}
-static bool stbi_demuxer_seek(struct camu_demuxer *demux, s64 pos)
+static bool stbi_demuxer_seek(struct camu_demuxer *demux, u64 pos)
{
(void)demux;
(void)pos;
diff --git a/src/codec/wuffs/impl.c b/src/codec/wuffs/impl.c
index a1e58e4..26e9011 100644
--- a/src/codec/wuffs/impl.c
+++ b/src/codec/wuffs/impl.c
@@ -72,13 +72,13 @@ static s32 wuffs_demuxer_get_packet(struct camu_demuxer *demux, struct camu_pack
return CAMU_OK;
}
-static s64 wuffs_demuxer_get_duration(struct camu_demuxer *demux)
+static u64 wuffs_demuxer_get_duration(struct camu_demuxer *demux)
{
(void)demux;
return 0;
}
-static bool wuffs_demuxer_seek(struct camu_demuxer *demux, s64 pos)
+static bool wuffs_demuxer_seek(struct camu_demuxer *demux, u64 pos)
{
(void)demux;
(void)pos;
diff --git a/src/fruits/sink/meson.build b/src/fruits/sink/meson.build
index c409857..8879937 100644
--- a/src/fruits/sink/meson.build
+++ b/src/fruits/sink/meson.build
@@ -1,5 +1,10 @@
sink_src = ['sink.c']
sink_deps = [common_deps, buffer, cache, av, screen, render, mixer, libsink]
+sink_args = []
+
+if meson.is_cross_build()
+ sink_args += ['-static', '-static-libgcc', '-static-libstdc++']
+endif
use_tui = false
if use_tui
@@ -7,4 +12,5 @@ if use_tui
sink_deps += [dependency('notcurses')]
endif
-executable('sink', sink_src, dependencies: sink_deps)
+executable('sink', sink_src, dependencies: sink_deps,
+ c_args: sink_args, cpp_args: sink_args, link_args: sink_args)
diff --git a/src/mixer/meson.build b/src/mixer/meson.build
index 53389eb..52125ce 100644
--- a/src/mixer/meson.build
+++ b/src/mixer/meson.build
@@ -4,10 +4,6 @@ mixer_deps = [common_deps]
miniaudio = subproject('miniaudio').get_variable('miniaudio')
mixer_src += ['audio_miniaudio.c']
mixer_deps += [miniaudio]
-if host_machine.system() != 'windows'
- libpulse = dependency('libpulse')
- mixer_deps += [libpulse]
-endif
miniaudio_args = [
'-DMA_NO_JACK',
@@ -18,8 +14,13 @@ miniaudio_args = [
'-DMA_NO_RESOURCE_MANAGER',
'-DMA_NO_NODE_GRAPH',
'-DMA_NO_ENGINE',
- '-DMA_NO_RUNTIME_LINKING'
]
+if not is_windows
+ libpulse = dependency('libpulse')
+ mixer_deps += [libpulse]
+ miniaudio_args += ['-DMA_NO_RUNTIME_LINKING']
+endif
+
mixer = declare_dependency(sources: mixer_src, dependencies: mixer_deps,
compile_args: miniaudio_args)
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index 646f056..663e7aa 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -1,5 +1,4 @@
#include "../buffer/audio.h"
-#include "../buffer/clock.h"
#include "mixer.h"
diff --git a/src/render/queue_libplacebo.c b/src/render/queue_libplacebo.c
index 327397f..de9df44 100644
--- a/src/render/queue_libplacebo.c
+++ b/src/render/queue_libplacebo.c
@@ -120,7 +120,7 @@ static void discard_av_frame(const struct pl_source_frame *src)
{
AVFrame *frame = src->frame_data;
av_frame_free(&frame);
- al_log_info("frame_queue_libplacebo", "Dropped frame with PTS %.3f.", src->pts);
+ al_log_debug("frame_queue_libplacebo", "Dropped frame with PTS %.3f.", src->pts);
}
static void queue_lp_push_av_frame(struct camu_frame_queue *queue, AVFrame *frame, f64 pts)
diff --git a/src/render/queue_tiger.h b/src/render/queue_tiger.h
index 1524a29..db675df 100644
--- a/src/render/queue_tiger.h
+++ b/src/render/queue_tiger.h
@@ -1,6 +1,6 @@
#pragma once
-#include <skh/egl.h>
+#include <skh/gl.h>
#include "../buffer/frame_queue.h"
diff --git a/src/render/renderer_tiger.h b/src/render/renderer_tiger.h
index e9a7eb0..2979d91 100644
--- a/src/render/renderer_tiger.h
+++ b/src/render/renderer_tiger.h
@@ -1,6 +1,6 @@
#pragma once
-#include <skh/egl.h>
+#include <skh/gl.h>
#include "renderer.h"
diff --git a/src/screen/screen.c b/src/screen/screen.c
index dd4bdc6..94b5d8c 100644
--- a/src/screen/screen.c
+++ b/src/screen/screen.c
@@ -260,7 +260,6 @@ static void add_buffer_internal(struct camu_screen *scr, struct camu_video_buffe
#endif
camu_view_calculate(&video.view, scr->width, scr->height);
al_array_push(scr->videos, video);
- scr->window->resize(scr->window, stream->video.width, stream->video.height);
}
static void remove_buffer_internal(struct camu_screen *scr, struct camu_video_buffer *buf)
diff --git a/src/screen/view.c b/src/screen/view.c
index 4cf6007..dddc11a 100644
--- a/src/screen/view.c
+++ b/src/screen/view.c
@@ -33,8 +33,8 @@ void camu_view_calculate(struct camu_view *view, s32 window_width, s32 window_he
default:
return;
}
- view->x_offset = ((window_width - (view->width * view->zoom)) / 2.0);
- view->y_offset = ((window_height - (view->height * view->zoom)) / 2.0);
+ view->x_offset = (window_width - (view->width * view->zoom)) / 2.0;
+ view->y_offset = (window_height - (view->height * view->zoom)) / 2.0;
}
bool camu_view_pan_simple(struct camu_view *view, s32 window_width, s32 window_height, f64 dx, f64 dy)