VdpStatus vdp_presentation_queue_create(VdpDevice device, VdpPresentationQueueTarget presentation_queue_target, VdpPresentationQueue *presentation_queue) { if (!presentation_queue) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; queue_target_ctx_t *qt = handle_get(presentation_queue_target); if (!qt) return VDP_STATUS_INVALID_HANDLE; queue_ctx_t *q = calloc(1, sizeof(queue_ctx_t)); if (!q) return VDP_STATUS_RESOURCES; q->target = qt; q->device = dev; int handle = handle_create(q); if (handle == -1) { free(q); return VDP_STATUS_RESOURCES; } *presentation_queue = handle; return VDP_STATUS_OK; }
VdpStatus vdp_decoder_render_stream(VdpDecoder decoder, VdpVideoSurface target, VdpPictureInfo const *picture_info, uint32_t bitstream_buffer_count, VdpBitstreamBuffer const *bitstream_buffers, uint32_t* bitstream_pos_returned) { decoder_ctx_t *dec = handle_get(decoder); if (!dec) return VDP_STATUS_INVALID_HANDLE; video_surface_ctx_t *vid = handle_get(target); if (!vid) return VDP_STATUS_INVALID_HANDLE; vid->source_format = INTERNAL_YCBCR_FORMAT; unsigned int i, pos = dec->data_pos; for (i = 0; i < bitstream_buffer_count; i++) { cedarv_memcpy(dec->data, pos, bitstream_buffers[i].bitstream, bitstream_buffers[i].bitstream_bytes); pos += bitstream_buffers[i].bitstream_bytes; } //memory is mapped unchached, therefore no flush necessary. hopefully ;) cedarv_flush_cache(dec->data, pos); int error = dec->decode_stream(dec, picture_info, pos, vid, bitstream_pos_returned); if(error) { dec->data_pos = (*bitstream_pos_returned + 7) >> 3; if(dec->data_pos > pos) { dec->data_pos = pos; } //memmove(dec->data, (char*)dec->data + dec->data_pos, pos - dec->data_pos); } else {
VdpStatus vdp_decoder_render(VdpDecoder decoder, VdpVideoSurface target, VdpPictureInfo const *picture_info, uint32_t bitstream_buffer_count, VdpBitstreamBuffer const *bitstream_buffers) { decoder_ctx_t *dec = handle_get(decoder); if (!dec) return VDP_STATUS_INVALID_HANDLE; video_surface_ctx_t *vid = handle_get(target); if (!vid) return VDP_STATUS_INVALID_HANDLE; vid->source_format = INTERNAL_YCBCR_FORMAT; unsigned int i, pos = 0; for (i = 0; i < bitstream_buffer_count; i++) { memcpy(dec->data + pos, bitstream_buffers[i].bitstream, bitstream_buffers[i].bitstream_bytes); pos += bitstream_buffers[i].bitstream_bytes; } ve_flush_cache(dec->data, pos); return dec->decode(dec, picture_info, pos, vid); }
VdpStatus vdp_decoder_render(VdpDecoder decoder, VdpVideoSurface target, VdpPictureInfo const *picture_info, uint32_t bitstream_buffer_count, VdpBitstreamBuffer const *bitstream_buffers) { VdpStatus status = VDP_STATUS_INVALID_HANDLE; decoder_ctx_t *dec = handle_get(decoder); if (!dec) return VDP_STATUS_INVALID_HANDLE; video_surface_ctx_t *vid = handle_get(target); if (!vid) { handle_release(decoder); return VDP_STATUS_INVALID_HANDLE; } vid->source_format = INTERNAL_YCBCR_FORMAT; unsigned int i, pos = 0; for (i = 0; i < bitstream_buffer_count; i++) { cedarv_memcpy(dec->data, pos, bitstream_buffers[i].bitstream, bitstream_buffers[i].bitstream_bytes); pos += bitstream_buffers[i].bitstream_bytes; } //memory is mapped unchached, therefore no flush necessary. hopefully ;) cedarv_flush_cache(dec->data, pos); status = dec->decode(dec, picture_info, pos, vid); handle_release(target); handle_release(decoder); return status; }
VdpStatus vdp_video_mixer_render(VdpVideoMixer mixer, VdpOutputSurface background_surface, VdpRect const *background_source_rect, VdpVideoMixerPictureStructure current_picture_structure, uint32_t video_surface_past_count, VdpVideoSurface const *video_surface_past, VdpVideoSurface video_surface_current, uint32_t video_surface_future_count, VdpVideoSurface const *video_surface_future, VdpRect const *video_source_rect, VdpOutputSurface destination_surface, VdpRect const *destination_rect, VdpRect const *destination_video_rect, uint32_t layer_count, VdpLayer const *layers) { mixer_ctx_t *mix = handle_get(mixer); if (!mix) return VDP_STATUS_INVALID_HANDLE; if (background_surface != VDP_INVALID_HANDLE) VDPAU_DBG_ONCE("Requested unimplemented background_surface"); if (current_picture_structure != VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME) VDPAU_DBG_ONCE("Requested unimplemented picture_structure"); output_surface_ctx_t *os = handle_get(destination_surface); if (!os) return VDP_STATUS_INVALID_HANDLE; os->vs = handle_get(video_surface_current); if (!(os->vs)) return VDP_STATUS_INVALID_HANDLE; if (destination_video_rect) { os->video_dst_rect = *destination_video_rect; if (video_source_rect) os->video_src_rect = *video_source_rect; else { os->video_src_rect.x0 = os->video_src_rect.y0 = 0; os->video_src_rect.x1 = os->vs->width; os->video_src_rect.y1 = os->vs->height; } } os->csc_change = mix->csc_change; os->brightness = mix->brightness; os->contrast = mix->contrast; os->saturation = mix->saturation; os->hue = mix->hue; mix->csc_change = 0; if (layer_count != 0) VDPAU_DBG_ONCE("Requested unimplemented additional layers"); handle_release(mixer); handle_release(destination_surface); handle_release(video_surface_current); return VDP_STATUS_OK; }
/* Handle a client connection on the file descriptor CONNECTION_FD. */ static void handle_connection(int connection_fd) { char buffer[256]; ssize_t bytes_read; /* Read some data from the client. */ bytes_read = read(connection_fd, buffer, sizeof (buffer) - 1); if (bytes_read > 0) { char method[sizeof (buffer)]; char url[sizeof (buffer)]; char protocol[sizeof (buffer)]; /* Some data was read successfully. NUL-terminated the buffer so * we can use string operations on it. */ buffer[bytes_read] = '\0'; /* The first line the client sends it the HTTP request, which is * composed of a method, the requested page, and the protocol * version.*/ sscanf(buffer, "%s %s %s", method, url, protocol); /* The client may send various header information following the * request. For this HTTP Implementation, we don't care about it. * However, we need to read any data the client tries to send. * Keep on reading data until we get to the end of the header, * which is delimited by a blank line. HTTP specifies CR/CF as * the line delimiter. */ while (strstr(buffer, "\r\n\r\n") == NULL) { bytes_read = read(connection_fd, buffer, sizeof (buffer)); } /* Make sure the last read didn't fail. If it did, there's a * problem with the connection, so give up. */ if (bytes_read == -1) { close(connection_fd); return; } /* Check the protocol field. We understand HTTP version 1.0 and 1.1. */ if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1")) { /* We don't understand this protocol. Report a bad response. */ write(connection_fd, bad_request_response, sizeof (bad_request_response)); } else if (strcmp(method, "GET")) { /* This server only implements the GET method. The client * specified some other method, so report the failure. */ char response[1024]; snprintf(response, sizeof (response), bad_method_response_template, method); write(connection_fd, response, strlen(response)); } else { /* A valid request. Process it. */ handle_get(connection_fd, url); } } else if (bytes_read == 0) { /* The client closed the connection before sending any data. * Nothing to do. */ ; } else { /* The call to read failed. */ system_error("read"); } }
static DBusHandlerResult message_cb(DBusConnection *conn, DBusMessage *msg, void *user_data) { pa_dbusobj_server_lookup *sl = user_data; pa_assert(conn); pa_assert(msg); pa_assert(sl); /* pa_log("Got message! type = %s path = %s iface = %s member = %s dest = %s", dbus_message_type_to_string(dbus_message_get_type(msg)), dbus_message_get_path(msg), dbus_message_get_interface(msg), dbus_message_get_member(msg), dbus_message_get_destination(msg)); */ if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_METHOD_CALL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect") || (!dbus_message_get_interface(msg) && dbus_message_has_member(msg, "Introspect"))) return handle_introspect(conn, msg, sl); if (dbus_message_is_method_call(msg, DBUS_INTERFACE_PROPERTIES, "Get") || (!dbus_message_get_interface(msg) && dbus_message_has_member(msg, "Get"))) return handle_get(conn, msg, sl); if (dbus_message_is_method_call(msg, DBUS_INTERFACE_PROPERTIES, "Set") || (!dbus_message_get_interface(msg) && dbus_message_has_member(msg, "Set"))) return handle_set(conn, msg, sl); if (dbus_message_is_method_call(msg, DBUS_INTERFACE_PROPERTIES, "GetAll") || (!dbus_message_get_interface(msg) && dbus_message_has_member(msg, "GetAll"))) return handle_get_all(conn, msg, sl); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
static int memcachefs_open(const char *path, struct fuse_file_info *fi) { handle_t *handle; char *key; size_t keylen; void *val; size_t vallen; if(opt.verbose){ fprintf(stderr, "%s(\"%s\")\n", __func__, path); } handle = handle_get(pool); if(!handle){ return -EMFILE; } fi->fh = handle->index; key = (char *)path + 1; keylen = strlen(key); val = mc_aget2(handle->mc, key, keylen, &vallen); if(!val){ return -EIO; } memcpy(handle->buf, val, vallen); handle->buf_len = vallen; return 0; }
static int memcachefs_truncate(const char* path, off_t length) { int ret; handle_t *handle; char *key; size_t keylen; if(opt.verbose){ fprintf(stderr, "%s(\"%s\", %lld)\n", __func__, path, length); } if(length != 0){ return -ENOSYS; } handle = handle_get(pool); if(!handle){ return -EMFILE; } key = (char *)path + 1; keylen = strlen(key); ret = mc_set(handle->mc, key, keylen, "", 0, 0, 0); handle_release(pool, handle->index); if(ret){ return -EIO; } return 0; }
static int memcachefs_mknod(const char *path, mode_t mode, dev_t rdev) { int ret; handle_t *handle; char *key; size_t keylen; if(opt.verbose){ fprintf(stderr, "%s(\"%s\", 0%o)\n", __func__, path, mode); } if(!S_ISREG(mode)){ return -ENOSYS; } handle = handle_get(pool); if(!handle){ return -EMFILE; } key = (char *)path + 1; keylen = strlen(key); ret = mc_set(handle->mc, key, keylen, "", 0, 0, 0); handle_release(pool, handle->index); if(ret){ return -EIO; } return 0; }
VdpStatus vdp_video_surface_destroy(VdpVideoSurface surface) { video_surface_ctx_t *vs = handle_get(surface); if (!vs) return VDP_STATUS_INVALID_HANDLE; if (vs->decoder_private_free) vs->decoder_private_free(vs); if( cedarv_isValid(vs->dataY) ) cedarv_free(vs->dataY); if( cedarv_isValid(vs->dataU) ) cedarv_free(vs->dataU); if (cedarv_isValid(vs->dataV) ) cedarv_free(vs->dataV); cedarv_setBufferInvalid(vs->dataY); cedarv_setBufferInvalid(vs->dataU); cedarv_setBufferInvalid(vs->dataV); VDPAU_DBG("vdpau video surface=%d destroyed", surface); handle_release(surface); handle_destroy(surface); return VDP_STATUS_OK; }
static void handle_message(struct cfw_message *msg, void *param) { switch (CFW_MESSAGE_ID(msg)) { case MSG_ID_CIRCULAR_STORAGE_PUSH_REQ: handle_push(msg); break; case MSG_ID_CIRCULAR_STORAGE_POP_REQ: handle_pop(msg); break; case MSG_ID_CIRCULAR_STORAGE_PEEK_REQ: handle_peek(msg); break; case MSG_ID_CIRCULAR_STORAGE_CLEAR_REQ: handle_clear(msg); break; case MSG_ID_LL_CIRCULAR_STORAGE_SHUTDOWN_REQ: cfw_send_message(CFW_MESSAGE_PRIV(msg)); break; case MSG_ID_CIRCULAR_STORAGE_GET_REQ: handle_get(msg); default: cfw_print_default_handle_error_msg(LOG_MODULE_MAIN, CFW_MESSAGE_ID( msg)); break; } cfw_msg_free(msg); }
VdpStatus vdp_get_proc_address(VdpDevice device_handle, VdpFuncId function_id, void **function_pointer) { VdpStatus status; if (!function_pointer) return VDP_STATUS_INVALID_POINTER; device_ctx_t *device = handle_get(device_handle); if (!device) return VDP_STATUS_INVALID_HANDLE; if (function_id < ARRAY_SIZE(functions)) { *function_pointer = functions[function_id]; if (*function_pointer == NULL) status = VDP_STATUS_INVALID_FUNC_ID; else status = VDP_STATUS_OK; } else if (function_id == VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11) { *function_pointer = &vdp_presentation_queue_target_create_x11; status = VDP_STATUS_OK; } else status = VDP_STATUS_INVALID_FUNC_ID; handle_release(device_handle); return status; }
VdpStatus vdp_video_mixer_query_parameter_value_range(VdpDevice device, VdpVideoMixerParameter parameter, void *min_value, void *max_value) { if (!min_value || !max_value) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; switch (parameter) { case VDP_VIDEO_MIXER_PARAMETER_LAYERS: *(uint32_t *)min_value = 0; *(uint32_t *)max_value = 0; return VDP_STATUS_OK; case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT: case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH: *(uint32_t *)min_value = 0; *(uint32_t *)max_value = 8192; return VDP_STATUS_OK; } handle_release(device); return VDP_STATUS_ERROR; }
VdpStatus vdp_video_mixer_query_parameter_support(VdpDevice device, VdpVideoMixerParameter parameter, VdpBool *is_supported) { if (!is_supported) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; switch (parameter) { case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE: case VDP_VIDEO_MIXER_PARAMETER_LAYERS: case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT: case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH: *is_supported = VDP_TRUE; break; default: *is_supported = VDP_FALSE; break; } handle_release(device); return VDP_STATUS_OK; }
VdpStatus vdp_bitmap_surface_create(VdpDevice device, VdpRGBAFormat rgba_format, uint32_t width, uint32_t height, VdpBool frequently_accessed, VdpBitmapSurface *surface) { int ret = VDP_STATUS_OK; if (!surface) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; bitmap_surface_ctx_t *out = handle_create(sizeof(*out), surface); if (!out) return VDP_STATUS_RESOURCES; out->frequently_accessed = frequently_accessed; ret = rgba_create(&out->rgba, dev, width, height, rgba_format); if (ret != VDP_STATUS_OK) { handle_destroy(*surface); return ret; } return VDP_STATUS_OK; }
VdpStatus vdp_get_proc_address(VdpDevice device_handle, VdpFuncId function_id, void **function_pointer) { if (!function_pointer) return VDP_STATUS_INVALID_POINTER; device_ctx_t *device = handle_get(device_handle); if (!device) return VDP_STATUS_INVALID_HANDLE; if (function_id < ARRAY_SIZE(functions)) { *function_pointer = functions[function_id]; if (*function_pointer == NULL) return VDP_STATUS_INVALID_FUNC_ID; else return VDP_STATUS_OK; } else if (function_id == VDP_FUNC_ID_BASE_WINSYS) { *function_pointer = &vdp_presentation_queue_target_create_x11; return VDP_STATUS_OK; } return VDP_STATUS_INVALID_FUNC_ID; }
VdpStatus vdp_output_surface_create(VdpDevice device, VdpRGBAFormat rgba_format, uint32_t width, uint32_t height, VdpOutputSurface *surface) { int status = VDP_STATUS_OK; 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; output_surface_ctx_t *out = handle_create(sizeof(*out), surface, htype_output); if (out) { memset(out, 0, sizeof(*out)); out->width = width; out->height = height; out->rgba_format = rgba_format; out->contrast = 1.0; out->saturation = 1.0; out->device = dev; } else{ status = VDP_STATUS_RESOURCES; } handle_release(device); return status; }
VdpStatus vdp_output_surface_create(VdpDevice device, VdpRGBAFormat rgba_format, uint32_t width, uint32_t height, VdpOutputSurface *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; output_surface_ctx_t *out = calloc(1, sizeof(output_surface_ctx_t)); if (!out) return VDP_STATUS_RESOURCES; out->width = width; out->height = height; out->rgba_format = rgba_format; out->device = dev; int handle = handle_create(out); if (handle == -1) { free(out); return VDP_STATUS_RESOURCES; } *surface = handle; return VDP_STATUS_OK; }
VdpStatus vdp_decoder_query_capabilities(VdpDevice device, VdpDecoderProfile profile, VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks, uint32_t *max_width, uint32_t *max_height) { if (!is_supported || !max_level || !max_macroblocks || !max_width || !max_height) return VDP_STATUS_INVALID_POINTER; device_ctx_t *dev = handle_get(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; // guessed in lack of documentation, bigger pictures should be possible *max_level = 16; *max_width = 2048; *max_height = 1152; *max_macroblocks = (*max_width * *max_height) / (16 * 16); switch (profile) { case VDP_DECODER_PROFILE_MPEG1: case VDP_DECODER_PROFILE_MPEG2_SIMPLE: case VDP_DECODER_PROFILE_MPEG2_MAIN: case VDP_DECODER_PROFILE_H264_BASELINE: case VDP_DECODER_PROFILE_H264_MAIN: case VDP_DECODER_PROFILE_H264_HIGH: *is_supported = VDP_TRUE; break; default: *is_supported = VDP_FALSE; break; } return VDP_STATUS_OK; }
VdpStatus vdp_presentation_queue_block_until_surface_idle(VdpPresentationQueue presentation_queue, VdpOutputSurface surface, VdpTime *first_presentation_time) { queue_ctx_t *q = handle_get(presentation_queue); if (!q) return VDP_STATUS_INVALID_HANDLE; output_surface_ctx_t *out = handle_get(surface); if (!out) return VDP_STATUS_INVALID_HANDLE; *first_presentation_time = get_time(); return VDP_STATUS_OK; }
VdpStatus vdp_output_surface_render_output_surface(VdpOutputSurface destination_surface, VdpRect const *destination_rect, VdpOutputSurface source_surface, VdpRect const *source_rect, VdpColor const *colors, VdpOutputSurfaceRenderBlendState const *blend_state, uint32_t flags) { output_surface_ctx_t *out = handle_get(destination_surface); if (!out) return VDP_STATUS_INVALID_HANDLE; output_surface_ctx_t *in = handle_get(source_surface); if (!in) return VDP_STATUS_INVALID_HANDLE; VDPAU_DBG("%s called but unimplemented!", __func__); return VDP_STATUS_OK; }
VdpStatus vdp_video_surface_put_bits_y_cb_cr(VdpVideoSurface surface, VdpYCbCrFormat source_ycbcr_format, void const *const *source_data, uint32_t const *source_pitches) { video_surface_ctx_t *vs = handle_get(surface); if (!vs) return VDP_STATUS_INVALID_HANDLE; vs->source_format = source_ycbcr_format; switch (source_ycbcr_format) { case VDP_YCBCR_FORMAT_YUYV: case VDP_YCBCR_FORMAT_UYVY: case VDP_YCBCR_FORMAT_Y8U8V8A8: case VDP_YCBCR_FORMAT_V8U8Y8A8: break; case VDP_YCBCR_FORMAT_NV12: break; case VDP_YCBCR_FORMAT_YV12: memcpy(vs->data, source_data[0], source_pitches[0] * vs->height); memcpy(vs->data + vs->plane_size, source_data[1], source_pitches[1] * vs->height / 2); memcpy(vs->data + vs->plane_size + (vs->plane_size / 4), source_data[2], source_pitches[2] * vs->height / 2); break; } return VDP_STATUS_OK; }
VdpStatus vdp_video_surface_get_bits_y_cb_cr(VdpVideoSurface surface, VdpYCbCrFormat destination_ycbcr_format, void *const *destination_data, uint32_t const *destination_pitches) { video_surface_ctx_t *vs = handle_get(surface); if (!vs) return VDP_STATUS_INVALID_HANDLE; if (vs->chroma_type != VDP_CHROMA_TYPE_420 || vs->source_format != INTERNAL_YCBCR_FORMAT) return VDP_STATUS_INVALID_Y_CB_CR_FORMAT; if (destination_pitches[0] < vs->width || destination_pitches[1] < vs->width / 2) return VDP_STATUS_ERROR; switch (destination_ycbcr_format) { case VDP_YCBCR_FORMAT_NV12: tiled_to_planar(vs->yuv->data, destination_data[0], destination_pitches[0], vs->width, vs->height); tiled_to_planar(vs->yuv->data + vs->luma_size, destination_data[1], destination_pitches[1], vs->width, vs->height / 2); return VDP_STATUS_OK; case VDP_YCBCR_FORMAT_YV12: if (destination_pitches[2] != destination_pitches[1]) return VDP_STATUS_ERROR; tiled_to_planar(vs->yuv->data, destination_data[0], destination_pitches[0], vs->width, vs->height); tiled_deinterleave_to_planar(vs->yuv->data + vs->luma_size, destination_data[2], destination_data[1], destination_pitches[1], vs->width, vs->height / 2); return VDP_STATUS_OK; } return VDP_STATUS_ERROR; }
DDS_ReturnCode_t dcps_unregister_instance (DDS_DataWriter wp, const void *instance_data, int dynamic, const DDS_InstanceHandle_t handle, const FTime_t *time, DDS_InstanceHandleSeq *dests) { HCI hci; InstanceHandle h; handle_t d [MAX_DW_DESTS]; unsigned i, ndests; DDS_ReturnCode_t ret; prof_start (dcps_unregister); if (!writer_ptr (wp, 1, &ret)) return (ret); if (dests) { if (!dests->_length || !dests->_buffer) { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } else if (dests->_length > MAX_DW_DESTS) { ret = DDS_RETCODE_OUT_OF_RESOURCES; goto done; } for (i = 0; i < dests->_length; i++) d [i] = dests->_buffer [i]; while (i < MAX_DW_DESTS) d [i++] = 0; ndests = dests->_length; } else ndests = 0; if (!wp->w_topic->type->type_support->ts_keys) { ret = DDS_RETCODE_PRECONDITION_NOT_MET; goto done; } if (instance_data && handle == DDS_HANDLE_NIL) { hci = handle_get (wp->w_topic, wp->w_cache, instance_data, dynamic, ENC_DATA (&wp->w_lep), &h, &ret); if (!hci) goto done; } else if (handle != DDS_HANDLE_NIL) { h = (InstanceHandle) handle; hci = NULL; } else { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } ret = hc_unregister (wp->w_cache, h, hci, time, d, ndests); done: lock_release (wp->w_lock); prof_stop (dcps_unregister, 1); return (ret); }
cell_t *invoke(cell_t *fun, cell_t *args, environ_t *env) { int argslen, paramlen; environ_t *new_env; function_t *func = fun->slot2.fun; cell_t *ret; cell_t *code; handle_t *hc; argslen = proper_list_length(args,0); paramlen = proper_list_length(func->param_list, 0); if (argslen != paramlen) return NULL; /* error */ create_empty_environment(&new_env); extend(func->lexical_env, new_env, func->param_list, args); code = func->code; hc = handle_push(code); while (NULL != code && !NILP(code)) { ret = evaluate(CAR(code), new_env); // code handled code = handle_get(hc); code = CDR(code); handle_set(hc, code); } handle_pop(hc); return ret; }
static u32 handle_rpc(struct tee_tz *ptee, struct smc_param *param) { struct tee_shm *shm; int cookie; switch (TEESMC_RETURN_GET_RPC_FUNC(param->a0)) { case TEESMC_RPC_FUNC_ALLOC_ARG: param->a1 = tee_shm_pool_alloc(DEV, ptee->shm_pool, param->a1, 4); break; case TEESMC_RPC_FUNC_ALLOC_PAYLOAD: /* Can't support payload shared memory with this interface */ param->a2 = 0; break; case TEESMC_RPC_FUNC_FREE_ARG: tee_shm_pool_free(DEV, ptee->shm_pool, param->a1, 0); break; case TEESMC_RPC_FUNC_FREE_PAYLOAD: /* Can't support payload shared memory with this interface */ break; case TEESMC_ST_RPC_FUNC_ALLOC_PAYLOAD: shm = tee_shm_alloc_from_rpc(ptee->tee, param->a1, TEE_SHM_TEMP | TEE_SHM_FROM_RPC); if (!shm) { param->a1 = 0; break; } cookie = handle_get(&shm_handle_db, shm); if (cookie < 0) { tee_shm_free_from_rpc(shm); param->a1 = 0; break; } param->a1 = shm->paddr; param->a2 = cookie; break; case TEESMC_ST_RPC_FUNC_FREE_PAYLOAD: if (true || param->a1) { shm = handle_put(&shm_handle_db, param->a1); if (shm) tee_shm_free_from_rpc(shm); } break; case TEESMC_RPC_FUNC_IRQ: break; case TEESMC_RPC_FUNC_CMD: handle_rpc_func_cmd(ptee, param->a1); break; default: dev_warn(DEV, "Unknown RPC func 0x%x\n", (u32)TEESMC_RETURN_GET_RPC_FUNC(param->a0)); break; } if (irqs_disabled()) return TEESMC32_FASTCALL_RETURN_FROM_RPC; else return TEESMC32_CALL_RETURN_FROM_RPC; }
VdpStatus vdp_output_surface_render_bitmap_surface(VdpOutputSurface destination_surface, VdpRect const *destination_rect, VdpBitmapSurface source_surface, VdpRect const *source_rect, VdpColor const *colors, VdpOutputSurfaceRenderBlendState const *blend_state, uint32_t flags) { output_surface_ctx_t *out = handle_get(destination_surface); if (!out) return VDP_STATUS_INVALID_HANDLE; bitmap_surface_ctx_t *in = handle_get(source_surface); return rgba_render_surface(&out->rgba, destination_rect, in ? &in->rgba : NULL, source_rect, colors, blend_state, flags); }
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) return VDP_STATUS_RESOURCES; dec->device = dev; dec->profile = profile; dec->width = width; dec->height = height; dec->data = ve_malloc(VBV_SIZE); if (!(dec->data)) { free(dec); return VDP_STATUS_RESOURCES; } switch (profile) { case VDP_DECODER_PROFILE_MPEG1: case VDP_DECODER_PROFILE_MPEG2_SIMPLE: case VDP_DECODER_PROFILE_MPEG2_MAIN: dec->decode = mpeg12_decode; break; case VDP_DECODER_PROFILE_H264_BASELINE: case VDP_DECODER_PROFILE_H264_MAIN: case VDP_DECODER_PROFILE_H264_HIGH: if (h264_init(dec)) dec->decode = h264_decode; break; } if (!dec->decode) { free(dec); return VDP_STATUS_INVALID_DECODER_PROFILE; } int handle = handle_create(dec); if (handle == -1) { free(dec); return VDP_STATUS_RESOURCES; } *decoder = handle; return VDP_STATUS_OK; }
static int memcachefs_getattr(const char *path, struct stat *stbuf) { handle_t *handle; char *key; size_t keylen; void *val; size_t vallen; if(opt.verbose){ fprintf(stderr, "%s(\"%s\")\n", __func__, path); } memset(stbuf, 0, sizeof(struct stat)); if(!strcmp(path, "/")){ stbuf->st_ino = 1; stbuf->st_mode = S_IFDIR | 0755; // stbuf->st_mode = S_IFDIR; stbuf->st_uid = fuse_get_context()->uid; stbuf->st_gid = fuse_get_context()->gid; stbuf->st_nlink = 1; stbuf->st_atime = 0; stbuf->st_mtime = 0; stbuf->st_size = 0; return 0; } handle = handle_get(pool); if(!handle){ return -EMFILE; } key = (char *)path + 1; keylen = strlen(key); val = (char*)mc_aget2(handle->mc, key, keylen, &vallen); handle_release(pool, handle->index); if(!val){ return -ENOENT; } // get file attrs char *attrs = get_attrvalue(key); if (attrs != NULL) { stbuf->st_mode = S_IFDIR | 0666; } else { stbuf->st_mode = S_IFREG | 0666; } // printf("SAIDA: %s\n", attrs); // stbuf->st_mode = S_IFREG | 0666; // stbuf->st_mode = S_IFDIR | 0666; stbuf->st_uid = fuse_get_context()->uid; stbuf->st_gid = fuse_get_context()->gid; stbuf->st_nlink = 1; stbuf->st_size = vallen; free(val); free(attrs); return 0; }