Example #1
0
static int module_init(void)
{
	int err = 0;

	err = mqueue_alloc(&mod_obj.mq, mqueue_handler, &mod_obj);
	if (err)
		return err;

	aufilt_register(baresip_aufiltl(), &vumeter);

#ifdef USE_NOTIFICATIONS
	err = message_listen(&mod_obj.message, baresip_message(),
			     message_handler, &mod_obj);
	if (err) {
		warning("gtk: message_init failed (%m)\n", err);
		return err;
	}
#endif

	err = cmd_register(baresip_commands(), cmdv, ARRAY_SIZE(cmdv));
	if (err)
		return err;

	/* start the thread last */
	err = pthread_create(&mod_obj.thread, NULL, gtk_thread,
			     &mod_obj);
	if (err)
		return err;

	return err;
}
Example #2
0
static int module_init(void)
{
	int err = 0;

	err = mqueue_alloc(&mod_obj.mq, mqueue_handler, &mod_obj);
	if (err)
		return err;

	aufilt_register(&vumeter);
#ifdef USE_NOTIFICATIONS
	err = message_init(message_handler, &mod_obj);
	if (err)
		return err;
#endif

	err = cmd_register(cmdv, ARRAY_SIZE(cmdv));
	if (err)
		return err;

	/* start the thread last */
	err = pthread_create(&mod_obj.thread, NULL, gtk_thread,
			     &mod_obj);
	if (err)
		return err;

	return err;
}
Example #3
0
static int ui_alloc(struct ui_st **stp)
{
	struct ui_st *st;
	DWORD threadID;
	int err = 0;

	if (!stp)
		return EINVAL;

	st = mem_zalloc(sizeof(*st), destructor);
	if (!st)
		return ENOMEM;

	tmr_init(&st->tmr);

	err = mqueue_alloc(&st->mq, mqueue_handler, st);
	if (err)
		goto out;

	st->hstdin = GetStdHandle(STD_INPUT_HANDLE);

	/* save the current console mode */
	GetConsoleMode(st->hstdin, &st->mode);

	st->run = true;
	st->hThread = CreateThread(NULL, 0, input_thread, st, 0, &threadID);
	if (!st->hThread) {
		st->run = false;
		err = ENOMEM;
		goto out;
	}

 out:
	if (err)
		mem_deref(st);
	else
		*stp = st;

	return err;
}
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();
}