GStreamer application access violation in random locations

pfarmer flacone at gmx.de
Mon Jan 4 03:56:50 PST 2016


Thank a lot for the answer. Sorry for the super late response. 

I tried to make a minimal example:

This is the *.cpp file that is compiled with VS2013 64bit:


#define S_FUNCTION_LEVEL 2
#define S_FUNCTION_NAME  sfunc_gstmin

#include <simstruc.h>

#include <cstring>

#include <gst/gst.h>
#include <gst/app/gstappsink.h>

enum {VIDEO_HEIGHT=640, VIDEO_WIDTH=360};

static void mdlInitializeSizes(SimStruct* S)
{
	if (!ssSetNumOutputPorts(S, 1)) return;
	ssSetOutputPortDataType(S, 0, SS_UINT32);
	ssSetOutputPortMatrixDimensions(S, 0, VIDEO_HEIGHT, VIDEO_WIDTH);
	ssSetNumPWork(S, 1);
	ssSetNumSampleTimes(S, 1);


}

static void mdlInitializeSampleTimes(SimStruct* S)
{
	ssSetSampleTime(S, 0, -1);
}

#define MDL_START
static void mdlStart(SimStruct* S)
{
	gst_init(NULL, NULL);
	GstElement* pipeline = gst_parse_launch(
		 "videotestsrc horizontal-speed=1 ! capsfilter name=filter ! appsink
max-buffers=3 drop=true name=sink",
		 NULL);
	GstElement* filter = gst_bin_get_by_name(GST_BIN(pipeline), "filter");
	GstCaps* caps = gst_caps_new_simple("video/x-raw",
		  "format", G_TYPE_STRING, "RGBA",
		  "width", G_TYPE_INT, VIDEO_WIDTH,
		  "height", G_TYPE_INT, VIDEO_HEIGHT,
		  "framerate", GST_TYPE_FRACTION, 10, 1,
	NULL);
	g_object_set(filter, "caps", caps, NULL);
	gst_element_set_state(pipeline, GST_STATE_PLAYING);

	ssGetPWork(S)[0] = static_cast<void *>(pipeline);
}

static void mdlOutputs(SimStruct* S, int_T tid)
{
	UNUSED_ARG(tid);
	uint32_T* signal = static_cast<uint32_T*>(ssGetOutputPortSignal(S, 0));
	GstElement* pipeline = static_cast<GstElement*>(ssGetPWork(S)[0]);
	GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
	GstMapInfo map;
	GstSample* sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
	if (sample != NULL)
	{
		GstBuffer* buffer = gst_sample_get_buffer(sample);
		if (gst_buffer_map(buffer, &map, GST_MAP_READ))
		{
			std::memcpy(signal, map.data, map.size);
			gst_buffer_unmap(buffer, &map);
		}
		gst_sample_unref(sample);
	}
}

static void mdlTerminate(SimStruct *S)
{
	GstElement* pipeline = static_cast<GstElement*>(ssGetPWork(S)[0]);
	gst_element_set_state(pipeline, GST_STATE_NULL);
}


// Required S-function trailer

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif



This is that run as a a user-defined S-Function inside Simulink. 
This crashes very infrequently. 






--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GStreamer-application-access-violation-in-random-locations-tp4674999p4675109.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list