1

Using SBCL, I am trying to call a GStreamer function with this signature:

void gst_init (int *argc, char **argv[]);

so I wrote this interface code (simplified) based on what I had seen here:

(cffi:defcfun gst-init :VOID
  (argc :POINTER :INT)
  (argv :POINTER :STRING))
(defun start-gstreamer ()
   (cffi:with-foreign-object (argc :INT)
     (setf (cffi:mem-ref argc :INT) 1)
     (cffi:with-foreign-string (options "foo ")
       (cffi:with-foreign-object (poptions :POINTER)
         (setf (cffi:mem-ref poptions :POINTER) options)
         (gst-init argc poptions)))))

But when I run it I get a "memory fault" referencing an address that turns out to be an ASCII string of " oof", the reverse of the original string. It seems I need yet another level of indirection. Or maybe the defcfun is wrong. How do I accomplish this?

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
TwoNotes
  • 11
  • 1
  • I have not understood this completely but note that the second argument is not a pointer to a string: it's a pointer to an array of strings. –  Aug 01 '20 at 19:52

0 Answers0