diff --git a/Makefile b/Makefile index b6e31f79..ba9e3fa3 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 @@ -32,6 +35,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 @@ -46,7 +52,13 @@ 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 + cd external/baresip && \ + patch -p1 < ../../../mix_pro/patches/slmagic.diff ############################################################################## # diff --git a/modules/amix/amix.c b/modules/amix/amix.c index 260971ff..4a1908a3 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,8 @@ 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]; le = hash_lookup(amixl, hash_joaat_str(dev), dev_cmp_h, (void *)dev); if (!le) @@ -322,6 +331,16 @@ void amix_mute(const char *dev, bool mute, uint16_t 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; + } } diff --git a/patches/re_aumix_record_only.patch b/patches/re_aumix_record_only.patch new file mode 100644 index 00000000..330a0b33 --- /dev/null +++ b/patches/re_aumix_record_only.patch @@ -0,0 +1,66 @@ +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 ++++ 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 + *