{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Information describing audio properties. This information can be filled
in from GstCaps with 'GI.GstAudio.Structs.AudioInfo.audioInfoFromCaps'.

Use the provided macros to access the info in this structure.
-}

module GI.GstAudio.Structs.AudioInfo
    ( 

-- * Exported types
    AudioInfo(..)                           ,
    newZeroAudioInfo                        ,
    noAudioInfo                             ,


 -- * Methods
-- ** convert #method:convert#
    AudioInfoConvertMethodInfo              ,
    audioInfoConvert                        ,


-- ** copy #method:copy#
    AudioInfoCopyMethodInfo                 ,
    audioInfoCopy                           ,


-- ** free #method:free#
    AudioInfoFreeMethodInfo                 ,
    audioInfoFree                           ,


-- ** fromCaps #method:fromCaps#
    AudioInfoFromCapsMethodInfo             ,
    audioInfoFromCaps                       ,


-- ** init #method:init#
    AudioInfoInitMethodInfo                 ,
    audioInfoInit                           ,


-- ** isEqual #method:isEqual#
    AudioInfoIsEqualMethodInfo              ,
    audioInfoIsEqual                        ,


-- ** new #method:new#
    audioInfoNew                            ,


-- ** setFormat #method:setFormat#
    AudioInfoSetFormatMethodInfo            ,
    audioInfoSetFormat                      ,


-- ** toCaps #method:toCaps#
    AudioInfoToCapsMethodInfo               ,
    audioInfoToCaps                         ,




 -- * Properties
-- ** bpf #attr:bpf#
    audioInfo_bpf                           ,
    getAudioInfoBpf                         ,
    setAudioInfoBpf                         ,


-- ** channels #attr:channels#
    audioInfo_channels                      ,
    getAudioInfoChannels                    ,
    setAudioInfoChannels                    ,


-- ** finfo #attr:finfo#
    audioInfo_finfo                         ,
    clearAudioInfoFinfo                     ,
    getAudioInfoFinfo                       ,
    setAudioInfoFinfo                       ,


-- ** flags #attr:flags#
    audioInfo_flags                         ,
    getAudioInfoFlags                       ,
    setAudioInfoFlags                       ,


-- ** layout #attr:layout#
    audioInfo_layout                        ,
    getAudioInfoLayout                      ,
    setAudioInfoLayout                      ,


-- ** rate #attr:rate#
    audioInfo_rate                          ,
    getAudioInfoRate                        ,
    setAudioInfoRate                        ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.Gst.Enums as Gst.Enums
import qualified GI.Gst.Structs.Caps as Gst.Caps
import {-# SOURCE #-} qualified GI.GstAudio.Enums as GstAudio.Enums
import {-# SOURCE #-} qualified GI.GstAudio.Flags as GstAudio.Flags
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioFormatInfo as GstAudio.AudioFormatInfo

newtype AudioInfo = AudioInfo (ManagedPtr AudioInfo)
foreign import ccall "gst_audio_info_get_type" c_gst_audio_info_get_type :: 
    IO GType

instance BoxedObject AudioInfo where
    boxedType _ = c_gst_audio_info_get_type

-- | Construct a `AudioInfo` struct initialized to zero.
newZeroAudioInfo :: MonadIO m => m AudioInfo
newZeroAudioInfo = liftIO $ callocBoxedBytes 320 >>= wrapBoxed AudioInfo

instance tag ~ 'AttrSet => Constructible AudioInfo tag where
    new _ attrs = do
        o <- newZeroAudioInfo
        GI.Attributes.set o attrs
        return o


noAudioInfo :: Maybe AudioInfo
noAudioInfo = Nothing

getAudioInfoFinfo :: MonadIO m => AudioInfo -> m (Maybe GstAudio.AudioFormatInfo.AudioFormatInfo)
getAudioInfoFinfo s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr GstAudio.AudioFormatInfo.AudioFormatInfo)
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- (newPtr GstAudio.AudioFormatInfo.AudioFormatInfo) val'
        return val''
    return result

setAudioInfoFinfo :: MonadIO m => AudioInfo -> Ptr GstAudio.AudioFormatInfo.AudioFormatInfo -> m ()
setAudioInfoFinfo s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Ptr GstAudio.AudioFormatInfo.AudioFormatInfo)

clearAudioInfoFinfo :: MonadIO m => AudioInfo -> m ()
clearAudioInfoFinfo s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (FP.nullPtr :: Ptr GstAudio.AudioFormatInfo.AudioFormatInfo)

data AudioInfoFinfoFieldInfo
instance AttrInfo AudioInfoFinfoFieldInfo where
    type AttrAllowedOps AudioInfoFinfoFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint AudioInfoFinfoFieldInfo = (~) (Ptr GstAudio.AudioFormatInfo.AudioFormatInfo)
    type AttrBaseTypeConstraint AudioInfoFinfoFieldInfo = (~) AudioInfo
    type AttrGetType AudioInfoFinfoFieldInfo = Maybe GstAudio.AudioFormatInfo.AudioFormatInfo
    type AttrLabel AudioInfoFinfoFieldInfo = "finfo"
    type AttrOrigin AudioInfoFinfoFieldInfo = AudioInfo
    attrGet _ = getAudioInfoFinfo
    attrSet _ = setAudioInfoFinfo
    attrConstruct = undefined
    attrClear _ = clearAudioInfoFinfo

audioInfo_finfo :: AttrLabelProxy "finfo"
audioInfo_finfo = AttrLabelProxy


getAudioInfoFlags :: MonadIO m => AudioInfo -> m [GstAudio.Flags.AudioFlags]
getAudioInfoFlags s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CUInt
    let val' = wordToGFlags val
    return val'

setAudioInfoFlags :: MonadIO m => AudioInfo -> [GstAudio.Flags.AudioFlags] -> m ()
setAudioInfoFlags s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = gflagsToWord val
    poke (ptr `plusPtr` 8) (val' :: CUInt)

data AudioInfoFlagsFieldInfo
instance AttrInfo AudioInfoFlagsFieldInfo where
    type AttrAllowedOps AudioInfoFlagsFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AudioInfoFlagsFieldInfo = (~) [GstAudio.Flags.AudioFlags]
    type AttrBaseTypeConstraint AudioInfoFlagsFieldInfo = (~) AudioInfo
    type AttrGetType AudioInfoFlagsFieldInfo = [GstAudio.Flags.AudioFlags]
    type AttrLabel AudioInfoFlagsFieldInfo = "flags"
    type AttrOrigin AudioInfoFlagsFieldInfo = AudioInfo
    attrGet _ = getAudioInfoFlags
    attrSet _ = setAudioInfoFlags
    attrConstruct = undefined
    attrClear _ = undefined

audioInfo_flags :: AttrLabelProxy "flags"
audioInfo_flags = AttrLabelProxy


getAudioInfoLayout :: MonadIO m => AudioInfo -> m GstAudio.Enums.AudioLayout
getAudioInfoLayout s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

setAudioInfoLayout :: MonadIO m => AudioInfo -> GstAudio.Enums.AudioLayout -> m ()
setAudioInfoLayout s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = (fromIntegral . fromEnum) val
    poke (ptr `plusPtr` 12) (val' :: CUInt)

data AudioInfoLayoutFieldInfo
instance AttrInfo AudioInfoLayoutFieldInfo where
    type AttrAllowedOps AudioInfoLayoutFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AudioInfoLayoutFieldInfo = (~) GstAudio.Enums.AudioLayout
    type AttrBaseTypeConstraint AudioInfoLayoutFieldInfo = (~) AudioInfo
    type AttrGetType AudioInfoLayoutFieldInfo = GstAudio.Enums.AudioLayout
    type AttrLabel AudioInfoLayoutFieldInfo = "layout"
    type AttrOrigin AudioInfoLayoutFieldInfo = AudioInfo
    attrGet _ = getAudioInfoLayout
    attrSet _ = setAudioInfoLayout
    attrConstruct = undefined
    attrClear _ = undefined

audioInfo_layout :: AttrLabelProxy "layout"
audioInfo_layout = AttrLabelProxy


getAudioInfoRate :: MonadIO m => AudioInfo -> m Int32
getAudioInfoRate s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Int32
    return val

setAudioInfoRate :: MonadIO m => AudioInfo -> Int32 -> m ()
setAudioInfoRate s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Int32)

data AudioInfoRateFieldInfo
instance AttrInfo AudioInfoRateFieldInfo where
    type AttrAllowedOps AudioInfoRateFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AudioInfoRateFieldInfo = (~) Int32
    type AttrBaseTypeConstraint AudioInfoRateFieldInfo = (~) AudioInfo
    type AttrGetType AudioInfoRateFieldInfo = Int32
    type AttrLabel AudioInfoRateFieldInfo = "rate"
    type AttrOrigin AudioInfoRateFieldInfo = AudioInfo
    attrGet _ = getAudioInfoRate
    attrSet _ = setAudioInfoRate
    attrConstruct = undefined
    attrClear _ = undefined

audioInfo_rate :: AttrLabelProxy "rate"
audioInfo_rate = AttrLabelProxy


getAudioInfoChannels :: MonadIO m => AudioInfo -> m Int32
getAudioInfoChannels s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 20) :: IO Int32
    return val

setAudioInfoChannels :: MonadIO m => AudioInfo -> Int32 -> m ()
setAudioInfoChannels s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 20) (val :: Int32)

