static void recv(struct mwService *srvc, struct mwChannel *chan, guint16 type, struct mwOpaque *data) { struct mwServiceConference *srvc_conf = (struct mwServiceConference *) srvc; struct mwConference *conf = conf_find(srvc_conf, chan); struct mwGetBuffer *b; g_return_if_fail(conf != NULL); b = mwGetBuffer_wrap(data); switch(type) { case msg_WELCOME: WELCOME_recv(srvc_conf, conf, b); break; case msg_JOIN: JOIN_recv(srvc_conf, conf, b); break; case msg_PART: PART_recv(srvc_conf, conf, b); break; case msg_MESSAGE: MESSAGE_recv(srvc_conf, conf, b); break; default: ; /* hrm. should log this. TODO */ } }
static void recv_channelDestroy(struct mwService *srvc, struct mwChannel *chan, struct mwMsgChannelDestroy *msg) { /* - find conference from channel - trigger got_closed - remove conference, dealloc */ struct mwServiceConference *srvc_conf = (struct mwServiceConference *) srvc; struct mwConference *conf = conf_find(srvc_conf, chan); struct mwConferenceHandler *h = srvc_conf->handler; /* if there's no such conference, then I guess there's nothing to worry about. Except of course for the fact that we should never receive a channel destroy for a conference that doesn't exist. */ if(! conf) return; conf->channel = NULL; conf_state(conf, msg->reason? mwConference_ERROR: mwConference_CLOSING); if(h->conf_closed) h->conf_closed(conf, msg->reason); mwConference_destroy(conf, ERR_SUCCESS, NULL); }
void streamer_dsp_init (void) { // load dsp chain from file char fname[PATH_MAX]; snprintf (fname, sizeof (fname), "%s/dspconfig", plug_get_config_dir ()); dsp_chain = streamer_dsp_chain_load (fname); if (!dsp_chain) { // first run, let's add resampler DB_dsp_t *src = (DB_dsp_t *)plug_get_for_id ("SRC"); if (src) { ddb_dsp_context_t *inst = src->open (); inst->enabled = 1; src->set_param (inst, 0, "48000"); // samplerate src->set_param (inst, 1, "2"); // quality=SINC_FASTEST src->set_param (inst, 2, "1"); // auto inst->next = dsp_chain; dsp_chain = inst; } } eqplug = (DB_dsp_t *)plug_get_for_id ("supereq"); streamer_dsp_postinit (); // load legacy eq settings from pre-0.5 if (eq && eqplug && conf_find ("eq.", NULL)) { eq->enabled = deadbeef->conf_get_int ("eq.enable", 0); char s[50]; // 0.4.4 was writing buggy settings, need to multiply by 2 to compensate conf_get_str ("eq.preamp", "0", s, sizeof (s)); snprintf (s, sizeof (s), "%f", atof(s)*2); eqplug->set_param (eq, 0, s); for (int i = 0; i < 18; i++) { char key[100]; snprintf (key, sizeof (key), "eq.band%d", i); conf_get_str (key, "0", s, sizeof (s)); snprintf (s, sizeof (s), "%f", atof(s)*2); eqplug->set_param (eq, 1+i, s); } // delete obsolete settings conf_remove_items ("eq."); } }
static void process(bl_t bl) { struct sockaddr_storage rss; socklen_t rsl; char rbuf[BUFSIZ]; bl_info_t *bi; struct conf c; struct dbinfo dbi; struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { (*lfun)(LOG_ERR, "clock_gettime failed (%m)"); return; } if ((bi = bl_recv(bl)) == NULL) { (*lfun)(LOG_ERR, "no message (%m)"); return; } if (getremoteaddress(bi, &rss, &rsl) == -1) goto out; if (debug) { sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss); (*lfun)(LOG_DEBUG, "processing type=%d fd=%d remote=%s msg=%s" " uid=%lu gid=%lu", bi->bi_type, bi->bi_fd, rbuf, bi->bi_msg, (unsigned long)bi->bi_uid, (unsigned long)bi->bi_gid); } if (conf_find(bi->bi_fd, bi->bi_uid, &rss, &c) == NULL) { (*lfun)(LOG_DEBUG, "no rule matched"); goto out; } if (state_get(state, &c, &dbi) == -1) goto out; if (debug) { char b1[128], b2[128]; (*lfun)(LOG_DEBUG, "%s: db state info for %s: count=%d/%d " "last=%s now=%s", __func__, rbuf, dbi.count, c.c_nfail, fmttime(b1, sizeof(b1), dbi.last), fmttime(b2, sizeof(b2), ts.tv_sec)); } switch (bi->bi_type) { case BL_ADD: dbi.count++; dbi.last = ts.tv_sec; if (dbi.id[0]) { /* * We should not be getting this since the rule * should have blocked the address. A possible * explanation is that someone removed that rule, * and another would be that we got another attempt * before we added the rule. In anycase, we remove * and re-add the rule because we don't want to add * it twice, because then we'd lose track of it. */ (*lfun)(LOG_DEBUG, "rule exists %s", dbi.id); (void)run_change("rem", &c, dbi.id, 0); dbi.id[0] = '\0'; } if (c.c_nfail != -1 && dbi.count >= c.c_nfail) { int res = run_change("add", &c, dbi.id, sizeof(dbi.id)); if (res == -1) goto out; sockaddr_snprintf(rbuf, sizeof(rbuf), "%a", (void *)&rss); (*lfun)(LOG_INFO, "blocked %s/%d:%d for %d seconds", rbuf, c.c_lmask, c.c_port, c.c_duration); } break; case BL_DELETE: if (dbi.last == 0) goto out; dbi.last = 0; break; default: (*lfun)(LOG_ERR, "unknown message %d", bi->bi_type); } if (state_put(state, &c, &dbi) == -1) goto out; out: close(bi->bi_fd); }