diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2020-11-14 19:52:56 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2020-11-15 19:25:42 +0300 |
commit | f54f9f977ec2143028c6068ac43bff5da4bea2ee (patch) | |
tree | 86a035ad3a6a2457f5a1ee1c73288adf28136102 /audio/csound/src | |
parent | f43436056eeb612c573fc722e1f3e8c1d1f74666 (diff) |
audio: Update for subclassing API changes
Diffstat (limited to 'audio/csound/src')
-rw-r--r-- | audio/csound/src/filter/imp.rs (renamed from audio/csound/src/filter.rs) | 37 | ||||
-rw-r--r-- | audio/csound/src/filter/mod.rs | 37 |
2 files changed, 50 insertions, 24 deletions
diff --git a/audio/csound/src/filter.rs b/audio/csound/src/filter/imp.rs index e25d199d4..fa85d786d 100644 --- a/audio/csound/src/filter.rs +++ b/audio/csound/src/filter/imp.rs @@ -75,7 +75,7 @@ struct State { ksmps: u32, } -struct CsoundFilter { +pub struct CsoundFilter { settings: Mutex<Settings>, state: Mutex<Option<State>>, csound: Mutex<Csound>, @@ -222,7 +222,7 @@ impl CsoundFilter { } } - fn drain(&self, element: &gst_base::BaseTransform) -> Result<gst::FlowSuccess, gst::FlowError> { + fn drain(&self, element: &super::CsoundFilter) -> Result<gst::FlowSuccess, gst::FlowError> { let csound = self.csound.lock().unwrap(); let mut state_lock = self.state.lock().unwrap(); let state = state_lock.as_mut().unwrap(); @@ -293,7 +293,7 @@ impl CsoundFilter { fn generate_output( &self, - element: &gst_base::BaseTransform, + element: &super::CsoundFilter, state: &mut State, ) -> Result<GenerateOutputSuccess, gst::FlowError> { let output_size = state.max_output_size(state.adapter.available()); @@ -361,6 +361,7 @@ impl CsoundFilter { impl ObjectSubclass for CsoundFilter { const NAME: &'static str = "CsoundFilter"; + type Type = super::CsoundFilter; type ParentType = gst_base::BaseTransform; type Instance = gst::subclass::ElementInstanceStruct<Self>; type Class = subclass::simple::ClassStruct<Self>; @@ -385,7 +386,7 @@ impl ObjectSubclass for CsoundFilter { } } - fn class_init(klass: &mut subclass::simple::ClassStruct<Self>) { + fn class_init(klass: &mut Self::Class) { klass.set_metadata( "Audio filter", "Filter/Effect/Audio", @@ -431,7 +432,7 @@ impl ObjectSubclass for CsoundFilter { } impl ObjectImpl for CsoundFilter { - fn set_property(&self, _obj: &glib::Object, id: usize, value: &glib::Value) { + fn set_property(&self, _obj: &Self::Type, id: usize, value: &glib::Value) { let prop = &PROPERTIES[id]; match *prop { subclass::Property("loop", ..) => { @@ -464,7 +465,7 @@ impl ObjectImpl for CsoundFilter { } } - fn get_property(&self, _obj: &glib::Object, id: usize) -> Result<glib::Value, ()> { + fn get_property(&self, _obj: &Self::Type, id: usize) -> Result<glib::Value, ()> { let prop = &PROPERTIES[id]; match *prop { @@ -492,10 +493,7 @@ impl ObjectImpl for CsoundFilter { impl ElementImpl for CsoundFilter {} impl BaseTransformImpl for CsoundFilter { - fn start( - &self, - _element: &gst_base::BaseTransform, - ) -> std::result::Result<(), gst::ErrorMessage> { + fn start(&self, _element: &Self::Type) -> std::result::Result<(), gst::ErrorMessage> { self.compile_score()?; let csound = self.csound.lock().unwrap(); @@ -509,7 +507,7 @@ impl BaseTransformImpl for CsoundFilter { Ok(()) } - fn stop(&self, element: &gst_base::BaseTransform) -> Result<(), gst::ErrorMessage> { + fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> { let csound = self.csound.lock().unwrap(); csound.stop(); csound.reset(); @@ -520,7 +518,7 @@ impl BaseTransformImpl for CsoundFilter { Ok(()) } - fn sink_event(&self, element: &gst_base::BaseTransform, event: gst::Event) -> bool { + fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool { use gst::EventView; if let EventView::Eos(_) = event.view() { @@ -534,7 +532,7 @@ impl BaseTransformImpl for CsoundFilter { fn transform_caps( &self, - element: &gst_base::BaseTransform, + element: &Self::Type, direction: gst::PadDirection, caps: &gst::Caps, filter: Option<&gst::Caps>, @@ -586,7 +584,7 @@ impl BaseTransformImpl for CsoundFilter { fn set_caps( &self, - element: &gst_base::BaseTransform, + element: &Self::Type, incaps: &gst::Caps, outcaps: &gst::Caps, ) -> Result<(), gst::LoggableError> { @@ -646,7 +644,7 @@ impl BaseTransformImpl for CsoundFilter { fn generate_output( &self, - element: &gst_base::BaseTransform, + element: &Self::Type, ) -> 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 @@ -675,12 +673,3 @@ impl BaseTransformImpl for CsoundFilter { Ok(GenerateOutputSuccess::NoOutput) } } - -pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { - gst::Element::register( - Some(plugin), - "csoundfilter", - gst::Rank::None, - CsoundFilter::get_type(), - ) -} diff --git a/audio/csound/src/filter/mod.rs b/audio/csound/src/filter/mod.rs new file mode 100644 index 000000000..89ef3b4c9 --- /dev/null +++ b/audio/csound/src/filter/mod.rs @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Natanael Mojica <neithanmo@gmail.com> +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the +// Free Software Foundation, Inc., 51 Franklin Street, Suite 500, +// Boston, MA 02110-1335, USA. + +use glib::glib_wrapper; +use glib::prelude::*; + +mod imp; + +glib_wrapper! { + pub struct CsoundFilter(ObjectSubclass<imp::CsoundFilter>) @extends gst_base::BaseTransform, gst::Element, gst::Object; +} + +unsafe impl Send for CsoundFilter {} +unsafe impl Sync for CsoundFilter {} + +pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { + gst::Element::register( + Some(plugin), + "csoundfilter", + gst::Rank::None, + CsoundFilter::static_type(), + ) +} |