Also, I did have a thought as to why the audio functions properly, but the video crashes.
There are two audio callbacks in libretro:
pub type AudioSampleFunctionPointer = unsafe extern "C" fn(left: i16, right: i16);
pub type AudioSampleBatchFunctionPointer = unsafe extern "C" fn(data: *const i16, frames: libc::size_t) -> libc::size_t;
However, there is only one video callback:
pub type VideoRefreshFunctionPointer = unsafe extern "C" fn(data: *const libc::c_void, width: libc::c_uint, height: libc::c_uint, pitch: libc::size_t);
The one I am using for audio is the AudioSampleBatchFunctionPointer
, which says this from the documentation:
/* Renders multiple audio frames in one go.
*
* One frame is defined as a sample of left and right channels, interleaved.
* I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames.
* Only one of the audio callbacks must ever be used.
*/
The documentation for the video callback says this:
/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian
* unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).
*
* Width and height specify dimensions of buffer.
* Pitch specifices length in bytes between two lines in buffer.
*
* For performance reasons, it is highly recommended to have a frame
* that is packed in memory, i.e. pitch == width * byte_per_pixel.
* Certain graphic APIs, such as OpenGL ES, do not like textures
* that are not packed in memory.
*/
My thought is that GStreamer is rendering multiple frames for both audio and video, which is fine for the batch upload for audio, but it fails on the video upload, because it only expects one frame.