I'm getting a segfault upon calling mlt_frame_close after my consumer loop, the code is below, and it's really simple, it just gets the frame with rt_frame, and passes it to output. Output gets the image with mlt_frame_get_image and copies it over to shared memory. The segfault happens in the line marked with ///<<<<<<<<<<<<<<

I *think* it might have something to do with the playback velocity and whatnot. I wasn't able to figure out how to force this to be real time, and I'm thinking maybe I'm requesting the same frame twice and closing it or something of the sort, although I have seen the segfault happen on the first run of the thread loop

static void output( mlt_consumer this, void *share, int size, mlt_frame frame ) {
  // Get the properties
  mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );

  mlt_image_format fmt = mlt_properties_get_int(properties, "_format");
  int width = mlt_properties_get_int(properties, "width");
  int height = mlt_properties_get_int(properties, "height");
  pthread_rwlock_t *rwlock = mlt_properties_get_data(properties, "_rwlock", NULL);
  uint8_t *image=NULL;
  mlt_frame_get_image(frame, &image, &fmt, &width, &height, 0);
  int image_size = mlt_image_format_size(fmt, width, height, NULL);

  pthread_rwlock_wrlock(rwlock);

  void *walk = share;

  uint32_t *header = (uint32_t*) walk;

  header[0] = image_size;
  header[1] = fmt;
  header[2] = width;
  header[3] = height;
  walk = header + 4;
 
  memcpy(walk, image, image_size);
  walk += image_size;

  pthread_rwlock_unlock(rwlock);
}


static void *consumer_thread( void *arg ) {
  // Map the argument to the object
  mlt_consumer this = arg;

  // Get the properties
  mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );

  // Get the terminate_on_pause property
  int top = mlt_properties_get_int( properties, "terminate_on_pause" );

  // Frame and size
  mlt_frame frame = NULL;

  // shared memory info
  int size = 0;
  uint8_t *share = mlt_properties_get_data(properties, "_writespace", &size);

  // Loop while running
  while( mlt_properties_get_int( properties, "running" ) ) {
    // Get the frame
    frame = mlt_consumer_rt_frame( this );

    // Check that we have a frame to work with
    if ( frame != NULL ) {
      // Terminate on pause
      if ( top && mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame ), "_speed" ) == 0 ) {
        mlt_frame_close( frame );
        break;
      }
      output( this, share, size, frame );
      mlt_frame_close(frame);  ///<<<<<<<<<<<<<<
    }
  }

  mlt_consumer_stopped( this );

  return NULL;
}


Thanks

Tomas

--
"The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.