Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sdroege/gst-plugin-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2022-10-09 16:06:59 +0300
committerSebastian Dröge <sebastian@centricular.com>2022-10-10 15:03:25 +0300
commit7ee4afacf413b2e3c386bb1070994ed4325994e6 (patch)
treeeddcc0e047ab4704e5a459dd551a55196e8a1848 /audio/audiofx
parent7818ac658b02417fda071ce025b6d6a7fdb54a76 (diff)
Change *Impl trait methods to only take &self and not Self::Type in addition
Diffstat (limited to 'audio/audiofx')
-rw-r--r--audio/audiofx/src/audioecho/imp.rs25
-rw-r--r--audio/audiofx/src/audioloudnorm/imp.rs208
-rw-r--r--audio/audiofx/src/audiornnoise/imp.rs69
-rw-r--r--audio/audiofx/src/ebur128level/imp.rs112
-rw-r--r--audio/audiofx/src/hrtfrender/imp.rs60
5 files changed, 182 insertions, 292 deletions
diff --git a/audio/audiofx/src/audioecho/imp.rs b/audio/audiofx/src/audioecho/imp.rs
index ef606257..8659cce9 100644
--- a/audio/audiofx/src/audioecho/imp.rs
+++ b/audio/audiofx/src/audioecho/imp.rs
@@ -132,13 +132,7 @@ impl ObjectImpl for AudioEcho {
PROPERTIES.as_ref()
}
- fn set_property(
- &self,
- _obj: &Self::Type,
- _id: usize,
- value: &glib::Value,
- pspec: &glib::ParamSpec,
- ) {
+ fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
match pspec.name() {
"max-delay" => {
let mut settings = self.settings.lock().unwrap();
@@ -164,7 +158,7 @@ impl ObjectImpl for AudioEcho {
}
}
- fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
+ fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"max-delay" => {
let settings = self.settings.lock().unwrap();
@@ -236,11 +230,7 @@ impl BaseTransformImpl for AudioEcho {
const PASSTHROUGH_ON_SAME_CAPS: bool = false;
const TRANSFORM_IP_ON_PASSTHROUGH: bool = false;
- fn transform_ip(
- &self,
- _element: &Self::Type,
- buf: &mut gst::BufferRef,
- ) -> Result<gst::FlowSuccess, gst::FlowError> {
+ fn transform_ip(&self, buf: &mut gst::BufferRef) -> Result<gst::FlowSuccess, gst::FlowError> {
let mut settings = *self.settings.lock().unwrap();
settings.delay = cmp::min(settings.max_delay, settings.delay);
@@ -264,12 +254,7 @@ impl BaseTransformImpl for AudioEcho {
Ok(gst::FlowSuccess::Ok)
}
- fn set_caps(
- &self,
- _element: &Self::Type,
- incaps: &gst::Caps,
- outcaps: &gst::Caps,
- ) -> Result<(), gst::LoggableError> {
+ fn set_caps(&self, incaps: &gst::Caps, outcaps: &gst::Caps) -> Result<(), gst::LoggableError> {
if incaps != outcaps {
return Err(gst::loggable_error!(
CAT,
@@ -291,7 +276,7 @@ impl BaseTransformImpl for AudioEcho {
Ok(())
}
- fn stop(&self, _element: &Self::Type) -> Result<(), gst::ErrorMessage> {
+ fn stop(&self) -> Result<(), gst::ErrorMessage> {
// Drop state
let _ = self.state.lock().unwrap().take();
diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs
index 91e472d9..3ede79ba 100644
--- a/audio/audiofx/src/audioloudnorm/imp.rs
+++ b/audio/audiofx/src/audioloudnorm/imp.rs
@@ -218,7 +218,7 @@ impl State {
// Drains all full frames that are currently in the adapter
fn drain_full_frames(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
) -> Result<Vec<gst::Buffer>, gst::FlowError> {
let mut outbufs = vec![];
while self.adapter.available() >= self.info.bpf() as usize * self.current_samples_per_frame
@@ -241,7 +241,7 @@ impl State {
.as_slice_of::<f64>()
.map_err(|_| gst::FlowError::Error)?;
- let (mut outbuf, pts) = self.process(element, src, pts)?;
+ let (mut outbuf, pts) = self.process(imp, src, pts)?;
{
let outbuf = outbuf.get_mut().unwrap();
@@ -263,8 +263,8 @@ impl State {
}
// Drains everything
- fn drain(&mut self, element: &super::AudioLoudNorm) -> Result<gst::Buffer, gst::FlowError> {
- gst::debug!(CAT, obj: element, "Draining");
+ fn drain(&mut self, imp: &AudioLoudNorm) -> Result<gst::Buffer, gst::FlowError> {
+ gst::debug!(CAT, imp: imp, "Draining");
let (pts, distance) = self.adapter.prev_pts();
let distance_samples = distance / self.info.bpf() as u64;
@@ -299,11 +299,11 @@ impl State {
self.frame_type = FrameType::Final;
} else if src.is_empty() {
// Nothing to drain at all
- gst::debug!(CAT, obj: element, "No data to drain");
+ gst::debug!(CAT, imp: imp, "No data to drain");
return Err(gst::FlowError::Eos);
}
- let (mut outbuf, pts) = self.process(element, src, pts)?;
+ let (mut outbuf, pts) = self.process(imp, src, pts)?;
{
let outbuf = outbuf.get_mut().unwrap();
@@ -321,10 +321,7 @@ impl State {
Ok(outbuf)
}
- fn process_first_frame_is_last(
- &mut self,
- element: &super::AudioLoudNorm,
- ) -> Result<(), gst::FlowError> {
+ fn process_first_frame_is_last(&mut self, imp: &AudioLoudNorm) -> Result<(), gst::FlowError> {
// Calculated loudness in LUFS
let global = self
.r128_in
@@ -345,7 +342,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Calculated global loudness for first frame {} with peak {}",
global,
true_peak
@@ -371,7 +368,7 @@ impl State {
fn process_first_frame(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
src: &[f64],
pts: impl Into<Option<gst::ClockTime>>,
) -> Result<(gst::Buffer, Option<gst::ClockTime>), gst::FlowError> {
@@ -399,7 +396,7 @@ impl State {
self.prev_delta = self.delta[self.index];
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Initializing for first frame with gain adjustment of {}",
self.prev_delta
);
@@ -430,7 +427,7 @@ impl State {
.as_mut_slice_of::<f64>()
.map_err(|_| gst::FlowError::Error)?;
// This now consumes the first 100ms of limiter_buf for the output.
- self.true_peak_limiter(element, dst);
+ self.true_peak_limiter(imp, dst);
self.r128_out
.add_frames_f64(dst)
.map_err(|_| gst::FlowError::Error)?;
@@ -445,7 +442,7 @@ impl State {
Ok((outbuf, pts.into()))
}
- fn process_fill_inner_frame(&mut self, element: &super::AudioLoudNorm, src: &[f64]) {
+ fn process_fill_inner_frame(&mut self, imp: &AudioLoudNorm, src: &[f64]) {
// Get gain for this and the next 100ms frame based the delta array
// and smoothened with a gaussian filter.
let gain = self.gaussian_filter(if self.index + 10 < 30 {
@@ -461,7 +458,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Applying gain adjustment {}-{}",
gain,
gain_next
@@ -517,7 +514,7 @@ impl State {
fn process_update_gain_inner_frame(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
) -> Result<(), gst::FlowError> {
// Calculate global, shortterm loudness and relative threshold in LUFS.
let global = self
@@ -535,7 +532,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Calculated global loudness {}, short term loudness {} and relative threshold {}",
global,
shortterm,
@@ -558,7 +555,7 @@ impl State {
self.above_threshold = true;
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Above threshold now ({} >= {}, {} > -70)",
shortterm_out,
self.target_i,
@@ -586,7 +583,7 @@ impl State {
self.prev_delta = self.delta[self.index];
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Calculated new gain adjustment {}",
self.prev_delta
);
@@ -601,13 +598,13 @@ impl State {
fn process_inner_frame(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
src: &[f64],
pts: impl Into<Option<gst::ClockTime>>,
) -> Result<(gst::Buffer, Option<gst::ClockTime>), gst::FlowError> {
// Fill in these 100ms and adjust its gain according to previous measurements, and
// at the same time copy 100ms over to the limiter_buf.
- self.process_fill_inner_frame(element, src);
+ self.process_fill_inner_frame(imp, src);
// limiter_buf_index was 100ms advanced above, which brings us to exactly the
// position where we have to start consuming 100ms for the output now, and exactly
@@ -625,13 +622,13 @@ impl State {
.as_mut_slice_of::<f64>()
.map_err(|_| gst::FlowError::Error)?;
// This now consumes the next 100ms of limiter_buf for the output.
- self.true_peak_limiter(element, dst);
+ self.true_peak_limiter(imp, dst);
self.r128_out
.add_frames_f64(dst)
.map_err(|_| gst::FlowError::Error)?;
}
- self.process_update_gain_inner_frame(element)?;
+ self.process_update_gain_inner_frame(imp)?;
// PTS is 2.9s seconds before the input PTS as we buffer 3s of samples and just
// outputted here the first 100ms of that.
@@ -641,12 +638,7 @@ impl State {
Ok((outbuf, pts))
}
- fn process_fill_final_frame(
- &mut self,
- _element: &super::AudioLoudNorm,
- idx: usize,
- num_samples: usize,
- ) {
+ fn process_fill_final_frame(&mut self, _imp: &AudioLoudNorm, idx: usize, num_samples: usize) {
let channels = self.info.channels() as usize;
// Get gain for this and the next 100ms frame based the delta array
@@ -696,7 +688,7 @@ impl State {
fn process_final_frame(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
src: &[f64],
pts: impl Into<Option<gst::ClockTime>>,
) -> Result<(gst::Buffer, Option<gst::ClockTime>), gst::FlowError> {
@@ -706,14 +698,14 @@ impl State {
// First process any new/leftover data we get passed. This is the same
// as for inner frames. After this we will have done all gain adjustments
// and all samples we ever output are in buf or limiter_buf.
- self.process_fill_inner_frame(element, src);
+ self.process_fill_inner_frame(imp, src);
// If we got passed less than 100ms in src then limiter_buf_index is now
// not yet at the correct read position! Adjust accordingly here so that all
// further reads come from the right position by copying over the next samples
// from buf.
if num_samples != FRAME_SIZE {
- self.process_fill_final_frame(element, num_samples, FRAME_SIZE);
+ self.process_fill_final_frame(imp, num_samples, FRAME_SIZE);
}
// Now repeatadly run the limiter, output the output gain, update the gains, copy further
@@ -744,7 +736,7 @@ impl State {
// self.limiter_buf_index += FRAME_SIZE - num_samples;
//}
- self.true_peak_limiter(element, dst);
+ self.true_peak_limiter(imp, dst);
smp_cnt += frame_size;
if smp_cnt == out_num_samples {
@@ -755,11 +747,11 @@ impl State {
self.r128_out
.add_frames_f64(dst)
.map_err(|_| gst::FlowError::Error)?;
- self.process_update_gain_inner_frame(element)?;
+ self.process_update_gain_inner_frame(imp)?;
// And now copy over the next block of samples from buf to limiter_buf
let next_frame_size = std::cmp::min(out_num_samples - smp_cnt, FRAME_SIZE);
- self.process_fill_final_frame(element, 0, next_frame_size);
+ self.process_fill_final_frame(imp, 0, next_frame_size);
// Now for the very last frame we need to update the limiter buffer index by the
// amount of samples the last frame is short to reach the correct read position.
@@ -782,7 +774,7 @@ impl State {
fn process_linear_frame(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
src: &[f64],
pts: impl Into<Option<gst::ClockTime>>,
) -> Result<(gst::Buffer, Option<gst::ClockTime>), gst::FlowError> {
@@ -790,7 +782,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Applying linear gain adjustment of {}",
self.offset
);
@@ -819,7 +811,7 @@ impl State {
fn process(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
src: &[f64],
pts: impl Into<Option<gst::ClockTime>>,
) -> Result<(gst::Buffer, Option<gst::ClockTime>), gst::FlowError> {
@@ -833,20 +825,20 @@ impl State {
if self.frame_type == FrameType::First
&& (src.len() / self.info.channels() as usize) < self.current_samples_per_frame as usize
{
- self.process_first_frame_is_last(element)?;
+ self.process_first_frame_is_last(imp)?;
}
match self.frame_type {
- FrameType::First => self.process_first_frame(element, src, pts),
- FrameType::Inner => self.process_inner_frame(element, src, pts),
- FrameType::Final => self.process_final_frame(element, src, pts),
- FrameType::Linear => self.process_linear_frame(element, src, pts),
+ FrameType::First => self.process_first_frame(imp, src, pts),
+ FrameType::Inner => self.process_inner_frame(imp, src, pts),
+ FrameType::Final => self.process_final_frame(imp, src, pts),
+ FrameType::Linear => self.process_linear_frame(imp, src, pts),
}
}
fn true_peak_limiter_out(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
mut smp_cnt: usize,
nb_samples: usize,
) -> usize {
@@ -869,7 +861,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found peak {} at sample {}, going to attack state at sample {} (gain reduction {}-{})",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -887,7 +879,7 @@ impl State {
fn true_peak_limiter_attack(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
mut smp_cnt: usize,
nb_samples: usize,
) -> usize {
@@ -1006,7 +998,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found new peak {} at sample {}, restarting attack state at sample {} (gain reduction {}-{})",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -1055,7 +1047,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found new peak {} at sample {}, adjusting attack state at sample {} (gain reduction {}-{})",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -1070,7 +1062,7 @@ impl State {
// to ensure that we at least sustain it for that long afterwards.
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found new low peak {} at sample {} in attack state at sample {}",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -1086,7 +1078,7 @@ impl State {
// If we reached the target gain reduction, go into sustain state.
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Going to sustain state at sample {} (gain reduction {})",
smp_cnt,
self.gain_reduction[1]
@@ -1100,7 +1092,7 @@ impl State {
fn true_peak_limiter_sustain(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
mut smp_cnt: usize,
nb_samples: usize,
) -> usize {
@@ -1165,7 +1157,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found new peak {} at sample {}, going back to attack state at sample {} (gain reduction {}-{})",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -1176,7 +1168,7 @@ impl State {
} else {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found new peak {} at sample {}, going sustain further at sample {} (gain reduction {})",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -1203,7 +1195,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Going to release state for sample {} at sample {} (gain reduction {}-1.0)",
smp_cnt + LIMITER_RELEASE_WINDOW,
smp_cnt,
@@ -1216,7 +1208,7 @@ impl State {
fn true_peak_limiter_release(
&mut self,
- element: &super::AudioLoudNorm,
+ imp: &AudioLoudNorm,
mut smp_cnt: usize,
nb_samples: usize,
) -> usize {
@@ -1273,7 +1265,7 @@ impl State {
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Found new peak {} at sample {}, going back to attack state at sample {} (gain reduction {}-{})",
peak_value,
smp_cnt + LIMITER_ATTACK_WINDOW,
@@ -1285,7 +1277,7 @@ impl State {
self.gain_reduction[1] = current_gain_reduction;
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Going from release to sustain state at sample {} because of low peak {} at sample {} (gain reduction {})",
smp_cnt,
peak_value,
@@ -1326,7 +1318,7 @@ impl State {
self.limiter_state = LimiterState::Out;
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Leaving release state and going to out state at sample {}",
smp_cnt,
);
@@ -1335,7 +1327,7 @@ impl State {
smp_cnt
}
- fn true_peak_limiter_first_frame(&mut self, element: &super::AudioLoudNorm) {
+ fn true_peak_limiter_first_frame(&mut self, imp: &AudioLoudNorm) {
let channels = self.info.channels() as usize;
assert_eq!(self.limiter_buf_index, 0);
@@ -1364,7 +1356,7 @@ impl State {
self.gain_reduction[1] = self.target_tp / max;
gst::debug!(
CAT,
- obj: element,
+ imp: imp,
"Reducing gain for start of first frame by {} ({} > {}) and going to sustain state",
self.gain_reduction[1],
max,
@@ -1376,38 +1368,33 @@ impl State {
}
}
- fn true_peak_limiter(&mut self, element: &super::AudioLoudNorm, dst: &mut [f64]) {
+ fn true_peak_limiter(&mut self, imp: &AudioLoudNorm, dst: &mut [f64]) {
let channels = self.info.channels() as usize;
let nb_samples = dst.len() / channels;
- gst::debug!(
- CAT,
- obj: element,
- "Running limiter for {} samples",
- nb_samples
- );
+ gst::debug!(CAT, imp: imp, "Running limiter for {} samples", nb_samples);
// For the first frame we can't adjust the gain before it smoothly anymore so instead
// apply the gain reduction immediately if we get above the threshold and move to sustain
// state directly.
if self.frame_type == FrameType::First {
- self.true_peak_limiter_first_frame(element);
+ self.true_peak_limiter_first_frame(imp);
}
let mut smp_cnt = 0;
while smp_cnt < nb_samples {
match self.limiter_state {
LimiterState::Out => {
- smp_cnt = self.true_peak_limiter_out(element, smp_cnt, nb_samples);
+ smp_cnt = self.true_peak_limiter_out(imp, smp_cnt, nb_samples);
}
LimiterState::Attack => {
- smp_cnt = self.true_peak_limiter_attack(element, smp_cnt, nb_samples);
+ smp_cnt = self.true_peak_limiter_attack(imp, smp_cnt, nb_samples);
}
LimiterState::Sustain => {
- smp_cnt = self.true_peak_limiter_sustain(element, smp_cnt, nb_samples);
+ smp_cnt = self.true_peak_limiter_sustain(imp, smp_cnt, nb_samples);
}
LimiterState::Release => {
- smp_cnt = self.true_peak_limiter_release(element, smp_cnt, nb_samples);
+ smp_cnt = self.true_peak_limiter_release(imp, smp_cnt, nb_samples);
}
}
}
@@ -1552,15 +1539,14 @@ impl AudioLoudNorm {
fn sink_chain(
&self,
_pad: &gst::Pad,
- element: &super::AudioLoudNorm,
buffer: gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError> {
- gst::log!(CAT, obj: element, "Handling buffer {:?}", buffer);
+ gst::log!(CAT, imp: self, "Handling buffer {:?}", buffer);
let mut state_guard = self.state.borrow_mut();
let state = match *state_guard {
None => {
- gst::error!(CAT, obj: element, "Not negotiated yet");
+ gst::error!(CAT, imp: self, "Not negotiated yet");
return Err(gst::FlowError::NotNegotiated);
}
Some(ref mut state) => state,
@@ -1568,8 +1554,8 @@ impl AudioLoudNorm {
let mut outbufs = vec![];
if buffer.flags().contains(gst::BufferFlags::DISCONT) {
- gst::debug!(CAT, obj: element, "Draining on discontinuity");
- match state.drain(element) {
+ gst::debug!(CAT, imp: self, "Draining on discontinuity");
+ match state.drain(self) {
Ok(outbuf) => {
outbufs.push(outbuf);
}
@@ -1582,23 +1568,18 @@ impl AudioLoudNorm {
}
state.adapter.push(buffer);
- outbufs.append(&mut state.drain_full_frames(element)?);
+ outbufs.append(&mut state.drain_full_frames(self)?);
drop(state_guard);
for buffer in outbufs {
- gst::log!(CAT, obj: element, "Outputting buffer {:?}", buffer);
+ gst::log!(CAT, imp: self, "Outputting buffer {:?}", buffer);
self.srcpad.push(buffer)?;
}
Ok(gst::FlowSuccess::Ok)
}
- fn sink_event(
- &self,
- pad: &gst::Pad,
- element: &super::AudioLoudNorm,
- event: gst::Event,
- ) -> bool {
+ fn sink_event(&self, pad: &gst::Pad, event: gst::Event) -> bool {
use gst::EventView;
gst::log!(CAT, obj: pad, "Handling event {:?}", event);
@@ -1619,7 +1600,7 @@ impl AudioLoudNorm {
let mut state = self.state.borrow_mut();
let mut outbuf = None;
if let Some(ref mut state) = &mut *state {
- outbuf = match state.drain(element) {
+ outbuf = match state.drain(self) {
Ok(outbuf) => Some(outbuf),
Err(gst::FlowError::Eos) => None,
Err(_) => return false,
@@ -1629,9 +1610,9 @@ impl AudioLoudNorm {
drop(state);
if let Some(outbuf) = outbuf {
- gst::log!(CAT, obj: element, "Outputting buffer {:?}", outbuf);
+ gst::log!(CAT, imp: self, "Outputting buffer {:?}", outbuf);
if let Err(err) = self.srcpad.push(outbuf) {
- gst::error!(CAT, obj: element, "Failed to push drained data: {}", err);
+ gst::error!(CAT, imp: self, "Failed to push drained data: {}", err);
return false;
}
@@ -1641,7 +1622,7 @@ impl AudioLoudNorm {
let mut state = self.state.borrow_mut();
let mut outbuf = None;
if let Some(ref mut state) = &mut *state {
- outbuf = match state.drain(element) {
+ outbuf = match state.drain(self) {
Ok(outbuf) => Some(outbuf),
Err(gst::FlowError::Eos) => None,
Err(_) => return false,
@@ -1651,11 +1632,11 @@ impl AudioLoudNorm {
drop(state);
if let Some(outbuf) = outbuf {
- gst::log!(CAT, obj: element, "Outputting buffer {:?}", outbuf);
+ gst::log!(CAT, imp: self, "Outputting buffer {:?}", outbuf);
if let Err(err) = self.srcpad.push(outbuf) {
gst::error!(
CAT,
- obj: element,
+ imp: self,
"Failed to push drained data on EOS: {}",
err
);
@@ -1678,16 +1659,11 @@ impl AudioLoudNorm {
_ => (),
}
- pad.event_default(Some(element), event)
+ pad.event_default(Some(&*self.instance()), event)
}
#[allow(clippy::single_match)]
- fn src_query(
- &self,
- pad: &gst::Pad,
- element: &super::AudioLoudNorm,
- query: &mut gst::QueryRef,
- ) -> bool {
+ fn src_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
use gst::QueryViewMut;
gst::log!(CAT, obj: pad, "Handling query {:?}", query);
@@ -1706,7 +1682,7 @@ impl AudioLoudNorm {
false
}
}
- _ => pad.query_default(Some(element), query),
+ _ => pad.query_default(Some(&*self.instance()), query),
}
}
}
@@ -1724,15 +1700,11 @@ impl ObjectSubclass for AudioLoudNorm {
Self::catch_panic_pad_function(
parent,
|| Err(gst::FlowError::Error),
- |this, element| this.sink_chain(pad, element, buffer),
+ |this| this.sink_chain(pad, buffer),
)
})
.event_function(|pad, parent, event| {
- Self::catch_panic_pad_function(
- parent,
- || false,
- |this, element| this.sink_event(pad, element, event),
- )
+ Self::catch_panic_pad_function(parent, || false, |this| this.sink_event(pad, event))
})
.flags(gst::PadFlags::PROXY_CAPS)
.build();
@@ -1740,11 +1712,7 @@ impl ObjectSubclass for AudioLoudNorm {
let templ = klass.pad_template("src").unwrap();
let srcpad = gst::Pad::builder_with_template(&templ, Some("src"))
.query_function(|pad, parent, query| {
- Self::catch_panic_pad_function(
- parent,
- || false,
- |this, element| this.src_query(pad, element, query),
- )
+ Self::catch_panic_pad_function(parent, || false, |this| this.src_query(pad, query))
})
.flags(gst::PadFlags::PROXY_CAPS)
.build();
@@ -1800,20 +1768,15 @@ impl ObjectImpl for AudioLoudNorm {
PROPERTIES.as_ref()
}
- fn constructed(&self, obj: &Self::Type) {
- self.parent_constructed(obj);
+ fn constructed(&self) {
+ self.parent_constructed();
+ let obj = self.instance();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}
- fn set_property(
- &self,
- _obj: &Self::Type,
- _id: usize,
- value: &glib::Value,
- pspec: &glib::ParamSpec,
- ) {
+ fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
match pspec.name() {
"loudness-target" => {
let mut settings = self.settings.lock().unwrap();
@@ -1835,7 +1798,7 @@ impl ObjectImpl for AudioLoudNorm {
}
}
- fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
+ fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"loudness-target" => {
let settings = self.settings.lock().unwrap();
@@ -1905,10 +1868,9 @@ impl ElementImpl for AudioLoudNorm {
#[allow(clippy::single_match)]
fn change_state(
&self,
- element: &Self::Type,
transition: gst::StateChange,
) -> Result<gst::StateChangeSuccess, gst::StateChangeError> {
- let res = self.parent_change_state(element, transition);
+ let res = self.parent_change_state(transition);
match transition {
gst::StateChange::PausedToReady => {
diff --git a/audio/audiofx/src/audiornnoise/imp.rs b/audio/audiofx/src/audiornnoise/imp.rs
index 4454815e..321bf40a 100644
--- a/audio/audiofx/src/audiornnoise/imp.rs
+++ b/audio/audiofx/src/audiornnoise/imp.rs
@@ -10,6 +10,7 @@
use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
+use gst_base::prelude::*;
use gst_base::subclass::base_transform::BaseTransformImplExt;
use gst_base::subclass::base_transform::GenerateOutputSuccess;
use gst_base::subclass::prelude::*;
@@ -121,7 +122,7 @@ impl State {
}
impl AudioRNNoise {
- fn drain(&self, element: &super::AudioRNNoise) -> Result<gst::FlowSuccess, gst::FlowError> {
+ fn drain(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let mut state_lock = self.state.borrow_mut();
let state = state_lock.as_mut().unwrap();
@@ -131,12 +132,7 @@ impl AudioRNNoise {
}
let mut buffer = gst::Buffer::with_size(available).map_err(|e| {
- gst::error!(
- CAT,
- obj: element,
- "Failed to allocate buffer at EOS {:?}",
- e
- );
+ gst::error!(CAT, imp: self, "Failed to allocate buffer at EOS {:?}", e);
gst::FlowError::Flushing
})?;
@@ -158,15 +154,10 @@ impl AudioRNNoise {
state.process(in_data, out_data);
}
- let srcpad = element.static_pad("src").unwrap();
- srcpad.push(buffer)
+ self.instance().src_pad().push(buffer)
}
- fn generate_output(
- &self,
- _element: &super::AudioRNNoise,
- state: &mut State,
- ) -> Result<GenerateOutputSuccess, gst::FlowError> {
+ fn generate_output(&self, state: &mut State) -> Result<GenerateOutputSuccess, gst::FlowError> {
let available = state.adapter.available();
let bpf = state.in_info.bpf() as usize;
let output_size = available - (available % (FRAME_SIZE * bpf));
@@ -257,16 +248,11 @@ impl BaseTransformImpl for AudioRNNoise {
const PASSTHROUGH_ON_SAME_CAPS: bool = false;
const TRANSFORM_IP_ON_PASSTHROUGH: bool = false;
- fn set_caps(
- &self,
- element: &Self::Type,
- incaps: &gst::Caps,
- outcaps: &gst::Caps,
- ) -> Result<(), gst::LoggableError> {
+ fn set_caps(&self, incaps: &gst::Caps, outcaps: &gst::Caps) -> Result<(), gst::LoggableError> {
// Flush previous state
if self.state.borrow_mut().is_some() {
- self.drain(element).map_err(|e| {
- gst::loggable_error!(CAT, "Error flusing previous state data {:?}", e)
+ self.drain().map_err(|e| {
+ gst::loggable_error!(CAT, "Error flushing previous state data {:?}", e)
})?;
}
if incaps != outcaps {
@@ -276,7 +262,7 @@ impl BaseTransformImpl for AudioRNNoise {
));
}
- gst::debug!(CAT, obj: element, "Set caps to {}", incaps);
+ gst::debug!(CAT, imp: self, "Set caps to {}", incaps);
let in_info = gst_audio::AudioInfo::from_caps(incaps)
.map_err(|e| gst::loggable_error!(CAT, "Failed to parse input caps {:?}", e))?;
@@ -300,22 +286,19 @@ impl BaseTransformImpl for AudioRNNoise {
Ok(())
}
- fn generate_output(
- &self,
- element: &Self::Type,
- ) -> Result<GenerateOutputSuccess, gst::FlowError> {
+ fn generate_output(&self) -> Result<GenerateOutputSuccess, gst::FlowError> {
// Check if there are enough data in the queued buffer and adapter,
// if it is not the case, just notify the parent class to not generate
// an output
if let Some(buffer) = self.take_queued_buffer() {
if buffer.flags().contains(gst::BufferFlags::DISCONT) {
- self.drain(element)?;
+ self.drain()?;
}
let mut state_guard = self.state.borrow_mut();
let state = state_guard.as_mut().ok_or_else(|| {
- gst::element_error!(
- element,
+ gst::element_imp_error!(
+ self,
gst::CoreError::Negotiation,
["Can not generate an output without State"]
);
@@ -324,39 +307,33 @@ impl BaseTransformImpl for AudioRNNoise {
state.adapter.push(buffer);
if !state.needs_more_data() {
- return self.generate_output(element, state);
+ return self.generate_output(state);
}
}
Ok(GenerateOutputSuccess::NoOutput)
}
- fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
+ fn sink_event(&self, event: gst::Event) -> bool {
use gst::EventView;
if let EventView::Eos(_) = event.view() {
- gst::debug!(CAT, obj: element, "Handling EOS");
- if self.drain(element).is_err() {
+ gst::debug!(CAT, imp: self, "Handling EOS");
+ if self.drain().is_err() {
return false;
}
}
- self.parent_sink_event(element, event)
+ self.parent_sink_event(event)
}
- fn query(
- &self,
- element: &Self::Type,
- direction: gst::PadDirection,
- query: &mut gst::QueryRef,
- ) -> bool {
+ fn query(&self, direction: gst::PadDirection, query: &mut gst::QueryRef) -> bool {
if direction == gst::PadDirection::Src {
if let gst::QueryViewMut::Latency(q) = query.view_mut() {
- let sink_pad = element.static_pad("sink").expect("Sink pad not found");
let mut upstream_query = gst::query::Latency::new();
- if sink_pad.peer_query(&mut upstream_query) {
+ if self.instance().sink_pad().peer_query(&mut upstream_query) {
let (live, mut min, mut max) = upstream_query.result();
gst::debug!(
CAT,
- obj: element,
+ imp: self,
"Peer latency: live {} min {} max {}",
live,
min,
@@ -370,10 +347,10 @@ impl BaseTransformImpl for AudioRNNoise {
}
}
}
- BaseTransformImplExt::parent_query(self, element, direction, query)
+ BaseTransformImplExt::parent_query(self, direction, query)
}
- fn stop(&self, _element: &Self::Type) -> Result<(), gst::ErrorMessage> {
+ fn stop(&self) -> Result<(), gst::ErrorMessage> {
// Drop state
let _ = self.state.borrow_mut().take();
diff --git a/audio/audiofx/src/ebur128level/imp.rs b/audio/audiofx/src/ebur128level/imp.rs
index ae9fa35f..dd0135bf 100644
--- a/audio/audiofx/src/ebur128level/imp.rs
+++ b/audio/audiofx/src/ebur128level/imp.rs
@@ -169,20 +169,14 @@ impl ObjectImpl for EbuR128Level {
PROPERTIES.as_ref()
}
- fn set_property(
- &self,
- obj: &Self::Type,
- _id: usize,
- value: &glib::Value,
- pspec: &glib::ParamSpec,
- ) {
+ fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
let mut settings = self.settings.lock().unwrap();
match pspec.name() {
"mode" => {
let mode = value.get().expect("type checked upstream");
gst::info!(
CAT,
- obj: obj,
+ imp: self,
"Changing mode from {:?} to {:?}",
settings.mode,
mode
@@ -193,7 +187,7 @@ impl ObjectImpl for EbuR128Level {
let post_messages = value.get().expect("type checked upstream");
gst::info!(
CAT,
- obj: obj,
+ imp: self,
"Changing post-messages from {} to {}",
settings.post_messages,
post_messages
@@ -205,7 +199,7 @@ impl ObjectImpl for EbuR128Level {
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
gst::info!(
CAT,
- obj: obj,
+ imp: self,
"Changing interval from {} to {}",
settings.interval,
interval,
@@ -216,7 +210,7 @@ impl ObjectImpl for EbuR128Level {
}
}
- fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
+ fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
let settings = self.settings.lock().unwrap();
match pspec.name() {
"mode" => settings.mode.to_value(),
@@ -290,18 +284,13 @@ impl BaseTransformImpl for EbuR128Level {
const PASSTHROUGH_ON_SAME_CAPS: bool = true;
const TRANSFORM_IP_ON_PASSTHROUGH: bool = true;
- fn set_caps(
- &self,
- element: &Self::Type,
- incaps: &gst::Caps,
- _outcaps: &gst::Caps,
- ) -> Result<(), gst::LoggableError> {
+ fn set_caps(&self, incaps: &gst::Caps, _outcaps: &gst::Caps) -> Result<(), gst::LoggableError> {
let info = match gst_audio::AudioInfo::from_caps(incaps) {
Err(_) => return Err(gst::loggable_error!(CAT, "Failed to parse input caps")),
Ok(info) => info,
};
- gst::debug!(CAT, obj: element, "Configured for caps {}", incaps,);
+ gst::debug!(CAT, imp: self, "Configured for caps {}", incaps,);
let settings = *self.settings.lock().unwrap();
@@ -364,7 +353,7 @@ impl BaseTransformImpl for EbuR128Level {
val => {
gst::debug!(
CAT,
- obj: element,
+ imp: self,
"Unknown channel position {:?}, ignoring channel",
val
);
@@ -402,39 +391,38 @@ impl BaseTransformImpl for EbuR128Level {
Ok(())
}
- fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
+ fn stop(&self) -> Result<(), gst::ErrorMessage> {
// Drop state
let _ = self.state.borrow_mut().take();
- gst::info!(CAT, obj: element, "Stopped");
+ gst::info!(CAT, imp: self, "Stopped");
Ok(())
}
fn transform_ip_passthrough(
&self,
- element: &Self::Type,
buf: &gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError> {
let settings = *self.settings.lock().unwrap();
let mut state_guard = self.state.borrow_mut();
let mut state = state_guard.as_mut().ok_or_else(|| {
- gst::element_error!(element, gst::CoreError::Negotiation, ["Have no state yet"]);
+ gst::element_imp_error!(self, gst::CoreError::Negotiation, ["Have no state yet"]);
gst::FlowError::NotNegotiated
})?;
let mut timestamp = buf.pts();
- let segment = element.segment().downcast::<gst::ClockTime>().ok();
+ let segment = self.instance().segment().downcast::<gst::ClockTime>().ok();
let buf = gst_audio::AudioBufferRef::from_buffer_ref_readable(buf, &state.info).map_err(
|_| {
- gst::element_error!(element, gst::ResourceError::Read, ["Failed to map buffer"]);
+ gst::element_imp_error!(self, gst::ResourceError::Read, ["Failed to map buffer"]);
gst::FlowError::Error
},
)?;
- let mut frames = Frames::from_audio_buffer(element, &buf)?;
+ let mut frames = Frames::from_audio_buffer(self, &buf)?;
while frames.num_frames() > 0 {
if self
.reset
@@ -459,8 +447,8 @@ impl BaseTransformImpl for EbuR128Level {
frames
.process(to_process, &mut state.ebur128)
.map_err(|err| {
- gst::element_error!(
- element,
+ gst::element_imp_error!(
+ self,
gst::ResourceError::Read,
["Failed to process buffer: {}", err]
);
@@ -498,7 +486,7 @@ impl BaseTransformImpl for EbuR128Level {
Ok(loudness) => s.set("momentary-loudness", &loudness),
Err(err) => gst::error!(
CAT,
- obj: element,
+ imp: self,
"Failed to get momentary loudness: {}",
err
),
@@ -510,7 +498,7 @@ impl BaseTransformImpl for EbuR128Level {
Ok(loudness) => s.set("shortterm-loudness", &loudness),
Err(err) => gst::error!(
CAT,
- obj: element,
+ imp: self,
"Failed to get shortterm loudness: {}",
err
),
@@ -522,7 +510,7 @@ impl BaseTransformImpl for EbuR128Level {
Ok(loudness) => s.set("global-loudness", &loudness),
Err(err) => gst::error!(
CAT,
- obj: element,
+ imp: self,
"Failed to get global loudness: {}",
err
),
@@ -532,7 +520,7 @@ impl BaseTransformImpl for EbuR128Level {
Ok(threshold) => s.set("relative-threshold", &threshold),
Err(err) => gst::error!(
CAT,
- obj: element,
+ imp: self,
"Failed to get relative threshold: {}",
err
),
@@ -542,12 +530,9 @@ impl BaseTransformImpl for EbuR128Level {
if state.ebur128.mode().contains(ebur128::Mode::LRA) {
match state.ebur128.loudness_range() {
Ok(range) => s.set("loudness-range", &range),
- Err(err) => gst::error!(
- CAT,
- obj: element,
- "Failed to get loudness range: {}",
- err
- ),
+ Err(err) => {
+ gst::error!(CAT, imp: self, "Failed to get loudness range: {}", err)
+ }
}
}
@@ -559,12 +544,7 @@ impl BaseTransformImpl for EbuR128Level {
match peaks {
Ok(peaks) => s.set("sample-peak", gst::Array::from(peaks)),
Err(err) => {
- gst::error!(
- CAT,
- obj: element,
- "Failed to get sample peaks: {}",
- err
- )
+ gst::error!(CAT, imp: self, "Failed to get sample peaks: {}", err)
}
}
}
@@ -577,24 +557,26 @@ impl BaseTransformImpl for EbuR128Level {
match peaks {
Ok(peaks) => s.set("true-peak", gst::Array::from(peaks)),
Err(err) => {
- gst::error!(CAT, obj: element, "Failed to get true peaks: {}", err)
+ gst::error!(CAT, imp: self, "Failed to get true peaks: {}", err)
}
}
}
- gst::debug!(CAT, obj: element, "Posting message {}", s);
+ gst::debug!(CAT, imp: self, "Posting message {}", s);
- let msg = gst::message::Element::builder(s).src(element).build();
+ let msg = gst::message::Element::builder(s)
+ .src(&*self.instance())
+ .build();
// Release lock while posting the message to avoid deadlocks
drop(state_guard);
- let _ = element.post_message(msg);
+ let _ = self.instance().post_message(msg);
state_guard = self.state.borrow_mut();
state = state_guard.as_mut().ok_or_else(|| {
- gst::element_error!(
- element,
+ gst::element_imp_error!(
+ self,
gst::CoreError::Negotiation,
["Have no state yet"]
);
@@ -623,37 +605,37 @@ enum Frames<'a> {
impl<'a> Frames<'a> {
/// Create a new frames wrapper that allows chunked processing.
fn from_audio_buffer(
- element: &super::EbuR128Level,
+ imp: &EbuR128Level,
buf: &'a gst_audio::AudioBufferRef<&'a gst::BufferRef>,
) -> Result<Self, gst::FlowError> {
match (buf.format(), buf.layout()) {
(gst_audio::AUDIO_FORMAT_S16, gst_audio::AudioLayout::Interleaved) => Ok(Frames::S16(
- interleaved_channel_data_into_slice(element, buf)?,
+ interleaved_channel_data_into_slice(imp, buf)?,
buf.channels() as usize,
)),
(gst_audio::AUDIO_FORMAT_S32, gst_audio::AudioLayout::Interleaved) => Ok(Frames::S32(
- interleaved_channel_data_into_slice(element, buf)?,
+ interleaved_channel_data_into_slice(imp, buf)?,
buf.channels() as usize,
)),
(gst_audio::AUDIO_FORMAT_F32, gst_audio::AudioLayout::Interleaved) => Ok(Frames::F32(
- interleaved_channel_data_into_slice(element, buf)?,
+ interleaved_channel_data_into_slice(imp, buf)?,
buf.channels() as usize,
)),
(gst_audio::AUDIO_FORMAT_F64, gst_audio::AudioLayout::Interleaved) => Ok(Frames::F64(
- interleaved_channel_data_into_slice(element, buf)?,
+ interleaved_channel_data_into_slice(imp, buf)?,
buf.channels() as usize,
)),
(gst_audio::AUDIO_FORMAT_S16, gst_audio::AudioLayout::NonInterleaved) => Ok(
- Frames::S16P(non_interleaved_channel_data_into_slices(element, buf)?),
+ Frames::S16P(non_interleaved_channel_data_into_slices(imp, buf)?),
),
(gst_audio::AUDIO_FORMAT_S32, gst_audio::AudioLayout::NonInterleaved) => Ok(
- Frames::S32P(non_interleaved_channel_data_into_slices(element, buf)?),
+ Frames::S32P(non_interleaved_channel_data_into_slices(imp, buf)?),
),
(gst_audio::AUDIO_FORMAT_F32, gst_audio::AudioLayout::NonInterleaved) => Ok(
- Frames::F32P(non_interleaved_channel_data_into_slices(element, buf)?),
+ Frames::F32P(non_interleaved_channel_data_into_slices(imp, buf)?),
),
(gst_audio::AUDIO_FORMAT_F64, gst_audio::AudioLayout::NonInterleaved) => Ok(
- Frames::F64P(non_interleaved_channel_data_into_slices(element, buf)?),
+ Frames::F64P(non_interleaved_channel_data_into_slices(imp, buf)?),
),
_ => Err(gst::FlowError::NotNegotiated),
}
@@ -742,36 +724,36 @@ impl<'a> Frames<'a> {
/// Converts an interleaved audio buffer into a typed slice.
fn interleaved_channel_data_into_slice<'a, T: FromByteSlice>(
- element: &super::EbuR128Level,
+ imp: &EbuR128Level,
buf: &'a gst_audio::AudioBufferRef<&gst::BufferRef>,
) -> Result<&'a [T], gst::FlowError> {
buf.plane_data(0)
.map_err(|err| {
- gst::error!(CAT, obj: element, "Failed to get audio data: {}", err);
+ gst::error!(CAT, imp: imp, "Failed to get audio data: {}", err);
gst::FlowError::Error
})?
.as_slice_of::<T>()
.map_err(|err| {
- gst::error!(CAT, obj: element, "Failed to handle audio data: {}", err);
+ gst::error!(CAT, imp: imp, "Failed to handle audio data: {}", err);
gst::FlowError::Error
})
}
/// Converts a non-interleaved audio buffer into a vector of typed slices.
fn non_interleaved_channel_data_into_slices<'a, T: FromByteSlice>(
- element: &super::EbuR128Level,
+ imp: &EbuR128Level,
buf: &'a gst_audio::AudioBufferRef<&gst::BufferRef>,
) -> Result<SmallVec<[&'a [T]; 64]>, gst::FlowError> {
(0..buf.channels())
.map(|c| {
buf.plane_data(c)
.map_err(|err| {
- gst::error!(CAT, obj: element, "Failed to get audio data: {}", err);
+ gst::error!(CAT, imp: imp, "Failed to get audio data: {}", err);
gst::FlowError::Error
})?
.as_slice_of::<T>()
.map_err(|err| {
- gst::error!(CAT, obj: element, "Failed to handle audio data: {}", err);
+ gst::error!(CAT, imp: imp, "Failed to handle audio data: {}", err);
gst::FlowError::Error
})
})
diff --git a/audio/audiofx/src/hrtfrender/imp.rs b/audio/audiofx/src/hrtfrender/imp.rs
index 76b22748..f7947217 100644
--- a/audio/audiofx/src/hrtfrender/imp.rs
+++ b/audio/audiofx/src/hrtfrender/imp.rs
@@ -10,6 +10,7 @@ use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
+use gst_base::prelude::*;
use gst_base::subclass::prelude::*;
use hrtf::{HrirSphere, HrtfContext, HrtfProcessor, Vec3};
@@ -216,7 +217,6 @@ impl ObjectSubclass for HrtfRender {
impl HrtfRender {
fn process(
&self,
- element: &super::HrtfRender,
outbuf: &mut gst::BufferRef,
state: &mut State,
settings: &Settings,
@@ -224,7 +224,7 @@ impl HrtfRender {
let mut outbuf =
gst_audio::AudioBufferRef::from_buffer_ref_writable(outbuf, &state.outinfo).map_err(
|err| {
- gst::error!(CAT, obj: element, "Failed to map buffer : {}", err);
+ gst::error!(CAT, imp: self, "Failed to map buffer : {}", err);
gst::FlowError::Error
},
)?;
@@ -248,13 +248,13 @@ impl HrtfRender {
while state.adapter.available() >= inblksz {
let inbuf = state.adapter.take_buffer(inblksz).map_err(|_| {
- gst::error!(CAT, obj: element, "Failed to map buffer");
+ gst::error!(CAT, imp: self, "Failed to map buffer");
gst::FlowError::Error
})?;
let inbuf = gst_audio::AudioBuffer::from_buffer_readable(inbuf, &state.ininfo)
.map_err(|_| {
- gst::error!(CAT, obj: element, "Failed to map buffer");
+ gst::error!(CAT, imp: self, "Failed to map buffer");
gst::FlowError::Error
})?;
@@ -326,7 +326,7 @@ impl HrtfRender {
Ok(gst::FlowSuccess::Ok)
}
- fn drain(&self, element: &super::HrtfRender) -> Result<gst::FlowSuccess, gst::FlowError> {
+ fn drain(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let settings = &self.settings.lock().unwrap();
let mut state_guard = self.state.lock().unwrap();
@@ -384,19 +384,17 @@ impl HrtfRender {
let mut outbuf = gst::Buffer::with_size(outblksz).map_err(|_| gst::FlowError::Error)?;
let outbuf_mut = outbuf.get_mut().unwrap();
- self.process(element, outbuf_mut, state, settings)?;
+ self.process(outbuf_mut, state, settings)?;
outbuf_mut.set_size(outputsz);
outbuf_mut.set_pts(pts);
outbuf_mut.set_offset(offset);
outbuf_mut.set_duration(duration);
- let srcpad = element.static_pad("src").unwrap();
-
state.reset_processors();
drop(state_guard);
- srcpad.push(outbuf)
+ self.instance().src_pad().push(outbuf)
}
}
@@ -445,13 +443,7 @@ impl ObjectImpl for HrtfRender {
PROPERTIES.as_ref()
}
- fn set_property(
- &self,
- _obj: &Self::Type,
- _id: usize,
- value: &glib::Value,
- pspec: &glib::ParamSpec,
- ) {
+ fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
match pspec.name() {
"hrir-raw" => {
let mut settings = self.settings.lock().unwrap();
@@ -502,7 +494,7 @@ impl ObjectImpl for HrtfRender {
}
}
- fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
+ fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"hrir-raw" => {
let settings = self.settings.lock().unwrap();
@@ -600,7 +592,6 @@ impl BaseTransformImpl for HrtfRender {
fn transform(
&self,
- element: &Self::Type,
inbuf: &gst::Buffer,
outbuf: &mut gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError> {
@@ -612,7 +603,7 @@ impl BaseTransformImpl for HrtfRender {
state.adapter.push(inbuf.clone());
if state.adapter.available() >= state.input_block_size() {
- return self.process(element, outbuf, state, settings);
+ return self.process(outbuf, state, settings);
}
Ok(gst::FlowSuccess::Ok)
@@ -620,7 +611,6 @@ impl BaseTransformImpl for HrtfRender {
fn transform_size(
&self,
- element: &Self::Type,
_direction: gst::PadDirection,
_caps: &gst::Caps,
size: usize,
@@ -638,7 +628,7 @@ impl BaseTransformImpl for HrtfRender {
gst::log!(
CAT,
- obj: element,
+ imp: self,
"Adapter size: {}, input size {}, transformed size {}",
state.adapter.available(),
size,
@@ -650,7 +640,6 @@ impl BaseTransformImpl for HrtfRender {
fn transform_caps(
&self,
- element: &Self::Type,
direction: gst::PadDirection,
caps: &gst::Caps,
filter: Option<&gst::Caps>,
@@ -685,7 +674,7 @@ impl BaseTransformImpl for HrtfRender {
gst::debug!(
CAT,
- obj: element,
+ imp: self,
"Transformed caps from {} to {} in direction {:?}",
caps,
other_caps,
@@ -695,12 +684,7 @@ impl BaseTransformImpl for HrtfRender {
Some(other_caps)
}
- fn set_caps(
- &self,
- element: &Self::Type,
- incaps: &gst::Caps,
- outcaps: &gst::Caps,
- ) -> Result<(), gst::LoggableError> {
+ fn set_caps(&self, incaps: &gst::Caps, outcaps: &gst::Caps) -> Result<(), gst::LoggableError> {
let ininfo = gst_audio::AudioInfo::from_caps(incaps)
.map_err(|_| gst::loggable_error!(CAT, "Failed to parse input caps"))?;
@@ -761,15 +745,15 @@ impl BaseTransformImpl for HrtfRender {
adapter: gst_base::UniqueAdapter::new(),
});
- gst::debug!(CAT, obj: element, "Configured for caps {}", incaps);
+ gst::debug!(CAT, imp: self, "Configured for caps {}", incaps);
Ok(())
}
- fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
+ fn sink_event(&self, event: gst::Event) -> bool {
use gst::EventView;
- gst::debug!(CAT, "Handling event {:?}", event);
+ gst::debug!(CAT, imp: self, "Handling event {:?}", event);
match event.view() {
EventView::FlushStop(_) => {
@@ -782,10 +766,10 @@ impl BaseTransformImpl for HrtfRender {
}
}
EventView::Eos(_) => {
- if self.drain(element).is_err() {
+ if self.drain().is_err() {
gst::warning!(CAT, "Failed to drain internal buffer");
- gst::element_warning!(
- element,
+ gst::element_imp_warning!(
+ self,
gst::CoreError::Event,
["Failed to drain internal buffer"]
);
@@ -794,10 +778,10 @@ impl BaseTransformImpl for HrtfRender {
_ => {}
}
- self.parent_sink_event(element, event)
+ self.parent_sink_event(event)
}
- fn start(&self, _element: &Self::Type) -> Result<(), gst::ErrorMessage> {
+ fn start(&self) -> Result<(), gst::ErrorMessage> {
// get global thread pool
let mut thread_pool_g = THREAD_POOL.lock().unwrap();
let mut thread_pool = self.thread_pool.lock().unwrap();
@@ -821,7 +805,7 @@ impl BaseTransformImpl for HrtfRender {
Ok(())
}
- fn stop(&self, _element: &Self::Type) -> Result<(), gst::ErrorMessage> {
+ fn stop(&self) -> Result<(), gst::ErrorMessage> {
// Drop state
let _ = self.state.lock().unwrap().take();
// Drop thread pool