Skip to content

Commit

Permalink
amix/aumix: add slmagic record routing
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Oct 10, 2024
1 parent c7dfaa3 commit ad84153
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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
Expand Down
20 changes: 19 additions & 1 deletion modules/amix/amix.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct amix {
struct aumix_source *aumix_src;
char *device;
uint16_t speaker_id;
bool magic;
bool muted;
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -303,18 +311,28 @@ 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)
return;

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);
Expand Down
54 changes: 54 additions & 0 deletions patches/re_aumix_record_only.patch
Original file line number Diff line number Diff line change
@@ -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
*

0 comments on commit ad84153

Please sign in to comment.