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

/No description available in the introspection data./
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.GstAudio.Structs.AudioQuantize
    (

-- * Exported types
    AudioQuantize(..)                       ,
    noAudioQuantize                         ,


 -- * Methods
-- ** free #method:free#

#if ENABLE_OVERLOADING
    AudioQuantizeFreeMethodInfo             ,
#endif
    audioQuantizeFree                       ,


-- ** reset #method:reset#

#if ENABLE_OVERLOADING
    AudioQuantizeResetMethodInfo            ,
#endif
    audioQuantizeReset                      ,


-- ** samples #method:samples#

#if ENABLE_OVERLOADING
    AudioQuantizeSamplesMethodInfo          ,
#endif
    audioQuantizeSamples                    ,




    ) 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


-- | Memory-managed wrapper type.
newtype AudioQuantize = AudioQuantize (ManagedPtr AudioQuantize)
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr AudioQuantize where
    wrappedPtrCalloc = return nullPtr
    wrappedPtrCopy = return
    wrappedPtrFree = Nothing

-- | A convenience alias for `Nothing` :: `Maybe` `AudioQuantize`.
noAudioQuantize :: Maybe AudioQuantize
noAudioQuantize = Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList AudioQuantize
type instance O.AttributeList AudioQuantize = AudioQuantizeAttributeList
type AudioQuantizeAttributeList = ('[ ] :: [(Symbol, *)])
#endif

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

{- |
Free a 'GI.GstAudio.Structs.AudioQuantize.AudioQuantize'.
-}
audioQuantizeFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioQuantize
    {- ^ /@quant@/: a 'GI.GstAudio.Structs.AudioQuantize.AudioQuantize' -}
    -> m ()
audioQuantizeFree quant = liftIO $ do
    quant' <- unsafeManagedPtrGetPtr quant
    gst_audio_quantize_free quant'
    touchManagedPtr quant
    return ()

#if ENABLE_OVERLOADING
data AudioQuantizeFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AudioQuantizeFreeMethodInfo AudioQuantize signature where
    overloadedMethod _ = audioQuantizeFree

#endif

-- method AudioQuantize::reset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "quant", argType = TInterface (Name {namespace = "GstAudio", name = "AudioQuantize"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioQuantize", 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_quantize_reset" gst_audio_quantize_reset ::
    Ptr AudioQuantize ->                    -- quant : TInterface (Name {namespace = "GstAudio", name = "AudioQuantize"})
    IO ()

{- |
Reset /@quant@/ to the state is was when created, clearing any
history it might have.
-}
audioQuantizeReset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioQuantize
    {- ^ /@quant@/: a 'GI.GstAudio.Structs.AudioQuantize.AudioQuantize' -}
    -> m ()
audioQuantizeReset quant = liftIO $ do
    quant' <- unsafeManagedPtrGetPtr quant
    gst_audio_quantize_reset quant'
    touchManagedPtr quant
    return ()

#if ENABLE_OVERLOADING
data AudioQuantizeResetMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AudioQuantizeResetMethodInfo AudioQuantize signature where
    overloadedMethod _ = audioQuantizeReset

#endif

-- method AudioQuantize::samples
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "quant", argType = TInterface (Name {namespace = "GstAudio", name = "AudioQuantize"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAudioQuantize", 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 samples", 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 samples", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "samples", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of samples", 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_quantize_samples" gst_audio_quantize_samples ::
    Ptr AudioQuantize ->                    -- quant : TInterface (Name {namespace = "GstAudio", name = "AudioQuantize"})
    Ptr () ->                               -- in : TBasicType TPtr
    Ptr () ->                               -- out : TBasicType TPtr
    Word32 ->                               -- samples : TBasicType TUInt
    IO ()

{- |
Perform quantization on /@samples@/ in /@in@/ and write the result to /@out@/.

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@/ and /@out@/ may point to the same memory location, in which case samples will be
modified in-place.
-}
audioQuantizeSamples ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AudioQuantize
    {- ^ /@quant@/: a 'GI.GstAudio.Structs.AudioQuantize.AudioQuantize' -}
    -> Ptr ()
    {- ^ /@in@/: input samples -}
    -> Ptr ()
    {- ^ /@out@/: output samples -}
    -> Word32
    {- ^ /@samples@/: number of samples -}
    -> m ()
audioQuantizeSamples quant in_ out samples = liftIO $ do
    quant' <- unsafeManagedPtrGetPtr quant
    gst_audio_quantize_samples quant' in_ out samples
    touchManagedPtr quant
    return ()

#if ENABLE_OVERLOADING
data AudioQuantizeSamplesMethodInfo
instance (signature ~ (Ptr () -> Ptr () -> Word32 -> m ()), MonadIO m) => O.MethodInfo AudioQuantizeSamplesMethodInfo AudioQuantize signature where
    overloadedMethod _ = audioQuantizeSamples

#endif

#if ENABLE_OVERLOADING
type family ResolveAudioQuantizeMethod (t :: Symbol) (o :: *) :: * where
    ResolveAudioQuantizeMethod "free" o = AudioQuantizeFreeMethodInfo
    ResolveAudioQuantizeMethod "reset" o = AudioQuantizeResetMethodInfo
    ResolveAudioQuantizeMethod "samples" o = AudioQuantizeSamplesMethodInfo
    ResolveAudioQuantizeMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveAudioQuantizeMethod t AudioQuantize, O.MethodInfo info AudioQuantize p) => OL.IsLabel t (AudioQuantize -> 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