data AudioInfoChannelsFieldInfo
instance AttrInfo AudioInfoChannelsFieldInfo where
    type AttrAllowedOps AudioInfoChannelsFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AudioInfoChannelsFieldInfo = (~) Int32
    type AttrBaseTypeConstraint AudioInfoChannelsFieldInfo = (~) AudioInfo
    type AttrGetType AudioInfoChannelsFieldInfo = Int32
    type AttrLabel AudioInfoChannelsFieldInfo = "channels"
    type AttrOrigin AudioInfoChannelsFieldInfo = AudioInfo
    attrGet _ = getAudioInfoChannels
    attrSet _ = setAudioInfoChannels
    attrConstruct = undefined
    attrClear _ = undefined

audioInfo_channels :: AttrLabelProxy "channels"
audioInfo_channels = AttrLabelProxy


getAudioInfoBpf :: MonadIO m => AudioInfo -> m Int32
getAudioInfoBpf s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO Int32
    return val

setAudioInfoBpf :: MonadIO m => AudioInfo -> Int32 -> m ()
setAudioInfoBpf s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 24) (val :: Int32)

data AudioInfoBpfFieldInfo
instance AttrInfo AudioInfoBpfFieldInfo where
    type AttrAllowedOps AudioInfoBpfFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AudioInfoBpfFieldInfo = (~) Int32
    type AttrBaseTypeConstraint AudioInfoBpfFieldInfo = (~) AudioInfo
    type AttrGetType AudioInfoBpfFieldInfo = Int32
    type AttrLabel AudioInfoBpfFieldInfo = "bpf"
    type AttrOrigin AudioInfoBpfFieldInfo = AudioInfo
    attrGet _ = getAudioInfoBpf
    attrSet _ = setAudioInfoBpf
    attrConstruct = undefined
    attrClear _ = undefined

