static void eventsink(void *opaque, prop_event_t event, ...) { event_t *e, **ep = opaque; va_list ap; va_start(ap, event); switch(event) { default: break; case PROP_EXT_EVENT: if(*ep) event_release(*ep); e = va_arg(ap, event_t *); atomic_inc(&e->e_refcount); *ep = e; break; case PROP_DESTROYED: if(*ep) event_release(*ep); *ep = event_create_action(ACTION_CANCEL); break; } }
/* * This gets called when a host has been put on a wait queue because * initial connection attempts failed. */ static void connect_wait_callback( void * cookie) { proto_t *p = cookie; event_release((event_handle_t *)p->security_handle); if ( #ifdef BSDTCP_SECURITY p->security_driver == &bsdtcp_security_driver || #endif p->security_driver == &local_security_driver || #ifdef RSH_SECURITY p->security_driver == &rsh_security_driver || #endif #ifdef SSL_SECURITY p->security_driver == &ssl_security_driver || #endif #ifdef SSH_SECURITY p->security_driver == &ssh_security_driver || #endif 0) { g_thread_create(connect_thread, (gpointer)p, TRUE, NULL); g_mutex_lock(protocol_mutex); nb_thread++; g_mutex_unlock(protocol_mutex); } else { // bsd_security_driver no connect,all use same socket // bsdudp_security_driver no connect,all use same socket // krb5_security_driver untested security_connect(p->security_driver, p->hostname, p->conf_fn, connect_callbackX, p, p->datap); } }
static event_t * rtmp_process_event(rtmp_t *r, event_t *e, media_buf_t **mbp) { media_pipe_t *mp = r->mp; if(event_is_type(e, EVENT_EXIT) || event_is_type(e, EVENT_PLAY_URL) || event_is_action(e, ACTION_SKIP_FORWARD) || event_is_action(e, ACTION_SKIP_BACKWARD)) return e; if(event_is_type(e, EVENT_CURRENT_TIME)) { event_ts_t *ets = (event_ts_t *)e; int sec = ets->ts / 1000000; if(sec != r->restartpos_last && mp->mp_flags & MP_CAN_SEEK) { r->restartpos_last = sec; playinfo_set_restartpos(r->canonical_url, mp->mp_seek_base / 1000, 1); } } else if(mp->mp_flags & MP_CAN_SEEK && event_is_type(e, EVENT_SEEK)) { event_ts_t *ets = (event_ts_t *)e; video_seek(r, mp, mbp, ets->ts, "direct"); } event_release(e); return NULL; }
int message_popup(const char *message, int flags) { prop_t *p; int rval; p = prop_create_root(NULL); prop_set_string(prop_create(p, "type"), "message"); prop_set_string_ex(prop_create(p, "message"), NULL, message, flags & MESSAGE_POPUP_RICH_TEXT ? PROP_STR_RICH : PROP_STR_UTF8); if(flags & MESSAGE_POPUP_CANCEL) prop_set_int(prop_create(p, "cancel"), 1); if(flags & MESSAGE_POPUP_OK) prop_set_int(prop_create(p, "ok"), 1); event_t *e = popup_display(p); prop_destroy(p); if(event_is_action(e, ACTION_OK)) rval = MESSAGE_POPUP_OK; else if(event_is_action(e, ACTION_CANCEL)) rval = MESSAGE_POPUP_CANCEL; else rval = 0; event_release(e); return rval; }
static int hc_prop(http_connection_t *hc, const char *remain, void *opaque, http_cmd_t method) { htsbuf_queue_t out; rstr_t *r; int rval, i; prop_t *p; const char *action = http_arg_get_req(hc, "action"); if(remain == NULL) return 404; p = prop_from_path(remain); if(p == NULL) return 404; htsbuf_queue_init(&out, 0); switch(method) { case HTTP_CMD_GET: if(action != NULL) { event_t *e = event_create_action_str(action); prop_send_ext_event(p, e); event_release(e); rval = HTTP_STATUS_OK; break; } r = prop_get_string(p, NULL); if(r == NULL) { char **childs = prop_get_name_of_childs(p); if(childs == NULL) { rval = HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE; break; } for(i = 0; childs[i] != NULL; i++) { htsbuf_qprintf(&out, "\t%s\n", childs[i]); } } else { htsbuf_append(&out, rstr_get(r), strlen(rstr_get(r))); htsbuf_append(&out, "\n", 1); rstr_release(r); } rval = http_send_reply(hc, 0, "text/ascii", NULL, NULL, 0, &out); break; default: rval = HTTP_STATUS_METHOD_NOT_ALLOWED; break; } prop_ref_dec(p); return rval; }
static void glw_ps3_dispatch_event(uii_t *uii, event_t *e) { /* Pass it on to GLW */ glw_dispatch_event(uii, e); event_release(e); }
void event_to_ui(event_t *e) { event_to_prop(prop_get_by_name(PNVEC("global", "userinterfaces", "ui", "eventSink"), 1, NULL), e); event_release(e); }
void mp_become_primary(struct media_pipe *mp) { mp_init_audio(mp); if(media_primary == mp) return; hts_mutex_lock(&media_mutex); assert(mp->mp_flags & MP_PRIMABLE); if(media_primary != NULL) { prop_set_int(media_primary->mp_prop_primary, 0); event_t *e = event_create_action(ACTION_STOP); mp_enqueue_event(media_primary, e); event_release(e); } media_primary = mp_retain(mp); prop_select(mp->mp_prop_root); prop_link(mp->mp_prop_root, media_prop_current); prop_set_int(mp->mp_prop_primary, 1); hts_mutex_unlock(&media_mutex); }
static void * video_player_idle(void *aux) { video_playback_t *vp = aux; int run = 1; event_t *e = NULL, *next; media_pipe_t *mp = vp->vp_mp; char errbuf[256]; prop_t *errprop = prop_ref_inc(prop_create(mp->mp_prop_root, "error")); while(run) { if(e == NULL) e = mp_dequeue_event(mp); if(event_is_type(e, EVENT_PLAY_URL)) { prop_set_void(errprop); event_playurl_t *ep = (event_playurl_t *)e; int flags = 0; if(ep->primary) flags |= BACKEND_VIDEO_PRIMARY; if(ep->no_audio) flags |= BACKEND_VIDEO_NO_AUDIO; next = backend_play_video(ep->url, mp, flags, ep->priority, errbuf, sizeof(errbuf)); if(next == NULL) { notify_add(NOTIFY_ERROR, NULL, 5, "URL: %s\nError: %s", ep->url, errbuf); prop_set_string(errprop, errbuf); } event_release(e); e = next; continue; } else if(event_is_type(e, EVENT_EXIT)) { event_release(e); break; } event_release(e); e = NULL; } prop_ref_dec(errprop); return NULL; }
static void *event_worker(void *arg) { while (1) { event_t *event = queue_dequeue(&event_queue); nb_cb_func cb = nb_cb[event->addr]; if (cb) cb(event->addr, event->ov, event->nv); event_release(event); } return NULL; }
static void gu_playqueue_send_event(gu_tab_t *gt, struct event *e) { prop_t *p = prop_get_by_name(PNVEC("global", "playqueue", "eventsink"), 1, NULL); prop_send_ext_event(p, e); prop_ref_dec(p); event_release(e); }
t_status interface_event_release(o_syscall* message) { t_status error; error = event_release(message->u.request.u.event_release.arg1); message->u.reply.error = error; return (STATUS_OK); }
int text_dialog_kbrd(const char *message, char** answer, int flags) { htsmsg_t *m; rstr_t *r; prop_t *p = prop_create_root(NULL); prop_set_string(prop_create(p, "type"), "textDialogKbrd"); prop_set_string_ex(prop_create(p, "message"), NULL, message, flags & MESSAGE_POPUP_RICH_TEXT ? PROP_STR_RICH : PROP_STR_UTF8); prop_t *string = prop_create(p, "input"); if(flags & MESSAGE_POPUP_CANCEL) prop_set_int(prop_create(p, "cancel"), 1); if(flags & MESSAGE_POPUP_OK) prop_set_int(prop_create(p, "ok"), 1); event_t *e = popup_display_kbrd(p, string); if (event_is_action(e, ACTION_OK)) { m = htsmsg_create_map(); r = prop_get_string(string); htsmsg_add_str(m, "input", r ? rstr_get(r) : ""); rstr_release(r); htsmsg_get_str(m, "input"); setstr(answer, m, "input"); } prop_destroy(p); if(event_is_action(e, ACTION_CANCEL)){ event_release(e); return -1; } event_release(e); return 0; }
int message_popup(const char *message, int flags, const char **extra) { prop_t *p; int rval; p = prop_ref_inc(prop_create_root(NULL)); TRACE(TRACE_DEBUG, "Notification", "%s", message); prop_set_string(prop_create(p, "type"), "message"); prop_set_string_ex(prop_create(p, "message"), NULL, message, flags & MESSAGE_POPUP_RICH_TEXT ? PROP_STR_RICH : PROP_STR_UTF8); if(extra) { int cnt = 1; prop_t *btns = prop_create(p, "buttons"); while(*extra) { prop_t *b = prop_create_root(NULL); prop_set_string(prop_create(b, "title"), *extra); char action[10]; snprintf(action, sizeof(action), "btn%d", cnt); prop_set_string(prop_create(b, "action"), action); if(prop_set_parent(b, btns)) abort(); cnt++; extra++; } } if(flags & MESSAGE_POPUP_CANCEL) prop_set_int(prop_create(p, "cancel"), 1); if(flags & MESSAGE_POPUP_OK) prop_set_int(prop_create(p, "ok"), 1); event_t *e = popup_display(p); prop_destroy(p); prop_ref_dec(p); const event_payload_t *ep = (const event_payload_t *)e; if(event_is_action(e, ACTION_OK)) rval = MESSAGE_POPUP_OK; else if(event_is_action(e, ACTION_CANCEL)) rval = MESSAGE_POPUP_CANCEL; else if(event_is_type(e, EVENT_DYNAMIC_ACTION) && !strncmp(ep->payload, "btn", 3)) rval = atoi(ep->payload + 3); else rval = 0; event_release(e); return rval; }
void gu_tab_send_event(gu_tab_t *gt, event_t *e) { prop_t *p = prop_get_by_name(PNVEC("nav", "eventsink"), 1, PROP_TAG_NAMED_ROOT, gt->gt_nav, "nav", NULL); prop_send_ext_event(p, e); prop_ref_dec(p); event_release(e); }
void video_playback_destroy(video_playback_t *vp) { event_t *e = event_create_type(EVENT_EXIT); mp_enqueue_event(vp->vp_mp, e); event_release(e); hts_thread_join(&vp->vp_thread); free(vp); }
/* * Cancel a previous stream read request. It's ok if we didn't * have a read scheduled. */ static void bsd_stream_read_cancel( void * s) { struct sec_stream *bs = s; assert(bs != NULL); if (bs->ev_read != NULL) { event_release(bs->ev_read); bs->ev_read = NULL; } }
/** * prop_mutex can be held here, so we need to avoid locking it */ void mp_release(media_pipe_t *mp) { if(atomic_dec(&mp->mp_refcount)) return; event_t *e; /* Make sure a clean shutdown has been made */ assert(mp->mp_audio_decoder == NULL); assert(mp != media_primary); if(media_pipe_fini_extra != NULL) media_pipe_fini_extra(mp); while((e = TAILQ_FIRST(&mp->mp_eq)) != NULL) { TAILQ_REMOVE(&mp->mp_eq, e, e_link); event_release(e); } mq_flush(mp, &mp->mp_audio, 1); mq_flush(mp, &mp->mp_video, 1); mq_destroy(&mp->mp_audio); mq_destroy(&mp->mp_video); video_overlay_flush_locked(mp, 0); dvdspu_destroy_all(mp); hts_cond_destroy(&mp->mp_backpressure); hts_mutex_destroy(&mp->mp_mutex); hts_mutex_destroy(&mp->mp_clock_mutex); hts_mutex_destroy(&mp->mp_overlay_mutex); pool_destroy(mp->mp_mb_pool); if(mp->mp_satisfied == 0) atomic_dec(&media_buffer_hungry); cancellable_release(mp->mp_cancellable); /** * We need to destroy mp_prop_root but there is a risk that prop_mutex * is held here, so we need to dispatch */ task_run(mp_final_release, mp); }
int text_dialog(const char *message, char **answer, int flags) { rstr_t *r; *answer = NULL; prop_t *p = prop_ref_inc(prop_create_root(NULL)); prop_set_string(prop_create(p, "type"), "textDialog"); prop_set_string_ex(prop_create(p, "message"), NULL, message, flags & MESSAGE_POPUP_RICH_TEXT ? PROP_STR_RICH : PROP_STR_UTF8); prop_t *string = prop_create(p, "input"); if(flags & MESSAGE_POPUP_CANCEL) prop_set_int(prop_create(p, "cancel"), 1); if(flags & MESSAGE_POPUP_OK) prop_set_int(prop_create(p, "ok"), 1); event_t *e = popup_display(p); if(event_is_action(e, ACTION_OK)) { r = prop_get_string(string, NULL); if(r) *answer = strdup(rstr_get(r)); rstr_release(r); } prop_destroy(p); prop_ref_dec(p); if(event_is_action(e, ACTION_CANCEL)) { event_release(e); return -1; } event_release(e); return 0; }
static void popup_send_result(popup_t *pop, action_type_t res) { prop_t *p; p = prop_get_by_name(PNVEC("self", "eventSink"), 1, PROP_TAG_NAMED_ROOT, pop->p, "self", NULL); if(p != NULL) { event_t *e = event_create_action(res); prop_send_ext_event(p, e); event_release(e); prop_ref_dec(p); } }
/* * This is a callback for security_connect. After the security layer * has initiated a connection to the given host, this will be called * with a security_handle_t. * * On error, the security_status_t arg will reflect errors which can * be had via security_geterror on the handle. */ static void connect_callback( void *cookie) { proto_t *p = cookie; assert(p != NULL); if (p->event_handle) { event_release(p->event_handle); p->event_handle = 0; } proto_debug(1, _("protocol: connect_callback: p %p\n"), p); switch (p->status) { case S_OK: state_machine(p, PA_START, NULL); break; case S_TIMEOUT: security_seterror(p->security_handle, _("timeout during connect")); /* FALLTHROUGH */ case S_ERROR: /* * For timeouts or errors, retry a few times, waiting CONNECT_WAIT * seconds between each attempt. If they all fail, just return * an error back to the caller. */ if (--p->connecttries == 0) { state_machine(p, PA_ABORT, NULL); } else { proto_debug(1, _("protocol: connect_callback: p %p: retrying %s\n"), p, p->hostname); security_close(p->security_handle); /* XXX overload p->security handle to hold the event handle */ p->security_handle = (security_handle_t *)event_create(CONNECT_WAIT, EV_TIME, connect_wait_callback, p); event_activate((event_handle_t *) p->security_handle); } break; default: assert(0); break; } }
static void eventsink(void *opaque, prop_event_t event, ...) { event_t *e, **ep = opaque; va_list ap; va_start(ap, event); if(event != PROP_EXT_EVENT) return; if(*ep) event_release(*ep); e = va_arg(ap, event_t *); atomic_add(&e->e_refcount, 1); *ep = e; }
static event_t * rtmp_process_event(rtmp_t *r, event_t *e, media_buf_t **mbp) { media_pipe_t *mp = r->mp; if(event_is_type(e, EVENT_EXIT) || event_is_type(e, EVENT_PLAY_URL) || event_is_action(e, ACTION_SKIP_FORWARD)) return e; if(event_is_action(e, ACTION_SKIP_BACKWARD)) { if(mp->mp_seek_base < MP_SKIP_LIMIT) { return e; } video_seek(r, mp, mbp, 0, "direct"); } if(event_is_type(e, EVENT_CURRENT_TIME)) { event_ts_t *ets = (event_ts_t *)e; int sec = ets->ts / 1000000; if(sec != r->restartpos_last && r->can_seek) { r->restartpos_last = sec; metadb_set_video_restartpos(r->canonical_url, mp->mp_seek_base / 1000); } } else if(r->can_seek && event_is_type(e, EVENT_SEEK)) { event_ts_t *ets = (event_ts_t *)e; video_seek(r, mp, mbp, ets->ts, "direct"); } else if(event_is_action(e, ACTION_STOP)) { mp_set_playstatus_stop(mp); } else if(event_is_type(e, EVENT_SELECT_SUBTITLE_TRACK)) { event_select_track_t *est = (event_select_track_t *)e; prop_set_string(mp->mp_prop_subtitle_track_current, est->id); if(!strcmp(est->id, "sub:off")) { mp_load_ext_sub(mp, NULL); } else { mp_load_ext_sub(mp, est->id); } } event_release(e); return NULL; }
static void osk_destroyed(glw_ps3_t *gp) { glw_t *w = gp->osk_widget; assert(w != NULL); if(!(w->glw_flags & GLW_DESTROYING)) { event_t *e = event_create_action(ACTION_SUBMIT); glw_event_to_widget(w, e); event_release(e); } glw_unref(w); gp->osk_widget = NULL; if(gp->osk_container != 0xFFFFFFFFU) lv2MemContinerDestroy(gp->osk_container); }
/* * Submit a request to read some data. Calls back with the given function * and arg when completed. */ static void bsd_stream_read( void * s, void (*fn)(void *, void *, ssize_t), void * arg) { struct sec_stream *bs = s; /* * Only one read request can be active per stream. */ if (bs->ev_read != NULL) event_release(bs->ev_read); bs->ev_read = event_register((event_id_t)bs->fd, EV_READFD, stream_read_callback, bs); bs->fn = fn; bs->arg = arg; }
t_status glue_timer_clean(void) { /* * 1) */ if (event_release(ARCHITECTURE_IDT_IRQ_PIT) != STATUS_OK) MACHINE_ESCAPE("unable to release the timer IRQ"); /* * 2) */ if (platform_pit_clean() != STATUS_OK) MACHINE_ESCAPE("unable to clean the PIT"); MACHINE_LEAVE(); }
void test_architecture_event_interrupt_02(void) { TEST_ENTER(); event_release(ARCHITECTURE_IDT_SYSCALL_BASE + 0); event_release(ARCHITECTURE_IDT_SYSCALL_BASE + 1); event_release(ARCHITECTURE_IDT_SYSCALL_BASE + 2); if (event_reserve(ARCHITECTURE_IDT_SYSCALL_BASE + 0, EVENT_TYPE_FUNCTION, EVENT_ROUTINE(test_architecture_event_interrupt_02_handler_56), EVENT_DATA(NULL)) != STATUS_OK) TEST_ERROR("[event_reserve] error"); if (event_reserve(ARCHITECTURE_IDT_SYSCALL_BASE + 1, EVENT_TYPE_FUNCTION, EVENT_ROUTINE(test_architecture_event_interrupt_02_handler_57), EVENT_DATA(NULL)) != STATUS_OK) TEST_ERROR("[event_reserve] error"); if (event_reserve(ARCHITECTURE_IDT_SYSCALL_BASE + 2, EVENT_TYPE_FUNCTION, EVENT_ROUTINE(test_architecture_event_interrupt_02_handler_58), EVENT_DATA(NULL)) != STATUS_OK) TEST_ERROR("[event_reserve] error"); if (event_enable() != STATUS_OK) TEST_ERROR("[event_enable] error"); asm volatile("int $56"); asm volatile("int $57"); asm volatile("int $58"); if (event_disable() != STATUS_OK) TEST_ERROR("[event_disable] error"); if (thrown != 3) TEST_ERROR("some interrupt events have not been caught"); if (event_release(ARCHITECTURE_IDT_SYSCALL_BASE + 0) != STATUS_OK) TEST_ERROR("[event_release] error"); if (event_release(ARCHITECTURE_IDT_SYSCALL_BASE + 1) != STATUS_OK) TEST_ERROR("[event_release] error"); if (event_release(ARCHITECTURE_IDT_SYSCALL_BASE + 2) != STATUS_OK) TEST_ERROR("[event_release] error"); TEST_SIGNATURE(cd09iwfjg9gerkg43hg); TEST_LEAVE(); }
static void handle_btn(glw_ps3_t *gp, int pad, int code, int pressed) { int16_t *store = &button_counter[pad][code]; if(code == 0) return; if(pressed) { if(*store == 0 || (*store > KEY_REPEAT_DELAY && (*store % KEY_REPEAT_RATE == 0))) { int uc = 0; event_t *e = NULL; if(code >= BTN_KEY_1 && code <= BTN_KEY_9) { uc = code - BTN_KEY_1 + '1'; } else if(code == BTN_KEY_0) { uc = '0'; } if(uc != 0) e = event_create_int(EVENT_UNICODE, uc); if(e == NULL) { const action_type_t *avec = btn_to_action[code]; if(avec) { int i = 0; while(avec[i] != 0) i++; e = event_create_action_multi(avec, i); } } if(e != NULL) { glw_dispatch_event(&gp->gr.gr_uii, e); event_release(e); } } (*store)++; } else { *store = 0; } }
void video_deliver_frame(video_decoder_t *vd, frame_buffer_type_t type, void *frame, const frame_info_t *info, int send_pts) { event_ts_t *ets; vd->vd_skip = 0; if(info->pts != AV_NOPTS_VALUE && send_pts) { ets = event_create(EVENT_CURRENT_PTS, sizeof(event_ts_t)); ets->ts = info->pts; mp_enqueue_event(vd->vd_mp, &ets->h); event_release(&ets->h); } vd->vd_frame_deliver(type, frame, info, vd->vd_opaque); video_decoder_scan_ext_sub(vd, info->pts); }
static void btn(glw_ps3_t *gp, krepeat_t *kr, int pressed, action_type_t ac) { event_t *e; if(ac == ACTION_NONE) return; if(pressed) { if(kr->held_frames == 0 || (kr->held_frames > 30 && (kr->held_frames % 3 == 0))) { e = event_create_action(ac); glw_dispatch_event(&gp->gr.gr_uii, e); event_release(e); } kr->held_frames++; } else { kr->held_frames = 0; } }