[gst-devel] virtual file support in audiofile

Baker, Steve SBaker at CHELLO.com
Sun Apr 21 05:25:02 CEST 2002


I am in the process of implementing an AFvirtualfile for our audiofile
GStreamer plugin. This will allow us to completely integrate audiofile into
the GStreamer system.

However afOpenVirtualFile isn't actually implemented even though it is in
the public header.

So below is my implementation - I know there is another patch floating
around so it would be good if something was commited to CVS.

Now I get a segfault the first time one of the vfile callbacks is called
(which just happens to be vfile->tell). My callback func isn't actually
reached but vfile->tell is non null.

I suspect linking voodoo is at fault. I would appreciate suggestions on what
I could look into.

cheers

Index: openclose.c
===================================================================
RCS file: /cvs/audiofile/libaudiofile/openclose.c,v
retrieving revision 1.8
diff -u -r1.8 openclose.c
--- openclose.c	2001/08/28 20:34:46	1.8
+++ openclose.c	2002/04/21 12:06:22
@@ -261,6 +263,44 @@
 
 	if (_afOpenFile(access, vf, filename, &filehandle, setup) !=
AF_SUCCEED)
 		af_fclose(vf);
+
+	return filehandle;
+}
+
+AFfilehandle afOpenVirtualFile (AFvirtualfile *vfile, const char *mode,
AFfilesetup setup)
+{
+	AFvirtualfile	*vf;
+	AFfilehandle	filehandle;
+	int		access;
+
+	if (mode == NULL)
+	{
+		_af_error(AF_BAD_ACCMODE, "null access mode");
+		return AF_NULL_FILEHANDLE;
+	}
+
+	if (mode[0] == 'r')
+		access = _AF_READ_ACCESS;
+	else if (mode[0] == 'w')
+		access = _AF_WRITE_ACCESS;
+	else
+	{
+		_af_error(AF_BAD_ACCMODE, "unrecognized access mode '%s'",
mode);
+		return AF_NULL_FILEHANDLE;
+	}
+
+	if (vfile == NULL)
+	{
+		_af_error(AF_BAD_OPEN, "virtual file is null");
+		return AF_NULL_FILEHANDLE;
+	}
+
+	printf("about to _afOpenFile\n");
+
+	if (_afOpenFile(access, vf, NULL, &filehandle, setup) !=
AF_SUCCEED){
+		printf("_afOpenFile failed");
+		af_fclose(vf);
+	}
 
 	return filehandle;
 }





More information about the gstreamer-devel mailing list