Skip to content

support for subclassing buffer pool

This MR adds support for subclassing BufferPool by adding BufferPoolImp and BufferPoolImplExt.

loggable_error! and result_from_gboolean! have been extended to allow specifing the DebugLevel that should be used for logging in case of an Err Result. The change allows for example to issue warnings from BufferPoolImpl::set_config. An alternative would be to use Result<bool, LoggableError> instead of Result<(), LoggableError> for BufferPoolImpl::set_config and just use gst_warning! in the subclass and return Ok(false).

acquire_buffer and alloc_buffer return a Result with a custom error that wraps LoggableError and FlowError. I am not sure if it is worth adding the custom error struct. I tried to use a Result<Result<Buffer, FlowError>, LoggableError>, but that is really akward to use. Not sure what could be a practical alternative here while keeping the logic that the LoggableError is logged in the unsafe external 'C' functions.

There is an open issue for the following functions:

  • flush_start
  • flush_stop
  • free_buffer

The functions are called during destruction of the BufferPool where let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr); will fail with a panic because the ref count is already zero. I was unable to find a solution for that. I guess it could be fine to not override free_buffer as a rust implementation could handle all the destruction in it's Drop implementation.

Edited by Sebastian Dröge

Merge request reports