audioInfo_bpf :: AttrLabelProxy "bpf"
audioInfo_bpf = AttrLabelProxy


-- XXX Skipped attribute for "AudioInfo:position" :: Not implemented: "Don't know how to unpack C array of type TCArray False 64 (-1) (TInterface (Name {namespace = \"GstAudio\", name = \"AudioChannelPosition\"}))"

instance O.HasAttributeList AudioInfo
type instance O.AttributeList AudioInfo = AudioInfoAttributeList
type AudioInfoAttributeList = ('[ '("finfo", AudioInfoFinfoFieldInfo), '("flags", AudioInfoFlagsFieldInfo), '("layout", AudioInfoLayoutFieldInfo), '("rate", AudioInfoRateFieldInfo), '("channels", AudioInfoChannelsFieldInfo), '("bpf", AudioInfoBpfFieldInfo)] :: [(Symbol, *)])

-- method AudioInfo::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_audio_info_new" gst_audio_info_new :: 
    IO (Ptr AudioInfo)

{- |
Allocate a new 'GI.GstAudio.Structs.AudioInfo.AudioInfo' that is also initialized with
'GI.GstAudio.Structs.AudioInfo.audioInfoInit'.
-}
audioInfoNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m AudioInfo
    {- ^ __Returns:__ a new 'GI.GstAudio.Structs.AudioInfo.AudioInfo'. free with 'GI.GstAudio.Structs.AudioInfo.audioInfoFree'. -}
audioInfoNew  = liftIO $ do
    result <- gst_audio_info_new
    checkUnexpectedReturnNULL "audioInfoNew" result
    result' <- (wrapBoxed AudioInfo) result
    return result'

-- method AudioInfo::convert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_fmt", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GstFormat of the @src_val", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_val", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "value to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_fmt", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GstFormat of the @dest_val", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_val", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to destination value", 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_info_convert" gst_audio_info_convert :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    CUInt ->                                -- src_fmt : TInterface (Name {namespace = "Gst", name = "Format"})
    Int64 ->                                -- src_val : TBasicType TInt64
    CUInt ->                                -- dest_fmt : TInterface (Name {namespace = "Gst", name = "Format"})
    Int64 ->                                -- dest_val : TBasicType TInt64
    IO CInt

{- |
Converts among various 'GI.Gst.Enums.Format' types.  This function handles
GST_FORMAT_BYTES, GST_FORMAT_TIME, and GST_FORMAT_DEFAULT.  For
raw audio, GST_FORMAT_DEFAULT corresponds to audio frames.  This
function can be used to handle pad queries of the type GST_QUERY_CONVERT.
-}
audioInfoConvert ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> Gst.Enums.Format
    {- ^ /@srcFmt@/: 'GI.Gst.Enums.Format' of the /@srcVal@/ -}
    -> Int64
    {- ^ /@srcVal@/: value to convert -}
    -> Gst.Enums.Format
    {- ^ /@destFmt@/: 'GI.Gst.Enums.Format' of the /@destVal@/ -}
    -> Int64
    {- ^ /@destVal@/: pointer to destination value -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the conversion was successful. -}
audioInfoConvert info srcFmt srcVal destFmt destVal = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    let srcFmt' = (fromIntegral . fromEnum) srcFmt
    let destFmt' = (fromIntegral . fromEnum) destFmt
    result <- gst_audio_info_convert info' srcFmt' srcVal destFmt' destVal
    let result' = (/= 0) result
    touchManagedPtr info
    return result'

data AudioInfoConvertMethodInfo
instance (signature ~ (Gst.Enums.Format -> Int64 -> Gst.Enums.Format -> Int64 -> m Bool), MonadIO m) => O.MethodInfo AudioInfoConvertMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoConvert

-- method AudioInfo::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_audio_info_copy" gst_audio_info_copy :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    IO (Ptr AudioInfo)

{- |
Copy a GstAudioInfo structure.
-}
audioInfoCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> m AudioInfo
    {- ^ __Returns:__ a new 'GI.GstAudio.Structs.AudioInfo.AudioInfo'. free with gst_audio_info_free. -}
audioInfoCopy info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- gst_audio_info_copy info'
    checkUnexpectedReturnNULL "audioInfoCopy" result
    result' <- (wrapBoxed AudioInfo) result
    touchManagedPtr info
    return result'

data AudioInfoCopyMethodInfo
instance (signature ~ (m AudioInfo), MonadIO m) => O.MethodInfo AudioInfoCopyMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoCopy

-- method AudioInfo::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", 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_info_free" gst_audio_info_free :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    IO ()

{- |
Free a GstAudioInfo structure previously allocated with 'GI.GstAudio.Structs.AudioInfo.audioInfoNew'
or 'GI.GstAudio.Structs.AudioInfo.audioInfoCopy'.
-}
audioInfoFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> m ()
audioInfoFree info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    gst_audio_info_free info'
    touchManagedPtr info
    return ()

data AudioInfoFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AudioInfoFreeMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoFree

-- method AudioInfo::from_caps
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", 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_info_from_caps" gst_audio_info_from_caps :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Parse /@caps@/ and update /@info@/.
-}
audioInfoFromCaps ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> Gst.Caps.Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if /@caps@/ could be parsed -}
audioInfoFromCaps info caps = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_audio_info_from_caps info' caps'
    let result' = (/= 0) result
    touchManagedPtr info
    touchManagedPtr caps
    return result'

