Example #1
0
int
oggz_close (OGGZ * oggz)
{
  if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

  if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) {
    oggz_write_close (oggz);
  } else if (OGGZ_CONFIG_READ) {
    oggz_read_close (oggz);
  }

  oggz_vector_foreach (oggz->streams, oggz_stream_clear);
  oggz_vector_delete (oggz->streams);

  assert(oggz_dlist_is_empty(oggz->packet_buffer));
  oggz_dlist_delete(oggz->packet_buffer);
  
  if (oggz->metric_internal)
    oggz_free (oggz->metric_user_data);

  if (oggz->file != NULL) {
    if (fclose (oggz->file) == EOF) {
      return OGGZ_ERR_SYSTEM;
    }
  }

  if (oggz->io != NULL) {
    oggz_io_flush (oggz);
    oggz_free (oggz->io);
  }

  oggz_free (oggz);

  return 0;
}
Example #2
0
File: oggz.c Project: mariuz/haiku
int
oggz_close (OGGZ * oggz)
{
  if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

  oggz_vector_foreach (oggz->streams, oggz_stream_clear);
  oggz_vector_delete (oggz->streams);

  if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) {
    oggz_write_close (oggz);
  } else if (OGGZ_CONFIG_READ) {
    oggz_read_close (oggz);
  }

  if (oggz->file != NULL) {
    if (fclose (oggz->file) == EOF) {
      return OGGZ_ERR_SYSTEM;
    }
  }

  oggz_free (oggz);

  return 0;
}