void on_accept(struct handle *handle) { int fd; struct handle *client; retry: fd = accept(handle->fd, NULL, 0); if (fd == -1) { if (errno == EINTR) { goto retry; } LOG(WARN, "accept() failed:%s", strerror(errno)); handle_destroy(handle); return; } LOG(INFO, "client connected"); client = handle_create(fd); client->readcb = on_http_read; client->arg = calloc(1, sizeof(struct http_arg)); client->deleter = http_arg_deleter; }
VdpStatus vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address) { if (!device || !get_proc_address) { VDPAU_DBG_ONCE("device=NULL || get_proc_address"); return VDP_STATUS_INVALID_POINTER; } device_ctx_t *dev = handle_create(sizeof(*dev), device, htype_device); if (!dev) return VDP_STATUS_RESOURCES; //dev->display = XOpenDisplay(XDisplayString(display)); dev->screen = screen; dev->fb_id = 0; if (!cedarv_open()) { VDPAU_DBG_ONCE("cedarv_open failed"); handle_destroy(*device); return VDP_STATUS_ERROR; } char *env_vdpau_osd = getenv("VDPAU_OSD"); if (env_vdpau_osd && strncmp(env_vdpau_osd, "1", 1) == 0) { dev->g2d_fd = open("/dev/g2d", O_RDWR); if (dev->g2d_fd != -1) dev->osd_enabled = 1; else VDPAU_DBG("Failed to open /dev/g2d! OSD disabled."); } VDPAU_DBG("VE version 0x%04x opened", cedarv_get_version()); *get_proc_address = &vdp_get_proc_address; return VDP_STATUS_OK; }
VdpStatus vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address) { if (!display || !device || !get_proc_address) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_create(sizeof(*dev), device); if (!dev) return VDP_STATUS_RESOURCES; #ifndef NO_X11 dev->display = XOpenDisplay(XDisplayString(display)); #endif dev->screen = screen; if (!ve_open()) { handle_destroy(*device); return VDP_STATUS_ERROR; } char *env_vdpau_osd = getenv("VDPAU_OSD"); if (env_vdpau_osd && strncmp(env_vdpau_osd, "1", 1) == 0) { dev->g2d_fd = open("/dev/g2d", O_RDWR); if (dev->g2d_fd != -1) dev->osd_enabled = 1; else VDPAU_DBG("Failed to open /dev/g2d! OSD disabled."); } *get_proc_address = &vdp_get_proc_address; return VDP_STATUS_OK; }
VdpStatus vdp_video_surface_create(VdpDevice device, VdpChromaType chroma_type, uint32_t width, uint32_t height, VdpVideoSurface *surface) { if (!surface) return VDP_STATUS_INVALID_POINTER; if (width < 1 || width > 8192 || height < 1 || height > 8192) return VDP_STATUS_INVALID_SIZE; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; video_surface_ctx_t *vs = handle_create(sizeof(*vs), surface); if (!vs) return VDP_STATUS_RESOURCES; vs->device = dev; vs->width = width; vs->height = height; vs->chroma_type = chroma_type; vs->luma_size = ALIGN(width, 32) * ALIGN(height, 32); VdpStatus ret = yuv_new(vs); if (ret != VDP_STATUS_OK) { handle_destroy(*surface); return ret; } return VDP_STATUS_OK; }
/* * System call handler * * retrieves system call number from user space * and invokes the requested method */ static void syscall_handler (struct intr_frame *f) { /* retrieve system call number and switch to corresponding method */ unsigned int syscall_number = *((unsigned int*) syscall_get_kernel_address(f->esp)); switch(syscall_number) { /* process system calls */ case SYS_HALT: handle_halt(f); break; case SYS_EXIT: handle_exit(f); break; case SYS_EXEC: handle_exec(f); break; case SYS_WAIT: handle_wait(f); break; /* file system calls */ case SYS_CREATE: handle_create(f); break; case SYS_REMOVE: handle_remove(f); break; case SYS_OPEN: handle_open(f); break; case SYS_FILESIZE: handle_filesize(f); break; case SYS_READ: handle_read(f); break; case SYS_WRITE: handle_write(f); break; case SYS_SEEK: handle_seek(f); break; case SYS_TELL: handle_tell(f); break; case SYS_CLOSE: handle_close(f); break; case SYS_CHDIR: handle_chdir(f); break; case SYS_MKDIR: handle_mkdir(f); break; case SYS_READDIR: handle_readdir(f); break; case SYS_ISDIR: handle_isdir(f); break; case SYS_INUMBER: handle_inumber(f); break; default: /* SYSCALL_ERROR: */ handle_no_such_syscall(f); break; } }
VdpStatus vdp_presentation_queue_target_create_x11(VdpDevice device, Drawable drawable, VdpPresentationQueueTarget *target) { if (!target || !drawable) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; queue_target_ctx_t *qt = calloc(1, sizeof(queue_target_ctx_t)); if (!qt) return VDP_STATUS_RESOURCES; qt->drawable = drawable; qt->fd = open("/dev/disp", O_RDWR); if (qt->fd == -1) { free(qt); return VDP_STATUS_ERROR; } int tmp = SUNXI_DISP_VERSION; if (ioctl(qt->fd, DISP_CMD_VERSION, &tmp) < 0) { close(qt->fd); free(qt); return VDP_STATUS_ERROR; } uint32_t args[4] = { 0, DISP_LAYER_WORK_MODE_SCALER, 0, 0 }; qt->layer = ioctl(qt->fd, DISP_CMD_LAYER_REQUEST, args); if (qt->layer == 0) goto out_layer; args[1] = qt->layer; ioctl(qt->fd, dev->osd_enabled ? DISP_CMD_LAYER_TOP : DISP_CMD_LAYER_BOTTOM, args); if (dev->osd_enabled) { args[1] = DISP_LAYER_WORK_MODE_NORMAL; qt->layer_top = ioctl(qt->fd, DISP_CMD_LAYER_REQUEST, args); if (qt->layer_top == 0) goto out_layer_top; args[1] = qt->layer_top; ioctl(qt->fd, DISP_CMD_LAYER_TOP, args); } XSetWindowBackground(dev->display, drawable, 0x000102); if (!dev->osd_enabled) { __disp_colorkey_t ck; ck.ck_max.red = ck.ck_min.red = 0; ck.ck_max.green = ck.ck_min.green = 1; ck.ck_max.blue = ck.ck_min.blue = 2; ck.red_match_rule = 2; ck.green_match_rule = 2; ck.blue_match_rule = 2; args[1] = (unsigned long)(&ck); ioctl(qt->fd, DISP_CMD_SET_COLORKEY, args); } int handle = handle_create(qt); if (handle == -1) goto out_handle_create; *target = handle; return VDP_STATUS_OK; out_handle_create: args[1] = qt->layer_top; ioctl(qt->fd, DISP_CMD_LAYER_RELEASE, args); out_layer_top: args[1] = qt->layer; ioctl(qt->fd, DISP_CMD_LAYER_RELEASE, args); out_layer: close(qt->fd); free(qt); return VDP_STATUS_RESOURCES; }
VdpStatus vdp_decoder_create(VdpDevice device, VdpDecoderProfile profile, uint32_t width, uint32_t height, uint32_t max_references, VdpDecoder *decoder) { device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; if (max_references > 16) return VDP_STATUS_ERROR; decoder_ctx_t *dec = calloc(1, sizeof(decoder_ctx_t)); if (!dec) goto err_ctx; dec->device = dev; dec->profile = profile; dec->width = width; dec->height = height; dec->data = ve_malloc(VBV_SIZE); if (!(dec->data)) goto err_data; VdpStatus ret; switch (profile) { case VDP_DECODER_PROFILE_MPEG1: case VDP_DECODER_PROFILE_MPEG2_SIMPLE: case VDP_DECODER_PROFILE_MPEG2_MAIN: ret = new_decoder_mpeg12(dec); break; case VDP_DECODER_PROFILE_H264_BASELINE: case VDP_DECODER_PROFILE_H264_MAIN: case VDP_DECODER_PROFILE_H264_HIGH: ret = new_decoder_h264(dec); break; case VDP_DECODER_PROFILE_MPEG4_PART2_SP: case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: ret = new_decoder_mp4(dec); break; default: ret = VDP_STATUS_INVALID_DECODER_PROFILE; break; } if (ret != VDP_STATUS_OK) goto err_decoder; int handle = handle_create(dec); if (handle == -1) goto err_handle; *decoder = handle; return VDP_STATUS_OK; err_handle: if (dec->private_free) dec->private_free(dec); err_decoder: ve_free(dec->data); err_data: free(dec); err_ctx: return VDP_STATUS_RESOURCES; }
void metadb::handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) { handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index())); }
VdpStatus vdp_decoder_create(VdpDevice device, VdpDecoderProfile profile, uint32_t width, uint32_t height, uint32_t max_references, VdpDecoder *decoder) { device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; if (max_references > 16) return VDP_STATUS_ERROR; decoder_ctx_t *dec = handle_create(sizeof(*dec), decoder, htype_decoder); if (!dec) goto err_ctx; VDPAU_DBG("vdpau decoder=%d created", *decoder); memset(dec, 0, sizeof(*dec)); dec->device = dev; dec->profile = profile; dec->width = width; dec->height = height; dec->data = cedarv_malloc(VBV_SIZE); if (! cedarv_isValid(dec->data)) goto err_data; dec->data_pos = 0; VdpStatus ret; switch (profile) { case VDP_DECODER_PROFILE_MPEG1: case VDP_DECODER_PROFILE_MPEG2_SIMPLE: case VDP_DECODER_PROFILE_MPEG2_MAIN: ret = new_decoder_mpeg12(dec); break; case VDP_DECODER_PROFILE_H264_BASELINE: case VDP_DECODER_PROFILE_H264_MAIN: case VDP_DECODER_PROFILE_H264_HIGH: ret = new_decoder_h264(dec); break; case VDP_DECODER_PROFILE_MPEG4_PART2_SP: case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: case VDP_DECODER_PROFILE_DIVX4_QMOBILE: case VDP_DECODER_PROFILE_DIVX4_MOBILE: case VDP_DECODER_PROFILE_DIVX4_HOME_THEATER: case VDP_DECODER_PROFILE_DIVX4_HD_1080P: case VDP_DECODER_PROFILE_DIVX5_QMOBILE: case VDP_DECODER_PROFILE_DIVX5_MOBILE: case VDP_DECODER_PROFILE_DIVX5_HOME_THEATER: case VDP_DECODER_PROFILE_DIVX5_HD_1080P: ret = new_decoder_mpeg4(dec); break; case VDP_DECODER_PROFILE_DIVX3_HD_1080P: case VDP_DECODER_PROFILE_DIVX3_QMOBILE: case VDP_DECODER_PROFILE_DIVX3_MOBILE: case VDP_DECODER_PROFILE_DIVX3_HOME_THEATER: ret = new_decoder_msmpeg4(dec); break; default: ret = VDP_STATUS_INVALID_DECODER_PROFILE; break; } if (ret != VDP_STATUS_OK) goto err_decoder; handle_release(device); return VDP_STATUS_OK; err_handle: if (dec->private_free) dec->private_free(dec); err_decoder: cedarv_free(dec->data); err_data: handle_destroy(*decoder); err_ctx: handle_release(device); return VDP_STATUS_RESOURCES; }
conerr_t smfu_set_property(char *fmri, char *pgname, char *propname, char *value) { conerr_t err = ce_ok; scf_handle_t *scfhandle = handle_create(); scf_service_t *service = scf_service_create(scfhandle); scf_instance_t *instance = scf_instance_create(scfhandle); scf_propertygroup_t *pg = scf_pg_create(scfhandle); scf_property_t *prop = scf_property_create(scfhandle); scf_value_t *val = scf_value_create(scfhandle); scf_transaction_t *tx = scf_transaction_create(scfhandle); scf_transaction_entry_t *ent = scf_entry_create(scfhandle); scf_type_t type; if (scfhandle == NULL || service == NULL || instance == NULL || pg == NULL || prop == NULL || tx == NULL || ent == NULL || val == NULL) { err = ce_nomem; goto out; } if (scf_handle_decode_fmri(scfhandle, fmri, NULL, service, instance, NULL, NULL, 0) != SCF_SUCCESS) { rad_log(RL_ERROR, "couldn't decode '%s': %s\n", fmri, scf_strerror(scf_error())); err = maperr(scf_error()); goto out; } if (scf_instance_get_pg(instance, pgname, pg) != 0 || scf_pg_get_property(pg, propname, prop) != 0 || scf_property_type(prop, &type) != 0) { rad_log(RL_ERROR, "couldn't get property: '%s/%s/%s': %s\n", fmri, pgname, propname, scf_strerror(scf_error())); err = maperr(scf_error()); goto out; } top: if (scf_transaction_start(tx, pg) == -1 || scf_transaction_property_change(tx, ent, propname, type) != 0 || scf_value_set_from_string(val, type, value) != 0 || scf_entry_add_value(ent, val) != 0) { rad_log(RL_ERROR, "couldn't set property: '%s/%s/%s': %s\n", fmri, pgname, propname, scf_strerror(scf_error())); err = maperr(scf_error()); goto out; } switch (scf_transaction_commit(tx)) { /* success */ case 1: if (smf_refresh_instance(fmri) != 0) { err = maperr(scf_error()); goto out; } break; /* retry */ case 0: if (scf_pg_update(pg) != 0) { err = maperr(scf_error()); goto out; } scf_transaction_reset(tx); goto top; default: err = maperr(scf_error()); goto out; } out: scf_entry_destroy(ent); scf_transaction_destroy(tx); scf_value_destroy(val); scf_property_destroy(prop); scf_pg_destroy(pg); scf_instance_destroy(instance); scf_service_destroy(service); scf_handle_destroy(scfhandle); return (err); }
VdpStatus vdp_video_surface_create(VdpDevice device, VdpChromaType chroma_type, uint32_t width, uint32_t height, VdpVideoSurface *surface) { if (!surface) return VDP_STATUS_INVALID_POINTER; if (!width || !height) return VDP_STATUS_INVALID_SIZE; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; video_surface_ctx_t *vs = handle_create(sizeof(*vs), surface, htype_video); if (!vs) return VDP_STATUS_RESOURCES; VDPAU_DBG("vdpau video surface=%d created", *surface); vs->device = dev; vs->width = width; vs->height = height; vs->chroma_type = chroma_type; vs->stride_width = (width + 63) & ~63; vs->stride_height = (height + 63) & ~63; vs->plane_size = vs->stride_width * vs->stride_height; cedarv_setBufferInvalid(vs->dataY); cedarv_setBufferInvalid(vs->dataU); cedarv_setBufferInvalid(vs->dataV); switch (chroma_type) { case VDP_CHROMA_TYPE_444: //vs->data = cedarv_malloc(vs->plane_size * 3); vs->dataY = cedarv_malloc(vs->plane_size); vs->dataU = cedarv_malloc(vs->plane_size); vs->dataV = cedarv_malloc(vs->plane_size); if (! cedarv_isValid(vs->dataY) || ! cedarv_isValid(vs->dataU) || ! cedarv_isValid(vs->dataV)) { printf("vdpau video surface=%d create, failure\n", *surface); handle_destroy(*surface); handle_release(device); return VDP_STATUS_RESOURCES; } break; case VDP_CHROMA_TYPE_422: //vs->data = cedarv_malloc(vs->plane_size * 2); vs->dataY = cedarv_malloc(vs->plane_size); vs->dataU = cedarv_malloc(vs->plane_size/2); vs->dataV = cedarv_malloc(vs->plane_size/2); if (! cedarv_isValid(vs->dataY) || ! cedarv_isValid(vs->dataU) || ! cedarv_isValid(vs->dataV)) { printf("vdpau video surface=%d create, failure\n", *surface); handle_destroy(*surface); handle_release(device); return VDP_STATUS_RESOURCES; } break; case VDP_CHROMA_TYPE_420: //vs->data = cedarv_malloc(vs->plane_size + (vs->plane_size / 2)); vs->dataY = cedarv_malloc(vs->plane_size); vs->dataU = cedarv_malloc(vs->plane_size/2); if (! cedarv_isValid(vs->dataY) || ! cedarv_isValid(vs->dataU)) { printf("vdpau video surface=%d create, failure\n", *surface); handle_destroy(*surface); handle_release(device); return VDP_STATUS_RESOURCES; } break; default: free(vs); handle_release(device); return VDP_STATUS_INVALID_CHROMA_TYPE; } handle_release(device); return VDP_STATUS_OK; }