我试图通过引用将变量传递给void
指针以更新原始值。当我尝试它时,旧值永远不会更新。任何帮助将不胜感激。
gst_filter_chain
就像主函数 ( Gstreamer
)
void update_value(void *oldValue, void *newValue)
{
oldValue = newValue;
}
void update_struct(myStruct *oldStruct, myStruct newStruct)
{
update_value((void *)&oldStruct->a, (void *)&newStruct.a)
}
static GstFlowReturn
gst_filter_chain (GstPad * pad, GstBuffer * buf)
{
GstFilter *filter= GST_FILTER (gst_pad_get_parent (pad));
myStruct temp_data;
int buf_size = GST_BUFFER_SIZE(buf);
if(buf_size > 1) //if buffer is not empty
{
if(!filter->is_init)
{
memcpy(&filter->data, GST_BUFFER_DATA(buf), sizeof(myStruct));
filter->is_init = TRUE;
}
else
{
memcpy(&temp_data, GST_BUFFER_DATA(buf), sizeof(myStruct));
update_struct(&filter->data, temp_data);
}
}
gst_buffer_unref(buf);
return GST_FLOW_OK;
}