data AudioInfoFromCapsMethodInfo
instance (signature ~ (Gst.Caps.Caps -> m Bool), MonadIO m) => O.MethodInfo AudioInfoFromCapsMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoFromCaps

-- method AudioInfo::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", 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_info_init" gst_audio_info_init :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    IO ()

{- |
Initialize /@info@/ with default values.
-}
audioInfoInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> m ()
audioInfoInit info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    gst_audio_info_init info'
    touchManagedPtr info
    return ()

data AudioInfoInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AudioInfoInitMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoInit

-- method AudioInfo::is_equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "other", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", 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_info_is_equal" gst_audio_info_is_equal :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    Ptr AudioInfo ->                        -- other : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    IO CInt

{- |
Compares two 'GI.GstAudio.Structs.AudioInfo.AudioInfo' and returns whether they are equal or not

@since 1.2
-}
audioInfoIsEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> AudioInfo
    {- ^ /@other@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@info@/ and /@other@/ are equal, else 'False'. -}
audioInfoIsEqual info other = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    other' <- unsafeManagedPtrGetPtr other
    result <- gst_audio_info_is_equal info' other'
    let result' = (/= 0) result
    touchManagedPtr info
    touchManagedPtr other
    return result'

data AudioInfoIsEqualMethodInfo
instance (signature ~ (AudioInfo -> m Bool), MonadIO m) => O.MethodInfo AudioInfoIsEqualMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoIsEqual

