static void menu_on_incoming_call_reject(GtkMenuItem *menuItem, struct gtk_mod *mod) { struct call *call = g_object_get_data(G_OBJECT(menuItem), "call"); denotify_incoming_call(mod, call); mqueue_push(mod->mq, MQ_HANGUP, call); }
static void menu_on_dial_contact(GtkMenuItem *menuItem, gpointer arg) { struct gtk_mod *mod = arg; const char *uri = gtk_menu_item_get_label(menuItem); /* Queue dial from the main thread */ mqueue_push(mod->mq, MQ_CONNECT, (char *)uri); }
static void menu_on_account_toggled(GtkCheckMenuItem *menu_item, struct gtk_mod *mod) { struct ua *ua = g_object_get_data(G_OBJECT(menu_item), "ua"); if (menu_item->active) mqueue_push(mod->mq, MQ_SELECT_UA, ua); }
static DWORD WINAPI input_thread(LPVOID arg) { struct ui_st *st = arg; /* Switch to raw mode */ SetConsoleMode(st->hstdin, 0); while (st->run) { char buf[4]; DWORD i, count = 0; ReadConsole(st->hstdin, buf, sizeof(buf), &count, NULL); for (i=0; i<count; i++) { int ch = buf[i]; if (ch == '\r') ch = '\n'; /* * The keys are read from a thread so we have * to send them to the RE main event loop via * a message queue */ mqueue_push(st->mq, ch, 0); } } return 0; }
int tea_thread_msg_push(int tid, INET_ADDR *addr, void *msg, int msg_size) { TEA_MSG *tmsg; int r = 0; pthreadex_lock_get_shared(&ttable_lock); if(ttable[tid]) { if(ttable[tid]->mqueue) { tmsg = msg_get(); if(addr) msg_set_addr(tmsg, addr); msg_fill(tmsg, msg, msg_size); mqueue_push(ttable[tid]->mqueue, tmsg); pthreadex_flag_up(&(ttable[tid]->mwaiting)); } else DBG("[tea] network message ignored by %d", tid); } else r = -1; pthreadex_lock_release(); return r; }
static int cmd_popup_menu(struct re_printf *pf, void *unused) { (void)pf; (void)unused; mqueue_push(mod_obj.mq, MQ_POPUP, GUINT_TO_POINTER(GDK_CURRENT_TIME)); return 0; }
/* push new taskid */ int wtable_new_task(WTABLE *w, int wid, int taskid) { int ret = 0; if(w && wid > 0 && wid < W_WORKER_MAX) { mqueue_push(w->queue, w->workers[wid].task_qid, taskid); MUTEX_SIGNAL(w->workers[wid].mmlock); } return ret; }
static void menu_on_quit(GtkMenuItem *menuItem, gpointer arg) { struct gtk_mod *mod = arg; (void)menuItem; gtk_widget_destroy(GTK_WIDGET(mod->app_menu)); g_object_unref(G_OBJECT(mod->status_icon)); mqueue_push(mod->mq, MQ_QUIT, 0); info("quit from gtk\n"); }
static void reject_activated(GSimpleAction *action, GVariant *parameter, gpointer arg) { struct gtk_mod *mod = arg; struct call *call = get_call_from_gvariant(parameter); (void)action; if (call) { denotify_incoming_call(mod, call); mqueue_push(mod->mq, MQ_HANGUP, call); } }
void mqueue_send_int(MQueue q, uint16_t id, int val) { union mqueue_value v; v.v = val; pthread_mutex_lock(&q->mutex); mqueue_push(q, id, &v); pthread_cond_signal(&q->cond); pthread_mutex_unlock(&q->mutex); }
void mqueue_send_ptr(MQueue q, uint16_t id, void *data) { union mqueue_value v; v.p = data; pthread_mutex_lock(&q->mutex); mqueue_push(q, id, &v); pthread_cond_signal(&q->cond); pthread_mutex_unlock(&q->mutex); }
/* wtable app auth */ int wtable_app_auth(WTABLE *w, int wid, char *appkey, int len, int conn_id, int64_t last_time) { int mid = 0, msgid = 0, appid = 0; int64_t time = 0; if(w && appkey && len > 0 && (appid = mmtrie_get(w->map, appkey, len)) > 0) { mtree_insert(w->workers[wid].map, appid, conn_id, wid, NULL); //REALLOG(w->logger, "workers[%d] app[%.*s][%d][%d] qtotal:%p/%d", wid, len, appkey, appid, conn_id, w->workers[wid].map, mtree_total(w->workers[wid].map, appid)); mid = mmtree64_max(w->appmap, appid, &time, &msgid); while(mid && time > last_time && msgid > 0) { //REALLOG(w->logger, "workers[%d] time:%lld last_time:%lld msgid:%d", wid, time, last_time, msgid) mqueue_push(w->workers[wid].queue,w->workers[wid].q[conn_id],msgid); time = 0; msgid = 0; mid = mmtree64_prev(w->appmap, appid, mid, &time, &msgid); } } return appid; }
/* wtable new push msg */ int wtable_new_msg(WTABLE *w, int appid, char *msg, int len, int64_t time) { int msgid = 0, i = 0; char buf[W_BUF_SIZE]; WHEAD *head = (WHEAD *)buf; if(w && appid > 0 && msg && len > 0) { msgid = ++(w->state->msg_id_max); head->mix = appid; head->len = len; strncpy(buf + sizeof(WHEAD), msg, len); db_set_data(w->mdb, msgid, buf, len + sizeof(WHEAD)); //gettimeofday(&tv, NULL);now = (int64_t)tv.tv_sec * 1000000 + (int64_t)tv.tv_usec; mmtree64_try_insert(w->appmap, appid, time, msgid, NULL); for(i = 2; i <= w->state->nworkers; i++) { mqueue_push(w->queue, w->workers[i].msg_qid, msgid); } //REALLOG(w->logger, "new-msg[%.*s] for appid:%d", len, msg, appid); } return msgid; }
TEST(voe, enc_dec_alloc_start_stop_interrupt) { struct list aucodecl = LIST_INIT; int err; struct auenc_state *aesp = NULL; struct audec_state *adsp = NULL; struct media_ctx *mctxp = NULL; const struct aucodec *ac; int pt = 96; int srate = 48000; webrtc::fake_audiodevice ad(true); struct sync_state ss; init_sync_state(&ss); struct aucodec_param prm; memset(&prm, 0, sizeof(prm)); prm.local_ssrc = 0x12345678; prm.pt = 96; prm.srate = 48000; prm.ch = 2; err = voe_init(&aucodecl); ASSERT_EQ(0, err); err = re_thread_init(); struct mqueue *mq; err = mqueue_alloc(&mq, mqueue_handler, NULL); if(err){ printf("Could not allocate mqueue \n"); } voe_register_adm((void*)&ad); ac = aucodec_find(&aucodecl, "opus", 48000, 2); ss.ac = ac; if (ac->enc_alloc){ err = ac->enc_alloc(&aesp, &mctxp, ac, NULL, &prm, send_rtp, NULL, NULL, NULL, &ss); ASSERT_EQ(0, err); } if (ac->dec_alloc){ err = ac->dec_alloc(&adsp, &mctxp, ac, NULL, &prm, NULL, NULL, NULL); ASSERT_EQ(0, err); } ss.adsp = adsp; if (ac->enc_start){ ac->enc_start(aesp); } if (ac->dec_start){ ac->dec_start(adsp); } wait_for_event(&ss); wait_for_event(&ss); pthread_mutex_lock(&ss.mutex); if (mqueue_push(mq, 0, (void*)&ss) != 0) { error("mediamgr_set_sound_mode failed \n"); } pthread_mutex_unlock(&ss.mutex); for(int i = 0; i < 200; i++){ wait_for_event(&ss); } //sleep(3); if (ac->enc_stop){ ac->enc_stop(aesp); } if (ac->dec_stop){ ac->dec_stop(adsp); } mem_deref(aesp); mem_deref(adsp); voe_deregister_adm(); voe_close(); }
void gtk_mod_connect(struct gtk_mod *mod, const char *uri) { if (!mod) return; mqueue_push(mod->mq, MQ_CONNECT, (char *)uri); }