Skip to content

Commit

Permalink
fix muting on mqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
z-dule committed Apr 24, 2024
1 parent 190a8f9 commit 6b90ebd
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions src/peerflow/peerflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ static void push_mq(struct mq_data *md)

mqueue_push(g_pf.mq.q, md->id, md);
lock_rel(g_pf.mq.lock);

}

static void send_close(struct peerflow *pf, int err)
Expand Down Expand Up @@ -514,6 +513,7 @@ static void handle_mq(struct peerflow *pf, struct mq_data *md, int id)
break;

case MQ_INTERNAL_SET_MUTE:
info("%s SET_MUTE\n", __FUNCTION__);
set_all_mute(g_pf.audio.muted);
break;

Expand Down Expand Up @@ -581,14 +581,15 @@ static void run_all_mq(void)
struct mq_data *md = (struct mq_data *)le->data;
struct mq_entry *mqe;

le = le->next;

mqe = (struct mq_entry *)mem_zalloc(sizeof(*mqe), mqe_destructor);
if (!mqe)
continue;

mqe->md = md;
list_append(&mql, &mqe->le, mqe);

le = le->next;
list_unlink(&md->le);
}
lock_rel(g_pf.mq.lock);
Expand All @@ -599,19 +600,20 @@ static void run_all_mq(void)
struct peerflow *pf = md->pf;

lock_write_get(g_pf.lock);
if (valid_pf(pf)) {
if (pf && valid_pf(pf)) {
pf = (struct peerflow *)mem_ref(pf);
}
else {
else if (pf) {
debug("pf(%p): handle_all: spurious event: 0x%02x\n", pf, md->id);
pf = NULL;
lock_rel(g_pf.lock);
continue;
}
lock_rel(g_pf.lock);

if (pf != NULL) {
if (!md->handled) {
handle_mq(pf, md, md->id);
}
if (!md->handled) {
handle_mq(pf, md, md->id);
}
if (pf) {
lock_write_get(g_pf.lock);
mem_deref(pf);
lock_rel(g_pf.lock);
Expand All @@ -622,23 +624,7 @@ static void run_all_mq(void)

static void mq_handler(int id, void *data, void *arg)
{
struct mq_data *md = (struct mq_data *)data;
struct peerflow *pf = md->pf;

(void)arg;

switch(id) {
case MQ_INTERNAL_SET_MUTE:
pf = NULL;
break;

default:
run_all_mq();
break;
}

out:
return;
run_all_mq();
}


Expand Down

0 comments on commit 6b90ebd

Please sign in to comment.