static u32 vcd_set_buffer_requirements_cmn (struct vcd_clnt_ctxt *cctxt, enum vcd_buffer_type buffer, struct vcd_buffer_requirement *buffer_req) { struct vcd_property_hdr Prop_hdr; u32 rc = VCD_S_SUCCESS; struct vcd_buffer_pool *buf_pool; u32 first_frm_recvd = 0; VCD_MSG_LOW("vcd_set_buffer_requirements_cmn in %d:", cctxt->clnt_state.state); if (!cctxt->decoding && cctxt->clnt_state.state != VCD_CLIENT_STATE_OPEN) { VCD_MSG_ERROR("Bad state (%d) for encoder", cctxt->clnt_state.state); return VCD_ERR_BAD_STATE; } VCD_MSG_MED("Buffer type = %d", buffer); if (buffer == VCD_BUFFER_INPUT) { Prop_hdr.prop_id = DDL_I_INPUT_BUF_REQ; buf_pool = &cctxt->in_buf_pool; first_frm_recvd = VCD_FIRST_IP_RCVD; } else if (buffer == VCD_BUFFER_OUTPUT) { Prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; buf_pool = &cctxt->out_buf_pool; first_frm_recvd = VCD_FIRST_OP_RCVD; } else { rc = VCD_ERR_ILLEGAL_PARM; } VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); if (buf_pool->validated > 0) { VCD_MSG_ERROR("Need to free allocated buffers"); return VCD_ERR_ILLEGAL_OP; } first_frm_recvd &= cctxt->status.mask; if (first_frm_recvd) { VCD_MSG_ERROR("VCD SetBufReq called when data path is active"); return VCD_ERR_BAD_STATE; } Prop_hdr.sz = sizeof(*buffer_req); rc = ddl_set_property(cctxt->ddl_handle, &Prop_hdr, buffer_req); VCD_FAILED_RETURN(rc, "Failed: ddl_set_property"); if (buf_pool->entries) { VCD_MSG_MED("Resetting buffer requirements"); vcd_free_buffer_pool_entries(buf_pool); } return rc; }
static u32 vcd_set_buffer_requirements_cmn (struct vcd_clnt_ctxt_type_t *p_cctxt, enum vcd_buffer_type e_buffer, struct vcd_buffer_requirement_type *p_buffer_req) { struct vcd_property_hdr_type Prop_hdr; u32 rc = VCD_S_SUCCESS; struct vcd_buffer_pool_type *p_buf_pool; u32 b_first_frm_recvd = FALSE; VCD_MSG_LOW("vcd_set_buffer_requirements_cmn in %d:", p_cctxt->clnt_state.e_state); if (!p_cctxt->b_decoding && p_cctxt->clnt_state.e_state != VCD_CLIENT_STATE_OPEN) { VCD_MSG_ERROR("Bad state (%d) for encoder", p_cctxt->clnt_state.e_state); return VCD_ERR_BAD_STATE; } VCD_MSG_MED("Buffer type = %d", e_buffer); if (e_buffer == VCD_BUFFER_INPUT) { Prop_hdr.prop_id = DDL_I_INPUT_BUF_REQ; p_buf_pool = &p_cctxt->in_buf_pool; b_first_frm_recvd = p_cctxt->status.b_first_ip_frame_recvd; } else if (e_buffer == VCD_BUFFER_OUTPUT) { Prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; p_buf_pool = &p_cctxt->out_buf_pool; b_first_frm_recvd = p_cctxt->status.b_first_op_frame_recvd; } else { rc = VCD_ERR_ILLEGAL_PARM; } VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); if (p_buf_pool->n_validated > 0) { VCD_MSG_ERROR("Need to free allocated buffers"); return VCD_ERR_ILLEGAL_OP; } if (b_first_frm_recvd) { VCD_MSG_ERROR("VCD SetBufReq called when data path is active"); return VCD_ERR_BAD_STATE; } Prop_hdr.n_size = sizeof(*p_buffer_req); rc = ddl_set_property(p_cctxt->ddl_handle, &Prop_hdr, p_buffer_req); VCD_FAILED_RETURN(rc, "Failed: ddl_set_property"); if (p_buf_pool->a_entries) { VCD_MSG_MED("Resetting buffer requirements"); vcd_free_buffer_pool_entries(p_buf_pool); } rc = vcd_alloc_buffer_pool_entries(p_buf_pool, p_buffer_req); return rc; }