{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) This object is used to convert audio samples from one format to another. The object can perform conversion of: * audio format with optional dithering and noise shaping * audio samplerate * audio channels and channel layout -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GstAudio.Structs.AudioConverter ( -- * Exported types AudioConverter(..) , noAudioConverter , -- * Methods -- ** convert #method:convert# #if ENABLE_OVERLOADING AudioConverterConvertMethodInfo , #endif audioConverterConvert , -- ** free #method:free# #if ENABLE_OVERLOADING AudioConverterFreeMethodInfo , #endif audioConverterFree , -- ** getConfig #method:getConfig# #if ENABLE_OVERLOADING AudioConverterGetConfigMethodInfo , #endif audioConverterGetConfig , -- ** getInFrames #method:getInFrames# #if ENABLE_OVERLOADING AudioConverterGetInFramesMethodInfo , #endif audioConverterGetInFrames , -- ** getMaxLatency #method:getMaxLatency# #if ENABLE_OVERLOADING AudioConverterGetMaxLatencyMethodInfo , #endif audioConverterGetMaxLatency , -- ** getOutFrames #method:getOutFrames# #if ENABLE_OVERLOADING AudioConverterGetOutFramesMethodInfo , #endif audioConverterGetOutFrames , -- ** isPassthrough #method:isPassthrough# #if ENABLE_OVERLOADING AudioConverterIsPassthroughMethodInfo , #endif audioConverterIsPassthrough , -- ** new #method:new# audioConverterNew , -- ** reset #method:reset# #if ENABLE_OVERLOADING AudioConverterResetMethodInfo , #endif audioConverterReset , -- ** samples #method:samples# #if ENABLE_OVERLOADING AudioConverterSamplesMethodInfo , #endif audioConverterSamples , -- ** supportsInplace #method:supportsInplace# #if ENABLE_OVERLOADING AudioConverterSupportsInplaceMethodInfo , #endif audioConverterSupportsInplace , -- ** updateConfig #method:updateConfig# #if ENABLE_OVERLOADING AudioConverterUpdateConfigMethodInfo , #endif audioConverterUpdateConfig , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.Gst.Structs.Structure as Gst.Structure import {-# SOURCE #-} qualified GI.GstAudio.Flags as GstAudio.Flags import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioInfo as GstAudio.AudioInfo -- | Memory-managed wrapper type. newtype AudioConverter = AudioConverter (ManagedPtr AudioConverter) foreign import ccall "gst_audio_converter_get_type" c_gst_audio_converter_get_type :: IO GType instance BoxedObject AudioConverter where boxedType _ = c_gst_audio_converter_get_type -- | A convenience alias for `Nothing` :: `Maybe` `AudioConverter`. noAudioConverter :: Maybe AudioConverter noAudioConverter = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList AudioConverter type instance O.AttributeList AudioConverter = AudioConverterAttributeList type AudioConverterAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method AudioConverter::new -- method type : Constructor -- Args : [Arg {argCName = "flags", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverterFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "extra #GstAudioConverterFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a source #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a destination #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "config", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GstStructure with configuration options", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioConverter"})) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_new" gst_audio_converter_new :: CUInt -> -- flags : TInterface (Name {namespace = "GstAudio", name = "AudioConverterFlags"}) Ptr GstAudio.AudioInfo.AudioInfo -> -- in_info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}) Ptr GstAudio.AudioInfo.AudioInfo -> -- out_info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}) Ptr Gst.Structure.Structure -> -- config : TInterface (Name {namespace = "Gst", name = "Structure"}) IO (Ptr AudioConverter) {- | Create a new 'GI.GstAudio.Structs.AudioConverter.AudioConverter' that is able to convert between /@in@/ and /@out@/ audio formats. /@config@/ contains extra configuration options, see @/GST_AUDIO_CONVERTER_OPT_/@* parameters for details about the options and values. -} audioConverterNew :: (B.CallStack.HasCallStack, MonadIO m) => [GstAudio.Flags.AudioConverterFlags] {- ^ /@flags@/: extra 'GI.GstAudio.Flags.AudioConverterFlags' -} -> GstAudio.AudioInfo.AudioInfo {- ^ /@inInfo@/: a source 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -} -> GstAudio.AudioInfo.AudioInfo {- ^ /@outInfo@/: a destination 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -} -> Maybe (Gst.Structure.Structure) {- ^ /@config@/: a 'GI.Gst.Structs.Structure.Structure' with configuration options -} -> m AudioConverter {- ^ __Returns:__ a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' or 'Nothing' if conversion is not possible. -} audioConverterNew flags inInfo outInfo config = liftIO $ do let flags' = gflagsToWord flags inInfo' <- unsafeManagedPtrGetPtr inInfo outInfo' <- unsafeManagedPtrGetPtr outInfo maybeConfig <- case config of Nothing -> return nullPtr Just jConfig -> do jConfig' <- B.ManagedPtr.disownBoxed jConfig return jConfig' result <- gst_audio_converter_new flags' inInfo' outInfo' maybeConfig checkUnexpectedReturnNULL "audioConverterNew" result result' <- (wrapBoxed AudioConverter) result touchManagedPtr inInfo touchManagedPtr outInfo whenJust config touchManagedPtr return result' #if ENABLE_OVERLOADING #endif -- method AudioConverter::convert -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverterFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "extra #GstAudioConverterFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out", argType = TCArray False (-1) 5 (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer where\n the output data will be written", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_size", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer where the size of @out will be written", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "out_size", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer where the size of @out will be written", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "in_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_convert" gst_audio_converter_convert :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) CUInt -> -- flags : TInterface (Name {namespace = "GstAudio", name = "AudioConverterFlags"}) Ptr Word8 -> -- in : TCArray False (-1) 3 (TBasicType TUInt8) Word64 -> -- in_size : TBasicType TUInt64 Ptr (Ptr Word8) -> -- out : TCArray False (-1) 5 (TBasicType TUInt8) Ptr Word64 -> -- out_size : TBasicType TUInt64 IO CInt {- | Convenience wrapper around 'GI.GstAudio.Structs.AudioConverter.audioConverterSamples', which will perform allocation of the output buffer based on the result from 'GI.GstAudio.Structs.AudioConverter.audioConverterGetOutFrames'. /Since: 1.14/ -} audioConverterConvert :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> [GstAudio.Flags.AudioConverterFlags] {- ^ /@flags@/: extra 'GI.GstAudio.Flags.AudioConverterFlags' -} -> ByteString {- ^ /@in@/: input data -} -> m ((Bool, ByteString)) {- ^ __Returns:__ 'True' is the conversion could be performed. -} audioConverterConvert convert flags in_ = liftIO $ do let inSize = fromIntegral $ B.length in_ convert' <- unsafeManagedPtrGetPtr convert let flags' = gflagsToWord flags in_' <- packByteString in_ out <- allocMem :: IO (Ptr (Ptr Word8)) outSize <- allocMem :: IO (Ptr Word64) result <- gst_audio_converter_convert convert' flags' in_' inSize out outSize outSize' <- peek outSize let result' = (/= 0) result out' <- peek out out'' <- (unpackByteStringWithLength outSize') out' freeMem out' touchManagedPtr convert freeMem in_' freeMem out freeMem outSize return (result', out'') #if ENABLE_OVERLOADING data AudioConverterConvertMethodInfo instance (signature ~ ([GstAudio.Flags.AudioConverterFlags] -> ByteString -> m ((Bool, ByteString))), MonadIO m) => O.MethodInfo AudioConverterConvertMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterConvert #endif -- method AudioConverter::free -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_free" gst_audio_converter_free :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) IO () {- | Free a previously allocated /@convert@/ instance. -} audioConverterFree :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> m () audioConverterFree convert = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert gst_audio_converter_free convert' touchManagedPtr convert return () #if ENABLE_OVERLOADING data AudioConverterFreeMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AudioConverterFreeMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterFree #endif -- method AudioConverter::get_config -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_rate", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "result input rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_rate", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "result output rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Gst", name = "Structure"})) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_get_config" gst_audio_converter_get_config :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) Ptr Int32 -> -- in_rate : TBasicType TInt Ptr Int32 -> -- out_rate : TBasicType TInt IO (Ptr Gst.Structure.Structure) {- | Get the current configuration of /@convert@/. -} audioConverterGetConfig :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> m ((Gst.Structure.Structure, Int32, Int32)) {- ^ __Returns:__ a 'GI.Gst.Structs.Structure.Structure' that remains valid for as long as /@convert@/ is valid or until 'GI.GstAudio.Structs.AudioConverter.audioConverterUpdateConfig' is called. -} audioConverterGetConfig convert = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert inRate <- allocMem :: IO (Ptr Int32) outRate <- allocMem :: IO (Ptr Int32) result <- gst_audio_converter_get_config convert' inRate outRate checkUnexpectedReturnNULL "audioConverterGetConfig" result result' <- (newBoxed Gst.Structure.Structure) result inRate' <- peek inRate outRate' <- peek outRate touchManagedPtr convert freeMem inRate freeMem outRate return (result', inRate', outRate') #if ENABLE_OVERLOADING data AudioConverterGetConfigMethodInfo instance (signature ~ (m ((Gst.Structure.Structure, Int32, Int32))), MonadIO m) => O.MethodInfo AudioConverterGetConfigMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterGetConfig #endif -- method AudioConverter::get_in_frames -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_frames", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of output frames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_get_in_frames" gst_audio_converter_get_in_frames :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) Word64 -> -- out_frames : TBasicType TUInt64 IO Word64 {- | Calculate how many input frames are currently needed by /@convert@/ to produce /@outFrames@/ of output frames. -} audioConverterGetInFrames :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> Word64 {- ^ /@outFrames@/: number of output frames -} -> m Word64 {- ^ __Returns:__ the number of input frames -} audioConverterGetInFrames convert outFrames = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert result <- gst_audio_converter_get_in_frames convert' outFrames touchManagedPtr convert return result #if ENABLE_OVERLOADING data AudioConverterGetInFramesMethodInfo instance (signature ~ (Word64 -> m Word64), MonadIO m) => O.MethodInfo AudioConverterGetInFramesMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterGetInFrames #endif -- method AudioConverter::get_max_latency -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_get_max_latency" gst_audio_converter_get_max_latency :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) IO Word64 {- | Get the maximum number of input frames that the converter would need before producing output. -} audioConverterGetMaxLatency :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> m Word64 {- ^ __Returns:__ the latency of /@convert@/ as expressed in the number of frames. -} audioConverterGetMaxLatency convert = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert result <- gst_audio_converter_get_max_latency convert' touchManagedPtr convert return result #if ENABLE_OVERLOADING data AudioConverterGetMaxLatencyMethodInfo instance (signature ~ (m Word64), MonadIO m) => O.MethodInfo AudioConverterGetMaxLatencyMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterGetMaxLatency #endif -- method AudioConverter::get_out_frames -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_frames", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of input frames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_get_out_frames" gst_audio_converter_get_out_frames :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) Word64 -> -- in_frames : TBasicType TUInt64 IO Word64 {- | Calculate how many output frames can be produced when /@inFrames@/ input frames are given to /@convert@/. -} audioConverterGetOutFrames :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> Word64 {- ^ /@inFrames@/: number of input frames -} -> m Word64 {- ^ __Returns:__ the number of output frames -} audioConverterGetOutFrames convert inFrames = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert result <- gst_audio_converter_get_out_frames convert' inFrames touchManagedPtr convert return result #if ENABLE_OVERLOADING data AudioConverterGetOutFramesMethodInfo instance (signature ~ (Word64 -> m Word64), MonadIO m) => O.MethodInfo AudioConverterGetOutFramesMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterGetOutFrames #endif -- method AudioConverter::is_passthrough -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_is_passthrough" gst_audio_converter_is_passthrough :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) IO CInt {- | Returns whether the audio converter will operate in passthrough mode. The return value would be typically input to 'GI.GstBase.Objects.BaseTransform.baseTransformSetPassthrough' /Since: 1.16/ -} audioConverterIsPassthrough :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter -> m Bool {- ^ __Returns:__ 'True' when no conversion will actually occur. -} audioConverterIsPassthrough convert = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert result <- gst_audio_converter_is_passthrough convert' let result' = (/= 0) result touchManagedPtr convert return result' #if ENABLE_OVERLOADING data AudioConverterIsPassthroughMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo AudioConverterIsPassthroughMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterIsPassthrough #endif -- method AudioConverter::reset -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_reset" gst_audio_converter_reset :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) IO () {- | Reset /@convert@/ to the state it was when it was first created, clearing any history it might currently have. -} audioConverterReset :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> m () audioConverterReset convert = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert gst_audio_converter_reset convert' touchManagedPtr convert return () #if ENABLE_OVERLOADING data AudioConverterResetMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AudioConverterResetMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterReset #endif -- method AudioConverter::samples -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverterFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "extra #GstAudioConverterFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "input frames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_frames", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of input frames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "output frames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_frames", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of output frames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_samples" gst_audio_converter_samples :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) CUInt -> -- flags : TInterface (Name {namespace = "GstAudio", name = "AudioConverterFlags"}) Ptr () -> -- in : TBasicType TPtr Word64 -> -- in_frames : TBasicType TUInt64 Ptr () -> -- out : TBasicType TPtr Word64 -> -- out_frames : TBasicType TUInt64 IO CInt {- | Perform the conversion with /@inFrames@/ in /@in@/ to /@outFrames@/ in /@out@/ using /@convert@/. In case the samples are interleaved, /@in@/ and /@out@/ must point to an array with a single element pointing to a block of interleaved samples. If non-interleaved samples are used, /@in@/ and /@out@/ must point to an array with pointers to memory blocks, one for each channel. /@in@/ may be 'Nothing', in which case /@inFrames@/ of silence samples are processed by the converter. This function always produces /@outFrames@/ of output and consumes /@inFrames@/ of input. Use 'GI.GstAudio.Structs.AudioConverter.audioConverterGetOutFrames' and 'GI.GstAudio.Structs.AudioConverter.audioConverterGetInFrames' to make sure /@inFrames@/ and /@outFrames@/ are matching and /@in@/ and /@out@/ point to enough memory. -} audioConverterSamples :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> [GstAudio.Flags.AudioConverterFlags] {- ^ /@flags@/: extra 'GI.GstAudio.Flags.AudioConverterFlags' -} -> Ptr () {- ^ /@in@/: input frames -} -> Word64 {- ^ /@inFrames@/: number of input frames -} -> Ptr () {- ^ /@out@/: output frames -} -> Word64 {- ^ /@outFrames@/: number of output frames -} -> m Bool {- ^ __Returns:__ 'True' is the conversion could be performed. -} audioConverterSamples convert flags in_ inFrames out outFrames = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert let flags' = gflagsToWord flags result <- gst_audio_converter_samples convert' flags' in_ inFrames out outFrames let result' = (/= 0) result touchManagedPtr convert return result' #if ENABLE_OVERLOADING data AudioConverterSamplesMethodInfo instance (signature ~ ([GstAudio.Flags.AudioConverterFlags] -> Ptr () -> Word64 -> Ptr () -> Word64 -> m Bool), MonadIO m) => O.MethodInfo AudioConverterSamplesMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterSamples #endif -- method AudioConverter::supports_inplace -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_supports_inplace" gst_audio_converter_supports_inplace :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) IO CInt {- | Returns whether the audio converter can perform the conversion in-place. The return value would be typically input to 'GI.GstBase.Objects.BaseTransform.baseTransformSetInPlace' -} audioConverterSupportsInplace :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> m Bool {- ^ __Returns:__ 'True' when the conversion can be done in place. -} audioConverterSupportsInplace convert = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert result <- gst_audio_converter_supports_inplace convert' let result' = (/= 0) result touchManagedPtr convert return result' #if ENABLE_OVERLOADING data AudioConverterSupportsInplaceMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo AudioConverterSupportsInplaceMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterSupportsInplace #endif -- method AudioConverter::update_config -- method type : OrdinaryMethod -- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_rate", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_rate", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "output rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "config", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GstStructure or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_audio_converter_update_config" gst_audio_converter_update_config :: Ptr AudioConverter -> -- convert : TInterface (Name {namespace = "GstAudio", name = "AudioConverter"}) Int32 -> -- in_rate : TBasicType TInt Int32 -> -- out_rate : TBasicType TInt Ptr Gst.Structure.Structure -> -- config : TInterface (Name {namespace = "Gst", name = "Structure"}) IO CInt {- | Set /@inRate@/, /@outRate@/ and /@config@/ as extra configuration for /@convert@/. /@inRate@/ and /@outRate@/ specify the new sample rates of input and output formats. A value of 0 leaves the sample rate unchanged. /@config@/ can be 'Nothing', in which case, the current configuration is not changed. If the parameters in /@config@/ can not be set exactly, this function returns 'False' and will try to update as much state as possible. The new state can then be retrieved and refined with 'GI.GstAudio.Structs.AudioConverter.audioConverterGetConfig'. Look at the @/GST_AUDIO_CONVERTER_OPT_/@* fields to check valid configuration option and values. -} audioConverterUpdateConfig :: (B.CallStack.HasCallStack, MonadIO m) => AudioConverter {- ^ /@convert@/: a 'GI.GstAudio.Structs.AudioConverter.AudioConverter' -} -> Int32 {- ^ /@inRate@/: input rate -} -> Int32 {- ^ /@outRate@/: output rate -} -> Maybe (Gst.Structure.Structure) {- ^ /@config@/: a 'GI.Gst.Structs.Structure.Structure' or 'Nothing' -} -> m Bool {- ^ __Returns:__ 'True' when the new parameters could be set -} audioConverterUpdateConfig convert inRate outRate config = liftIO $ do convert' <- unsafeManagedPtrGetPtr convert maybeConfig <- case config of Nothing -> return nullPtr Just jConfig -> do jConfig' <- B.ManagedPtr.disownBoxed jConfig return jConfig' result <- gst_audio_converter_update_config convert' inRate outRate maybeConfig let result' = (/= 0) result touchManagedPtr convert whenJust config touchManagedPtr return result' #if ENABLE_OVERLOADING data AudioConverterUpdateConfigMethodInfo instance (signature ~ (Int32 -> Int32 -> Maybe (Gst.Structure.Structure) -> m Bool), MonadIO m) => O.MethodInfo AudioConverterUpdateConfigMethodInfo AudioConverter signature where overloadedMethod _ = audioConverterUpdateConfig #endif #if ENABLE_OVERLOADING type family ResolveAudioConverterMethod (t :: Symbol) (o :: *) :: * where ResolveAudioConverterMethod "convert" o = AudioConverterConvertMethodInfo ResolveAudioConverterMethod "free" o = AudioConverterFreeMethodInfo ResolveAudioConverterMethod "isPassthrough" o = AudioConverterIsPassthroughMethodInfo ResolveAudioConverterMethod "reset" o = AudioConverterResetMethodInfo ResolveAudioConverterMethod "samples" o = AudioConverterSamplesMethodInfo ResolveAudioConverterMethod "supportsInplace" o = AudioConverterSupportsInplaceMethodInfo ResolveAudioConverterMethod "updateConfig" o = AudioConverterUpdateConfigMethodInfo ResolveAudioConverterMethod "getConfig" o = AudioConverterGetConfigMethodInfo ResolveAudioConverterMethod "getInFrames" o = AudioConverterGetInFramesMethodInfo ResolveAudioConverterMethod "getMaxLatency" o = AudioConverterGetMaxLatencyMethodInfo ResolveAudioConverterMethod "getOutFrames" o = AudioConverterGetOutFramesMethodInfo ResolveAudioConverterMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveAudioConverterMethod t AudioConverter, O.MethodInfo info AudioConverter p) => OL.IsLabel t (AudioConverter -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif