gstreamer-audio: Add Debug and Clone impls for AudioRingBufferSpec

This commit is contained in:
Sebastian Dröge 2019-12-18 15:35:24 +02:00
parent df251de2a1
commit 9657f4ce78

View file

@ -5,6 +5,8 @@ use gst_audio_sys::GstAudioRingBufferSpec;
use AudioInfo; use AudioInfo;
use AudioRingBufferFormatType; use AudioRingBufferFormatType;
use std::fmt;
#[repr(C)] #[repr(C)]
pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec); pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec);
@ -65,3 +67,37 @@ impl AudioRingBufferSpec {
self.0.seglatency = value; self.0.seglatency = value;
} }
} }
impl Clone for AudioRingBufferSpec {
fn clone(&self) -> Self {
unsafe {
let spec = self.0;
gst_sys::gst_mini_object_ref(spec.caps as *mut gst_sys::GstMiniObject);
AudioRingBufferSpec(spec)
}
}
}
impl Drop for AudioRingBufferSpec {
fn drop(&mut self) {
unsafe {
gst_sys::gst_mini_object_unref(self.0.caps as *mut gst_sys::GstMiniObject);
}
}
}
impl fmt::Debug for AudioRingBufferSpec {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.debug_struct("AudioRingBufferSpec")
.field("type", &self.get_type())
.field("caps", &self.get_caps())
.field("audio_info", &self.get_audio_info())
.field("latency_time", &self.get_latency_time())
.field("buffer_time", &self.get_buffer_time())
.field("segsize", &self.get_segsize())
.field("segtotal", &self.get_segtotal())
.field("seglatency", &self.get_seglatency())
.finish()
}
}