-- method AudioInfo::set_format
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "GstAudio", name = "AudioFormat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the format", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rate", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the samplerate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "position", argType = TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel positions", 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_info_set_format" gst_audio_info_set_format :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    CUInt ->                                -- format : TInterface (Name {namespace = "GstAudio", name = "AudioFormat"})
    Int32 ->                                -- rate : TBasicType TInt
    Int32 ->                                -- channels : TBasicType TInt
    CUInt ->                                -- position : TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})
    IO ()

{- |
Set the default info for the audio info of /@format@/ and /@rate@/ and /@channels@/.

Note: This initializes /@info@/ first, no values are preserved.
-}
audioInfoSetFormat ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> GstAudio.Enums.AudioFormat
    {- ^ /@format@/: the format -}
    -> Int32
    {- ^ /@rate@/: the samplerate -}
    -> Int32
    {- ^ /@channels@/: the number of channels -}
    -> GstAudio.Enums.AudioChannelPosition
    {- ^ /@position@/: the channel positions -}
    -> m ()
audioInfoSetFormat info format rate channels position = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    let format' = (fromIntegral . fromEnum) format
    let position' = (fromIntegral . fromEnum) position
    gst_audio_info_set_format info' format' rate channels position'
    touchManagedPtr info
    return ()

data AudioInfoSetFormatMethodInfo
instance (signature ~ (GstAudio.Enums.AudioFormat -> Int32 -> Int32 -> GstAudio.Enums.AudioChannelPosition -> m ()), MonadIO m) => O.MethodInfo AudioInfoSetFormatMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoSetFormat

-- method AudioInfo::to_caps
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_audio_info_to_caps" gst_audio_info_to_caps :: 
    Ptr AudioInfo ->                        -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
    IO (Ptr Gst.Caps.Caps)

{- |
Convert the values of /@info@/ into a 'GI.Gst.Structs.Caps.Caps'.
-}
audioInfoToCaps ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioInfo
    {- ^ /@info@/: a 'GI.GstAudio.Structs.AudioInfo.AudioInfo' -}
    -> m Gst.Caps.Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' containing the
         info of /@info@/. -}
audioInfoToCaps info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- gst_audio_info_to_caps info'
    checkUnexpectedReturnNULL "audioInfoToCaps" result
    result' <- (wrapBoxed Gst.Caps.Caps) result
    touchManagedPtr info
    return result'

data AudioInfoToCapsMethodInfo
instance (signature ~ (m Gst.Caps.Caps), MonadIO m) => O.MethodInfo AudioInfoToCapsMethodInfo AudioInfo signature where
    overloadedMethod _ = audioInfoToCaps

type family ResolveAudioInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveAudioInfoMethod "convert" o = AudioInfoConvertMethodInfo
    ResolveAudioInfoMethod "copy" o = AudioInfoCopyMethodInfo
    ResolveAudioInfoMethod "free" o = AudioInfoFreeMethodInfo
    ResolveAudioInfoMethod "fromCaps" o = AudioInfoFromCapsMethodInfo
    ResolveAudioInfoMethod "init" o = AudioInfoInitMethodInfo
    ResolveAudioInfoMethod "isEqual" o = AudioInfoIsEqualMethodInfo
    ResolveAudioInfoMethod "toCaps" o = AudioInfoToCapsMethodInfo
    ResolveAudioInfoMethod "setFormat" o = AudioInfoSetFormatMethodInfo
    ResolveAudioInfoMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveAudioInfoMethod t AudioInfo, O.MethodInfo info AudioInfo p) => O.IsLabelProxy t (AudioInfo -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveAudioInfoMethod t AudioInfo, O.MethodInfo info AudioInfo p) => O.IsLabel t (AudioInfo -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif