From 4cf920c19de38b32d7c64152f763486f9425e75a Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 18 May 2026 15:03:56 -0400 Subject: [PATCH] MT#55283 enable separate compilation of lib/* Change-Id: Ib9b9f7d2a55920f99a5224c86a7e563d76a316e7 --- include/ssrc.h | 29 +---------------------------- lib/Makefile | 27 ++++++++++++++++++++++----- lib/common.Makefile | 6 ++++-- lib/mix_buffer.c | 2 +- lib/mix_buffer.h | 3 ++- lib/ssrclib.h | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 37 deletions(-) create mode 100644 lib/ssrclib.h diff --git a/include/ssrc.h b/include/ssrc.h index e49061a84..15f627618 100644 --- a/include/ssrc.h +++ b/include/ssrc.h @@ -9,6 +9,7 @@ #include "obj.h" #include "codeclib.h" #include "types.h" +#include "ssrclib.h" #define MAX_SSRC_ENTRIES 20 @@ -17,16 +18,6 @@ struct ssrc_entry; struct ssrc_entry_call; enum ssrc_dir; -typedef struct ssrc_entry *(*ssrc_create_func_t)(void *uptr); - -struct ssrc_hash { - GQueue nq; - mutex_t lock; - ssrc_create_func_t create_func; - void *uptr; - struct ssrc_entry *precreat; // next used entry - unsigned int iters; // tracks changes -}; struct payload_tracker { mutex_t lock; unsigned char last[32]; // must be <= 255 @@ -49,13 +40,6 @@ struct ssrc_stats_block { uint64_t mos; // nominal range of 10 - 50 for MOS values 1.0 to 5.0 }; -struct ssrc_entry { - struct obj obj; - GList link; - mutex_t lock; - uint32_t ssrc; -}; - struct ssrc_entry_call { struct ssrc_entry h; // must be first @@ -194,19 +178,8 @@ struct crtt_args { }; - -void ssrc_hash_destroy(struct ssrc_hash *); -void ssrc_hash_foreach(struct ssrc_hash *, void (*)(void *, void *), void *); -void ssrc_hash_full_init(struct ssrc_hash *, ssrc_create_func_t, void *uptr); // pre-creates one object -void ssrc_hash_full_fast_init(struct ssrc_hash *, ssrc_create_func_t, void *uptr); // doesn't pre-create object - void ssrc_hash_call_init(struct ssrc_hash *); -void *get_ssrc_full(uint32_t, struct ssrc_hash *, bool *created); // creates new entry if not found -INLINE void *get_ssrc(uint32_t ssrc, struct ssrc_hash *ht) { - return get_ssrc_full(ssrc, ht, NULL); -} - INLINE struct ssrc_entry_call *call_get_first_ssrc(struct ssrc_hash *ht) { return ht->nq.head ? ht->nq.head->data : NULL; } diff --git a/lib/Makefile b/lib/Makefile index d727c3383..d796bf76d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,7 +1,24 @@ -.PHONY: clean distclean +export top_srcdir = .. -.DEFAULT: - true +include ../lib/deps.Makefile -clean distclean: - rm -f *.strhash.* +include ../lib/flags.Makefile + +CFLAGS += $(CFLAGS_GLIB) +CFLAGS += $(CFLAGS_JSON_GLIB) +CFLAGS += $(CFLAGS_LIBPCRE) +ifeq ($(with_transcoding),yes) +CFLAGS += $(CFLAGS_OPUS) +endif + +SRCS = auxlib.c bencode.c bufferpool.c codeclib.strhash.c dtmflib.c +SRCS += http.c loglib.c mix_buffer.c +SRCS += netfilter_api.c oauth.c poller.c resample.c +SRCS += rtplib.c s3utils.c socket.c +SRCS += ssllib.c str.c streambuf.c uring.c + +ASM = mix_in_x64_avx2.S mix_in_x64_avx512bw.S mix_in_x64_sse2.S mvr2s_x64_avx2.S mvr2s_x64_avx512.S + +include common.Makefile + +all: $(OBJS) diff --git a/lib/common.Makefile b/lib/common.Makefile index 791ebb019..378b44847 100644 --- a/lib/common.Makefile +++ b/lib/common.Makefile @@ -7,13 +7,15 @@ all: $(TARGET) $(MANS) OBJS = $(SRCS:.c=.o) +ASMOBJS = $(ASM:.S=.o) + LIBOBJS = $(LIBSRCS:.c=.o) DAEMONOBJS = $(DAEMONSRCS:.c=.o) LIBASMOBJS = $(LIBASM:.S=.o) -ALLOBJS = $(OBJS) $(LIBOBJS) $(LIBASMOBJS) $(DAEMONOBJS) +ALLOBJS = $(OBJS) $(LIBOBJS) $(LIBASMOBJS) $(DAEMONOBJS) $(ASMOBJS) $(OBJS): %.o: %.c @@ -54,7 +56,7 @@ $(ALLOBJS): Makefile ../include/* ../lib/*.h ../kernel-module/*.h -M "date:$(BUILD_DATE)" \ -o "$@" -resample.c ../lib/codeclib.strhash.c mix.c packet.c: ../lib/fix_frame_channel_layout.h +resample.c codeclib.strhash.c mix.c packet.c: ../lib/fix_frame_channel_layout.h ifeq ($(with_transcoding),yes) ../daemon/codec.c codec.c: ../lib/dtmf_rx_fillin.h diff --git a/lib/mix_buffer.c b/lib/mix_buffer.c index 66fa33ad1..089f89453 100644 --- a/lib/mix_buffer.c +++ b/lib/mix_buffer.c @@ -5,7 +5,7 @@ #include #include #include -#include "ssrc.h" +#include "ssrclib.h" typedef void mix_in_fn_t(void *restrict dst, const void *restrict src, unsigned int num); diff --git a/lib/mix_buffer.h b/lib/mix_buffer.h index 72e207543..266462f8e 100644 --- a/lib/mix_buffer.h +++ b/lib/mix_buffer.h @@ -4,7 +4,8 @@ #include #include #include "helpers.h" -#include "ssrc.h" +#include "ssrclib.h" +#include "codeclib.h" enum AVSampleFormat; diff --git a/lib/ssrclib.h b/lib/ssrclib.h new file mode 100644 index 000000000..b7bb01b5b --- /dev/null +++ b/lib/ssrclib.h @@ -0,0 +1,36 @@ +#ifndef _SSRCLIB_H_ +#define _SSRCLIB_H_ + +#include "obj.h" +#include +#include + +struct ssrc_entry { + struct obj obj; + GList link; + mutex_t lock; + uint32_t ssrc; +}; + +typedef struct ssrc_entry *(*ssrc_create_func_t)(void *uptr); + +struct ssrc_hash { + GQueue nq; + mutex_t lock; + ssrc_create_func_t create_func; + void *uptr; + struct ssrc_entry *precreat; // next used entry + unsigned int iters; // tracks changes +}; + +void ssrc_hash_foreach(struct ssrc_hash *, void (*)(void *, void *), void *); +void ssrc_hash_full_init(struct ssrc_hash *, ssrc_create_func_t, void *uptr); // pre-creates one object +void ssrc_hash_full_fast_init(struct ssrc_hash *, ssrc_create_func_t, void *uptr); // doesn't pre-create object +void ssrc_hash_destroy(struct ssrc_hash *); + +void *get_ssrc_full(uint32_t, struct ssrc_hash *, bool *created); // creates new entry if not found +INLINE void *get_ssrc(uint32_t ssrc, struct ssrc_hash *ht) { + return get_ssrc_full(ssrc, ht, NULL); +} + +#endif