From 9a2bc6900295b01caa41058fb683f06be19de92b Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Mon, 7 Oct 2024 09:55:22 +0200 Subject: [PATCH 1/5] mk: add slmagic pro patch (not open source) --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index b6e31f7..60183ee 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,9 @@ systemd: external -DCMAKE_C_FLAGS="-g -DJBUF_STAT" -DUSE_SD_SOCK=ON -DUSE_TLS1_3_PHA=OFF make build +.PHONY: systemd_pro +systemd_pro: external_pro systemd + .PHONY: unix unix: external make clean @@ -48,6 +51,11 @@ external: cd external/re && \ patch -p1 < ../../patches/re_aubuf_timestamp_order_fix.patch +.PHONY: external_pro +external_pro: external + cd external/baresip && \ + patch -p1 < ../../../mix_pro/patches/slmagic.diff + ############################################################################## # # Sanitizers From 7e2b87e6e2a67ef2990633ca06d8083cf522e39e Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Thu, 10 Oct 2024 07:06:44 +0200 Subject: [PATCH 2/5] amix/aumix: add slmagic record routing --- Makefile | 3 +- modules/amix/amix.c | 20 ++++++++++- patches/re_aumix_record_only.patch | 54 ++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 patches/re_aumix_record_only.patch diff --git a/Makefile b/Makefile index 60183ee..f8990df 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,8 @@ external: git clone --depth 1 -b playout_time \ https://github.com/baresip/baresip.git external/baresip cd external/re && \ - patch -p1 < ../../patches/re_aubuf_timestamp_order_fix.patch + patch -p1 < ../../patches/re_aubuf_timestamp_order_fix.patch && \ + patch -p1 < ../../patches/re_aumix_record_only.patch .PHONY: external_pro external_pro: external diff --git a/modules/amix/amix.c b/modules/amix/amix.c index 260971f..f8c1eb6 100644 --- a/modules/amix/amix.c +++ b/modules/amix/amix.c @@ -42,6 +42,7 @@ struct amix { struct aumix_source *aumix_src; char *device; uint16_t speaker_id; + bool magic; bool muted; }; @@ -140,6 +141,13 @@ static int amix_alloc(struct amix **amixp, const char *device) amix->muted = true; + if (strstr(device, "slmagic")) { + amix->magic = true; + aumix_source_mute(amix->aumix_src, amix->muted); + aumix_source_enable(amix->aumix_src, true); + aumix_source_record_only(amix->aumix_src, true); + } + out: if (err) { mem_deref(amix); @@ -306,7 +314,9 @@ static int play_alloc(struct auplay_st **stp, const struct auplay *ap, void amix_mute(const char *dev, bool mute, uint16_t id); void amix_mute(const char *dev, bool mute, uint16_t id) { - struct le *le; + struct le *le, *le_magic; + char dev_magic[128]; + struct amix *amix_magic = NULL; le = hash_lookup(amixl, hash_joaat_str(dev), dev_cmp_h, (void *)dev); if (!le) @@ -314,10 +324,18 @@ void amix_mute(const char *dev, bool mute, uint16_t id) struct amix *amix = le->data; + re_snprintf(dev_magic, sizeof(dev_magic), "%s_slmagic", dev); + le_magic = hash_lookup(amixl, hash_joaat_str(dev_magic), dev_cmp_h, + (void *)dev_magic); + if (le_magic) + amix_magic = le_magic->data; + aumix_source_mute(amix->aumix_src, mute); amix->muted = mute; if (id) { amix->speaker_id = id; + if (amix_magic) + amix_magic->speaker_id = 10000 + id; if (!list_contains(&speakerl, &amix->sle)) list_append(&speakerl, &amix->sle, amix); diff --git a/patches/re_aumix_record_only.patch b/patches/re_aumix_record_only.patch new file mode 100644 index 0000000..d1b33ea --- /dev/null +++ b/patches/re_aumix_record_only.patch @@ -0,0 +1,54 @@ +diff --git a/rem/aumix/aumix.c b/rem/aumix/aumix.c +index 95032be..b46fbf7 100644 +--- a/rem/aumix/aumix.c ++++ b/rem/aumix/aumix.c +@@ -47,6 +47,7 @@ struct aumix_source { + aumix_read_h *readh; + void *arg; + bool muted; ++ bool record_only; + }; + + +@@ -193,6 +194,9 @@ static int aumix_thread(void *arg) + if (csrc->muted) + continue; + ++ if (csrc->record_only) ++ continue; ++ + for (size_t i = 0; i < mix->frame_size; i++) { + sample = mix_frame[i] + csrc->frame[i]; + +@@ -222,6 +226,9 @@ static int aumix_thread(void *arg) + if (csrc->muted) + continue; + ++ if(!csrc->record_only) ++ continue; ++ + for (size_t i = 0; i < mix->frame_size; i++) { + sample = mix_frame[i] + csrc->frame[i]; + +@@ -493,6 +500,21 @@ void aumix_source_mute(struct aumix_source *src, bool mute) + } + + ++/** ++ * Record only aumix source ++ * ++ * @param src Audio mixer source ++ * @param mute True to record only, false to disable ++ */ ++void aumix_source_record_only(struct aumix_source *src, bool enable) ++{ ++ if (!src) ++ return; ++ ++ src->record_only = enable; ++} ++ ++ + /** + * Enable/disable aumix source + * From f4e785aa857b105319bf6164757bba79c96bfbd4 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Thu, 10 Oct 2024 12:36:15 +0200 Subject: [PATCH 3/5] fix record only patch --- patches/re_aumix_record_only.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/patches/re_aumix_record_only.patch b/patches/re_aumix_record_only.patch index d1b33ea..330a0b3 100644 --- a/patches/re_aumix_record_only.patch +++ b/patches/re_aumix_record_only.patch @@ -1,3 +1,15 @@ +diff --git a/include/rem_aumix.h b/include/rem_aumix.h +index 4017fa2..b417fb3 100644 +--- a/include/rem_aumix.h ++++ b/include/rem_aumix.h +@@ -29,6 +29,7 @@ int aumix_source_alloc(struct aumix_source **srcp, struct aumix *mix, + void aumix_source_set_id(struct aumix_source *src, uint16_t id); + void aumix_source_enable(struct aumix_source *src, bool enable); + void aumix_source_mute(struct aumix_source *src, bool mute); ++void aumix_source_record_only(struct aumix_source *src, bool enable); + int aumix_source_put(struct aumix_source *src, const int16_t *sampv, + size_t sampc); + void aumix_source_readh(struct aumix_source *src, aumix_read_h *readh); diff --git a/rem/aumix/aumix.c b/rem/aumix/aumix.c index 95032be..b46fbf7 100644 --- a/rem/aumix/aumix.c From ba01a40e142f7f5d5073f8868afd09360a084924 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Fri, 11 Oct 2024 20:47:01 +0200 Subject: [PATCH 4/5] fix amix_mute slmagic --- modules/amix/amix.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/amix/amix.c b/modules/amix/amix.c index f8c1eb6..4a1908a 100644 --- a/modules/amix/amix.c +++ b/modules/amix/amix.c @@ -316,7 +316,6 @@ void amix_mute(const char *dev, bool mute, uint16_t id) { struct le *le, *le_magic; char dev_magic[128]; - struct amix *amix_magic = NULL; le = hash_lookup(amixl, hash_joaat_str(dev), dev_cmp_h, (void *)dev); if (!le) @@ -324,22 +323,24 @@ void amix_mute(const char *dev, bool mute, uint16_t id) struct amix *amix = le->data; - re_snprintf(dev_magic, sizeof(dev_magic), "%s_slmagic", dev); - le_magic = hash_lookup(amixl, hash_joaat_str(dev_magic), dev_cmp_h, - (void *)dev_magic); - if (le_magic) - amix_magic = le_magic->data; - aumix_source_mute(amix->aumix_src, mute); amix->muted = mute; if (id) { amix->speaker_id = id; - if (amix_magic) - amix_magic->speaker_id = 10000 + id; if (!list_contains(&speakerl, &amix->sle)) list_append(&speakerl, &amix->sle, amix); } + + re_snprintf(dev_magic, sizeof(dev_magic), "%s_slmagic", dev); + le_magic = hash_lookup(amixl, hash_joaat_str(dev_magic), dev_cmp_h, + (void *)dev_magic); + if (id && le_magic) { + struct amix *amix_magic = le_magic->data; + aumix_source_mute(amix_magic->aumix_src, mute); + amix_magic->muted = mute; + amix_magic->speaker_id = 10000 + id; + } } From 9ebd97cac517b1baa7038fd37bf8d0e61fad0359 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Tue, 15 Oct 2024 15:41:27 +0200 Subject: [PATCH 5/5] mk: add build_pro --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index f8990df..ba9e3fa 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ build: external -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-gdwarf-4 -g3 -DJBUF_STAT -DRE_RTP_PCAP" @cmake --build build --parallel +.PHONY: build_pro +build_pro: external_pro build + .PHONY: webui webui: cd webui && npm install && npm run build-only