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

\<refsect2>
\<para>
This object is the base class for audio ringbuffers used by the base
audio source and sink classes.
\<\/para>
\<para>
The ringbuffer abstracts a circular buffer of data. One reader and
one writer can operate on the data from different threads in a lockfree
manner. The base class is sufficiently flexible to be used as an
abstraction for DMA based ringbuffers as well as a pure software
implementations.
\<\/para>
\<\/refsect2>
-}

module GI.GstAudio.Objects.AudioRingBuffer
    ( 

-- * Exported types
    AudioRingBuffer(..)                     ,
    IsAudioRingBuffer                       ,
    toAudioRingBuffer                       ,
    noAudioRingBuffer                       ,


 -- * Methods
-- ** acquire #method:acquire#
    AudioRingBufferAcquireMethodInfo        ,
    audioRingBufferAcquire                  ,


-- ** activate #method:activate#
    AudioRingBufferActivateMethodInfo       ,
    audioRingBufferActivate                 ,


-- ** advance #method:advance#
    AudioRingBufferAdvanceMethodInfo        ,
    audioRingBufferAdvance                  ,


-- ** clear #method:clear#
    AudioRingBufferClearMethodInfo          ,
    audioRingBufferClear                    ,


-- ** clearAll #method:clearAll#
    AudioRingBufferClearAllMethodInfo       ,
    audioRingBufferClearAll                 ,


-- ** closeDevice #method:closeDevice#
    AudioRingBufferCloseDeviceMethodInfo    ,
    audioRingBufferCloseDevice              ,


-- ** commit #method:commit#
    AudioRingBufferCommitMethodInfo         ,
    audioRingBufferCommit                   ,


-- ** convert #method:convert#
    AudioRingBufferConvertMethodInfo        ,
    audioRingBufferConvert                  ,


-- ** debugSpecBuff #method:debugSpecBuff#
    audioRingBufferDebugSpecBuff            ,


-- ** debugSpecCaps #method:debugSpecCaps#
    audioRingBufferDebugSpecCaps            ,


-- ** delay #method:delay#
    AudioRingBufferDelayMethodInfo          ,
    audioRingBufferDelay                    ,


-- ** deviceIsOpen #method:deviceIsOpen#
    AudioRingBufferDeviceIsOpenMethodInfo   ,
    audioRingBufferDeviceIsOpen             ,


-- ** isAcquired #method:isAcquired#
    AudioRingBufferIsAcquiredMethodInfo     ,
    audioRingBufferIsAcquired               ,


-- ** isActive #method:isActive#
    AudioRingBufferIsActiveMethodInfo       ,
    audioRingBufferIsActive                 ,


-- ** isFlushing #method:isFlushing#
    AudioRingBufferIsFlushingMethodInfo     ,
    audioRingBufferIsFlushing               ,


-- ** mayStart #method:mayStart#
    AudioRingBufferMayStartMethodInfo       ,
    audioRingBufferMayStart                 ,


-- ** openDevice #method:openDevice#
    AudioRingBufferOpenDeviceMethodInfo     ,
    audioRingBufferOpenDevice               ,


-- ** parseCaps #method:parseCaps#
    audioRingBufferParseCaps                ,


-- ** pause #method:pause#
    AudioRingBufferPauseMethodInfo          ,
    audioRingBufferPause                    ,


-- ** prepareRead #method:prepareRead#
    AudioRingBufferPrepareReadMethodInfo    ,
    audioRingBufferPrepareRead              ,


-- ** read #method:read#
    AudioRingBufferReadMethodInfo           ,
    audioRingBufferRead                     ,


-- ** release #method:release#
    AudioRingBufferReleaseMethodInfo        ,
    audioRingBufferRelease                  ,


-- ** samplesDone #method:samplesDone#
    AudioRingBufferSamplesDoneMethodInfo    ,
    audioRingBufferSamplesDone              ,


-- ** setCallback #method:setCallback#
    AudioRingBufferSetCallbackMethodInfo    ,
    audioRingBufferSetCallback              ,


-- ** setChannelPositions #method:setChannelPositions#
    AudioRingBufferSetChannelPositionsMethodInfo,
    audioRingBufferSetChannelPositions      ,


-- ** setFlushing #method:setFlushing#
    AudioRingBufferSetFlushingMethodInfo    ,
    audioRingBufferSetFlushing              ,


-- ** setSample #method:setSample#
    AudioRingBufferSetSampleMethodInfo      ,
    audioRingBufferSetSample                ,


-- ** setTimestamp #method:setTimestamp#
    AudioRingBufferSetTimestampMethodInfo   ,
    audioRingBufferSetTimestamp             ,


-- ** start #method:start#
    AudioRingBufferStartMethodInfo          ,
    audioRingBufferStart                    ,


-- ** stop #method:stop#
    AudioRingBufferStopMethodInfo           ,
    audioRingBufferStop                     ,




    ) 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.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Enums as Gst.Enums
import qualified GI.Gst.Objects.Object as Gst.Object
import qualified GI.Gst.Structs.Caps as Gst.Caps
import qualified GI.GstAudio.Callbacks as GstAudio.Callbacks
import {-# SOURCE #-} qualified GI.GstAudio.Enums as GstAudio.Enums
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioRingBufferSpec as GstAudio.AudioRingBufferSpec

newtype AudioRingBuffer = AudioRingBuffer (ManagedPtr AudioRingBuffer)
foreign import ccall "gst_audio_ring_buffer_get_type"
    c_gst_audio_ring_buffer_get_type :: IO GType

instance GObject AudioRingBuffer where
    gobjectType _ = c_gst_audio_ring_buffer_get_type
    

class GObject o => IsAudioRingBuffer o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError AudioRingBuffer a) =>
    IsAudioRingBuffer a
#endif
instance IsAudioRingBuffer AudioRingBuffer
instance Gst.Object.IsObject AudioRingBuffer
instance GObject.Object.IsObject AudioRingBuffer

toAudioRingBuffer :: IsAudioRingBuffer o => o -> IO AudioRingBuffer
toAudioRingBuffer = unsafeCastTo AudioRingBuffer

noAudioRingBuffer :: Maybe AudioRingBuffer
noAudioRingBuffer = Nothing

type family ResolveAudioRingBufferMethod (t :: Symbol) (o :: *) :: * where
    ResolveAudioRingBufferMethod "acquire" o = AudioRingBufferAcquireMethodInfo
    ResolveAudioRingBufferMethod "activate" o = AudioRingBufferActivateMethodInfo
    ResolveAudioRingBufferMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolveAudioRingBufferMethod "advance" o = AudioRingBufferAdvanceMethodInfo
    ResolveAudioRingBufferMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAudioRingBufferMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAudioRingBufferMethod "clear" o = AudioRingBufferClearMethodInfo
    ResolveAudioRingBufferMethod "clearAll" o = AudioRingBufferClearAllMethodInfo
    ResolveAudioRingBufferMethod "closeDevice" o = AudioRingBufferCloseDeviceMethodInfo
    ResolveAudioRingBufferMethod "commit" o = AudioRingBufferCommitMethodInfo
    ResolveAudioRingBufferMethod "convert" o = AudioRingBufferConvertMethodInfo
    ResolveAudioRingBufferMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolveAudioRingBufferMethod "delay" o = AudioRingBufferDelayMethodInfo
    ResolveAudioRingBufferMethod "deviceIsOpen" o = AudioRingBufferDeviceIsOpenMethodInfo
    ResolveAudioRingBufferMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAudioRingBufferMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAudioRingBufferMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolveAudioRingBufferMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolveAudioRingBufferMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolveAudioRingBufferMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolveAudioRingBufferMethod "isAcquired" o = AudioRingBufferIsAcquiredMethodInfo
    ResolveAudioRingBufferMethod "isActive" o = AudioRingBufferIsActiveMethodInfo
    ResolveAudioRingBufferMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAudioRingBufferMethod "isFlushing" o = AudioRingBufferIsFlushingMethodInfo
    ResolveAudioRingBufferMethod "mayStart" o = AudioRingBufferMayStartMethodInfo
    ResolveAudioRingBufferMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAudioRingBufferMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAudioRingBufferMethod "openDevice" o = AudioRingBufferOpenDeviceMethodInfo
    ResolveAudioRingBufferMethod "pause" o = AudioRingBufferPauseMethodInfo
    ResolveAudioRingBufferMethod "prepareRead" o = AudioRingBufferPrepareReadMethodInfo
    ResolveAudioRingBufferMethod "read" o = AudioRingBufferReadMethodInfo
    ResolveAudioRingBufferMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolveAudioRingBufferMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAudioRingBufferMethod "release" o = AudioRingBufferReleaseMethodInfo
    ResolveAudioRingBufferMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolveAudioRingBufferMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveAudioRingBufferMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveAudioRingBufferMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAudioRingBufferMethod "samplesDone" o = AudioRingBufferSamplesDoneMethodInfo
    ResolveAudioRingBufferMethod "start" o = AudioRingBufferStartMethodInfo
    ResolveAudioRingBufferMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAudioRingBufferMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAudioRingBufferMethod "stop" o = AudioRingBufferStopMethodInfo
    ResolveAudioRingBufferMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolveAudioRingBufferMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
    ResolveAudioRingBufferMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAudioRingBufferMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolveAudioRingBufferMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolveAudioRingBufferMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAudioRingBufferMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolveAudioRingBufferMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolveAudioRingBufferMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAudioRingBufferMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
    ResolveAudioRingBufferMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
    ResolveAudioRingBufferMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolveAudioRingBufferMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolveAudioRingBufferMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAudioRingBufferMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAudioRingBufferMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
    ResolveAudioRingBufferMethod "getValueArray" o = Gst.Object.ObjectGetValueArrayMethodInfo
    ResolveAudioRingBufferMethod "setCallback" o = AudioRingBufferSetCallbackMethodInfo
    ResolveAudioRingBufferMethod "setChannelPositions" o = AudioRingBufferSetChannelPositionsMethodInfo
    ResolveAudioRingBufferMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolveAudioRingBufferMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolveAudioRingBufferMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolveAudioRingBufferMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAudioRingBufferMethod "setFlushing" o = AudioRingBufferSetFlushingMethodInfo
    ResolveAudioRingBufferMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolveAudioRingBufferMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolveAudioRingBufferMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAudioRingBufferMethod "setSample" o = AudioRingBufferSetSampleMethodInfo
    ResolveAudioRingBufferMethod "setTimestamp" o = AudioRingBufferSetTimestampMethodInfo
    ResolveAudioRingBufferMethod l o = O.MethodResolutionFailed l o

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

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

instance O.HasAttributeList AudioRingBuffer
type instance O.AttributeList AudioRingBuffer = AudioRingBufferAttributeList
type AudioRingBufferAttributeList = ('[ '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])

type instance O.SignalList AudioRingBuffer = AudioRingBufferSignalList
type AudioRingBufferSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method AudioRingBuffer::acquire
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to acquire", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "spec", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the specs of the buffer", 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_ring_buffer_acquire" gst_audio_ring_buffer_acquire :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Ptr GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> -- spec : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"})
    IO CInt

{- |
Allocate the resources for the ringbuffer. This function fills
in the data pointer of the ring buffer with a valid 'GI.Gst.Structs.Buffer.Buffer'
to which samples can be written.
-}
audioRingBufferAcquire ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to acquire -}
    -> GstAudio.AudioRingBufferSpec.AudioRingBufferSpec
    {- ^ /@spec@/: the specs of the buffer -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be acquired, FALSE on error.

MT safe. -}
audioRingBufferAcquire buf spec = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    spec' <- unsafeManagedPtrGetPtr spec
    result <- gst_audio_ring_buffer_acquire buf' spec'
    let result' = (/= 0) result
    touchManagedPtr buf
    touchManagedPtr spec
    return result'

data AudioRingBufferAcquireMethodInfo
instance (signature ~ (GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferAcquireMethodInfo a signature where
    overloadedMethod _ = audioRingBufferAcquire

-- method AudioRingBuffer::activate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to activate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new mode", 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_ring_buffer_activate" gst_audio_ring_buffer_activate :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    CInt ->                                 -- active : TBasicType TBoolean
    IO CInt

{- |
Activate /@buf@/ to start or stop pulling data.

MT safe.
-}
audioRingBufferActivate ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to activate -}
    -> Bool
    {- ^ /@active@/: the new mode -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be activated in the requested mode,
FALSE on error. -}
audioRingBufferActivate buf active = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    let active' = (fromIntegral . fromEnum) active
    result <- gst_audio_ring_buffer_activate buf' active'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferActivateMethodInfo
instance (signature ~ (Bool -> m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferActivateMethodInfo a signature where
    overloadedMethod _ = audioRingBufferActivate

-- method AudioRingBuffer::advance
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to advance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "advance", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of segments written", 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_ring_buffer_advance" gst_audio_ring_buffer_advance :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Word32 ->                               -- advance : TBasicType TUInt
    IO ()

{- |
Subclasses should call this function to notify the fact that
/@advance@/ segments are now processed by the device.

MT safe.
-}
audioRingBufferAdvance ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to advance -}
    -> Word32
    {- ^ /@advance@/: the number of segments written -}
    -> m ()
audioRingBufferAdvance buf advance = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    gst_audio_ring_buffer_advance buf' advance
    touchManagedPtr buf
    return ()

data AudioRingBufferAdvanceMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferAdvanceMethodInfo a signature where
    overloadedMethod _ = audioRingBufferAdvance

-- method AudioRingBuffer::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to clear", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "segment", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the segment to clear", 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_ring_buffer_clear" gst_audio_ring_buffer_clear :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Int32 ->                                -- segment : TBasicType TInt
    IO ()

{- |
Clear the given segment of the buffer with silence samples.
This function is used by subclasses.

MT safe.
-}
audioRingBufferClear ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to clear -}
    -> Int32
    {- ^ /@segment@/: the segment to clear -}
    -> m ()
audioRingBufferClear buf segment = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    gst_audio_ring_buffer_clear buf' segment
    touchManagedPtr buf
    return ()

data AudioRingBufferClearMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferClearMethodInfo a signature where
    overloadedMethod _ = audioRingBufferClear

-- method AudioRingBuffer::clear_all
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to clear", 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_ring_buffer_clear_all" gst_audio_ring_buffer_clear_all :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO ()

{- |
Fill the ringbuffer with silence.

MT safe.
-}
audioRingBufferClearAll ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to clear -}
    -> m ()
audioRingBufferClearAll buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    gst_audio_ring_buffer_clear_all buf'
    touchManagedPtr buf
    return ()

data AudioRingBufferClearAllMethodInfo
instance (signature ~ (m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferClearAllMethodInfo a signature where
    overloadedMethod _ = audioRingBufferClearAll

-- method AudioRingBuffer::close_device
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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_ring_buffer_close_device" gst_audio_ring_buffer_close_device :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Close the audio device associated with the ring buffer. The ring buffer
should already have been released via 'GI.GstAudio.Objects.AudioRingBuffer.audioRingBufferRelease'.
-}
audioRingBufferCloseDevice ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be closed, FALSE on error.

MT safe. -}
audioRingBufferCloseDevice buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_close_device buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferCloseDeviceMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferCloseDeviceMethodInfo a signature where
    overloadedMethod _ = audioRingBufferCloseDevice

-- method AudioRingBuffer::commit
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to commit", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sample", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample position of the data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the data to commit", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_samples", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of samples in the data to commit", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_samples", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of samples to write to the ringbuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "accum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "accumulator for rate conversion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_audio_ring_buffer_commit" gst_audio_ring_buffer_commit :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Word64 ->                               -- sample : TBasicType TUInt64
    Word8 ->                                -- data : TBasicType TUInt8
    Int32 ->                                -- in_samples : TBasicType TInt
    Int32 ->                                -- out_samples : TBasicType TInt
    Int32 ->                                -- accum : TBasicType TInt
    IO Word32

{- |
Commit /@inSamples@/ samples pointed to by /@data@/ to the ringbuffer /@buf@/.

/@inSamples@/ and /@outSamples@/ define the rate conversion to perform on the
samples in /@data@/. For negative rates, /@outSamples@/ must be negative and
/@inSamples@/ positive.

When /@outSamples@/ is positive, the first sample will be written at position /@sample@/
in the ringbuffer. When /@outSamples@/ is negative, the last sample will be written to
/@sample@/ in reverse order.

/@outSamples@/ does not need to be a multiple of the segment size of the ringbuffer
although it is recommended for optimal performance.

/@accum@/ will hold a temporary accumulator used in rate conversion and should be
set to 0 when this function is first called. In case the commit operation is
interrupted, one can resume the processing by passing the previously returned
/@accum@/ value back to this function.

MT safe.
-}
audioRingBufferCommit ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to commit -}
    -> Word64
    {- ^ /@sample@/: the sample position of the data -}
    -> Word8
    {- ^ /@data@/: the data to commit -}
    -> Int32
    {- ^ /@inSamples@/: the number of samples in the data to commit -}
    -> Int32
    {- ^ /@outSamples@/: the number of samples to write to the ringbuffer -}
    -> Int32
    {- ^ /@accum@/: accumulator for rate conversion. -}
    -> m Word32
    {- ^ __Returns:__ The number of samples written to the ringbuffer or -1 on error. The
number of samples written can be less than /@outSamples@/ when /@buf@/ was interrupted
with a flush or stop. -}
audioRingBufferCommit buf sample data_ inSamples outSamples accum = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_commit buf' sample data_ inSamples outSamples accum
    touchManagedPtr buf
    return result

data AudioRingBufferCommitMethodInfo
instance (signature ~ (Word64 -> Word8 -> Int32 -> Int32 -> Int32 -> m Word32), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferCommitMethodInfo a signature where
    overloadedMethod _ = audioRingBufferCommit

-- method AudioRingBuffer::convert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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 "the source format", 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 "the source value", 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 "the destination format", 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 "a location to store the converted 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_ring_buffer_convert" gst_audio_ring_buffer_convert :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    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

{- |
Convert /@srcVal@/ in /@srcFmt@/ to the equivalent value in /@destFmt@/. The result
will be put in /@destVal@/.
-}
audioRingBufferConvert ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> Gst.Enums.Format
    {- ^ /@srcFmt@/: the source format -}
    -> Int64
    {- ^ /@srcVal@/: the source value -}
    -> Gst.Enums.Format
    {- ^ /@destFmt@/: the destination format -}
    -> Int64
    {- ^ /@destVal@/: a location to store the converted value -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the conversion succeeded. -}
audioRingBufferConvert buf srcFmt srcVal destFmt destVal = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    let srcFmt' = (fromIntegral . fromEnum) srcFmt
    let destFmt' = (fromIntegral . fromEnum) destFmt
    result <- gst_audio_ring_buffer_convert buf' srcFmt' srcVal destFmt' destVal
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferConvertMethodInfo
instance (signature ~ (Gst.Enums.Format -> Int64 -> Gst.Enums.Format -> Int64 -> m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferConvertMethodInfo a signature where
    overloadedMethod _ = audioRingBufferConvert

-- method AudioRingBuffer::delay
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to query", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_audio_ring_buffer_delay" gst_audio_ring_buffer_delay :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO Word32

{- |
Get the number of samples queued in the audio device. This is
usually less than the segment size but can be bigger when the
implementation uses another internal buffer between the audio
device.

For playback ringbuffers this is the amount of samples transfered from the
ringbuffer to the device but still not played.

For capture ringbuffers this is the amount of samples in the device that are
not yet transfered to the ringbuffer.
-}
audioRingBufferDelay ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to query -}
    -> m Word32
    {- ^ __Returns:__ The number of samples queued in the audio device.

MT safe. -}
audioRingBufferDelay buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_delay buf'
    touchManagedPtr buf
    return result

data AudioRingBufferDelayMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferDelayMethodInfo a signature where
    overloadedMethod _ = audioRingBufferDelay

-- method AudioRingBuffer::device_is_open
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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_ring_buffer_device_is_open" gst_audio_ring_buffer_device_is_open :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Checks the status of the device associated with the ring buffer.
-}
audioRingBufferDeviceIsOpen ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device was open, FALSE if it was closed.

MT safe. -}
audioRingBufferDeviceIsOpen buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_device_is_open buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferDeviceIsOpenMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferDeviceIsOpenMethodInfo a signature where
    overloadedMethod _ = audioRingBufferDeviceIsOpen

-- method AudioRingBuffer::is_acquired
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to check", 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_ring_buffer_is_acquired" gst_audio_ring_buffer_is_acquired :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Check if the ringbuffer is acquired and ready to use.
-}
audioRingBufferIsAcquired ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to check -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the ringbuffer is acquired, FALSE on error.

MT safe. -}
audioRingBufferIsAcquired buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_is_acquired buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferIsAcquiredMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferIsAcquiredMethodInfo a signature where
    overloadedMethod _ = audioRingBufferIsAcquired

-- method AudioRingBuffer::is_active
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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_ring_buffer_is_active" gst_audio_ring_buffer_is_active :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Check if /@buf@/ is activated.

MT safe.
-}
audioRingBufferIsActive ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device is active. -}
audioRingBufferIsActive buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_is_active buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferIsActiveMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferIsActiveMethodInfo a signature where
    overloadedMethod _ = audioRingBufferIsActive

-- method AudioRingBuffer::is_flushing
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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_ring_buffer_is_flushing" gst_audio_ring_buffer_is_flushing :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Check if /@buf@/ is flushing.

MT safe.
-}
audioRingBufferIsFlushing ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device is flushing. -}
audioRingBufferIsFlushing buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_is_flushing buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferIsFlushingMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferIsFlushingMethodInfo a signature where
    overloadedMethod _ = audioRingBufferIsFlushing

-- method AudioRingBuffer::may_start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "allowed", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new value", 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_ring_buffer_may_start" gst_audio_ring_buffer_may_start :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    CInt ->                                 -- allowed : TBasicType TBoolean
    IO ()

{- |
Tell the ringbuffer that it is allowed to start playback when
the ringbuffer is filled with samples.

MT safe.
-}
audioRingBufferMayStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> Bool
    {- ^ /@allowed@/: the new value -}
    -> m ()
audioRingBufferMayStart buf allowed = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    let allowed' = (fromIntegral . fromEnum) allowed
    gst_audio_ring_buffer_may_start buf' allowed'
    touchManagedPtr buf
    return ()

data AudioRingBufferMayStartMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferMayStartMethodInfo a signature where
    overloadedMethod _ = audioRingBufferMayStart

-- method AudioRingBuffer::open_device
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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_ring_buffer_open_device" gst_audio_ring_buffer_open_device :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Open the audio device associated with the ring buffer. Does not perform any
setup on the device. You must open the device before acquiring the ring
buffer.
-}
audioRingBufferOpenDevice ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be opened, FALSE on error.

MT safe. -}
audioRingBufferOpenDevice buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_open_device buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferOpenDeviceMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferOpenDeviceMethodInfo a signature where
    overloadedMethod _ = audioRingBufferOpenDevice

-- method AudioRingBuffer::pause
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to pause", 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_ring_buffer_pause" gst_audio_ring_buffer_pause :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Pause processing samples from the ringbuffer.
-}
audioRingBufferPause ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to pause -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be paused, FALSE on error.

MT safe. -}
audioRingBufferPause buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_pause buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferPauseMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferPauseMethodInfo a signature where
    overloadedMethod _ = audioRingBufferPause

-- method AudioRingBuffer::prepare_read
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to read from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "segment", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the segment to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "readptr", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the pointer to the memory where samples can be read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to read", 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_ring_buffer_prepare_read" gst_audio_ring_buffer_prepare_read :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Int32 ->                                -- segment : TBasicType TInt
    Word8 ->                                -- readptr : TBasicType TUInt8
    Int32 ->                                -- len : TBasicType TInt
    IO CInt

{- |
Returns a pointer to memory where the data from segment /@segment@/
can be found. This function is mostly used by subclasses.
-}
audioRingBufferPrepareRead ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to read from -}
    -> Int32
    {- ^ /@segment@/: the segment to read -}
    -> Word8
    {- ^ /@readptr@/: the pointer to the memory where samples can be read -}
    -> Int32
    {- ^ /@len@/: the number of bytes to read -}
    -> m Bool
    {- ^ __Returns:__ FALSE if the buffer is not started.

MT safe. -}
audioRingBufferPrepareRead buf segment readptr len = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_prepare_read buf' segment readptr len
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferPrepareReadMethodInfo
instance (signature ~ (Int32 -> Word8 -> Int32 -> m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferPrepareReadMethodInfo a signature where
    overloadedMethod _ = audioRingBufferPrepareRead

-- method AudioRingBuffer::read
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to read from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sample", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample position of the data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "where the data should be read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of samples in data to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timestamp", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "where the timestamp is returned", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_audio_ring_buffer_read" gst_audio_ring_buffer_read :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Word64 ->                               -- sample : TBasicType TUInt64
    Word8 ->                                -- data : TBasicType TUInt8
    Word32 ->                               -- len : TBasicType TUInt
    Word64 ->                               -- timestamp : TBasicType TUInt64
    IO Word32

{- |
Read /@len@/ samples from the ringbuffer into the memory pointed
to by /@data@/.
The first sample should be read from position /@sample@/ in
the ringbuffer.

/@len@/ should not be a multiple of the segment size of the ringbuffer
although it is recommended.

/@timestamp@/ will return the timestamp associated with the data returned.
-}
audioRingBufferRead ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to read from -}
    -> Word64
    {- ^ /@sample@/: the sample position of the data -}
    -> Word8
    {- ^ /@data@/: where the data should be read -}
    -> Word32
    {- ^ /@len@/: the number of samples in data to read -}
    -> Word64
    {- ^ /@timestamp@/: where the timestamp is returned -}
    -> m Word32
    {- ^ __Returns:__ The number of samples read from the ringbuffer or -1 on
error.

MT safe. -}
audioRingBufferRead buf sample data_ len timestamp = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_read buf' sample data_ len timestamp
    touchManagedPtr buf
    return result

data AudioRingBufferReadMethodInfo
instance (signature ~ (Word64 -> Word8 -> Word32 -> Word64 -> m Word32), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferReadMethodInfo a signature where
    overloadedMethod _ = audioRingBufferRead

-- method AudioRingBuffer::release
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to release", 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_ring_buffer_release" gst_audio_ring_buffer_release :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Free the resources of the ringbuffer.
-}
audioRingBufferRelease ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to release -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be released, FALSE on error.

MT safe. -}
audioRingBufferRelease buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_release buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferReleaseMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferReleaseMethodInfo a signature where
    overloadedMethod _ = audioRingBufferRelease

-- method AudioRingBuffer::samples_done
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to query", 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_ring_buffer_samples_done" gst_audio_ring_buffer_samples_done :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO Word64

{- |
Get the number of samples that were processed by the ringbuffer
since it was last started. This does not include the number of samples not
yet processed (see 'GI.GstAudio.Objects.AudioRingBuffer.audioRingBufferDelay').
-}
audioRingBufferSamplesDone ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to query -}
    -> m Word64
    {- ^ __Returns:__ The number of samples processed by the ringbuffer.

MT safe. -}
audioRingBufferSamplesDone buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_samples_done buf'
    touchManagedPtr buf
    return result

data AudioRingBufferSamplesDoneMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferSamplesDoneMethodInfo a signature where
    overloadedMethod _ = audioRingBufferSamplesDone

-- method AudioRingBuffer::set_callback
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to set the callback on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cb", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the callback to set", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to the callback", 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_ring_buffer_set_callback" gst_audio_ring_buffer_set_callback :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    FunPtr GstAudio.Callbacks.C_AudioRingBufferCallback -> -- cb : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Sets the given callback function on the buffer. This function
will be called every time a segment has been written to a device.

MT safe.
-}
audioRingBufferSetCallback ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to set the callback on -}
    -> GstAudio.Callbacks.AudioRingBufferCallback
    {- ^ /@cb@/: the callback to set -}
    -> m ()
audioRingBufferSetCallback buf cb = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    ptrcb <- callocMem :: IO (Ptr (FunPtr GstAudio.Callbacks.C_AudioRingBufferCallback))
    cb' <- GstAudio.Callbacks.mk_AudioRingBufferCallback (GstAudio.Callbacks.wrap_AudioRingBufferCallback (Just ptrcb) (GstAudio.Callbacks.drop_closures_AudioRingBufferCallback cb))
    poke ptrcb cb'
    let userData = nullPtr
    gst_audio_ring_buffer_set_callback buf' cb' userData
    touchManagedPtr buf
    return ()

data AudioRingBufferSetCallbackMethodInfo
instance (signature ~ (GstAudio.Callbacks.AudioRingBufferCallback -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferSetCallbackMethodInfo a signature where
    overloadedMethod _ = audioRingBufferSetCallback

-- method AudioRingBuffer::set_channel_positions
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer", 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 device 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_ring_buffer_set_channel_positions" gst_audio_ring_buffer_set_channel_positions :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    CUInt ->                                -- position : TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})
    IO ()

{- |
Tell the ringbuffer about the device\'s channel positions. This must
be called in when the ringbuffer is acquired.
-}
audioRingBufferSetChannelPositions ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' -}
    -> GstAudio.Enums.AudioChannelPosition
    {- ^ /@position@/: the device channel positions -}
    -> m ()
audioRingBufferSetChannelPositions buf position = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    let position' = (fromIntegral . fromEnum) position
    gst_audio_ring_buffer_set_channel_positions buf' position'
    touchManagedPtr buf
    return ()

data AudioRingBufferSetChannelPositionsMethodInfo
instance (signature ~ (GstAudio.Enums.AudioChannelPosition -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferSetChannelPositionsMethodInfo a signature where
    overloadedMethod _ = audioRingBufferSetChannelPositions

-- method AudioRingBuffer::set_flushing
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to flush", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flushing", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new mode", 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_ring_buffer_set_flushing" gst_audio_ring_buffer_set_flushing :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    CInt ->                                 -- flushing : TBasicType TBoolean
    IO ()

{- |
Set the ringbuffer to flushing mode or normal mode.

MT safe.
-}
audioRingBufferSetFlushing ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to flush -}
    -> Bool
    {- ^ /@flushing@/: the new mode -}
    -> m ()
audioRingBufferSetFlushing buf flushing = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    let flushing' = (fromIntegral . fromEnum) flushing
    gst_audio_ring_buffer_set_flushing buf' flushing'
    touchManagedPtr buf
    return ()

data AudioRingBufferSetFlushingMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferSetFlushingMethodInfo a signature where
    overloadedMethod _ = audioRingBufferSetFlushing

-- method AudioRingBuffer::set_sample
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sample", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample number to set", 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_ring_buffer_set_sample" gst_audio_ring_buffer_set_sample :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Word64 ->                               -- sample : TBasicType TUInt64
    IO ()

{- |
Make sure that the next sample written to the device is
accounted for as being the /@sample@/ sample written to the
device. This value will be used in reporting the current
sample position of the ringbuffer.

This function will also clear the buffer with silence.

MT safe.
-}
audioRingBufferSetSample ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to use -}
    -> Word64
    {- ^ /@sample@/: the sample number to set -}
    -> m ()
audioRingBufferSetSample buf sample = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    gst_audio_ring_buffer_set_sample buf' sample
    touchManagedPtr buf
    return ()

data AudioRingBufferSetSampleMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferSetSampleMethodInfo a signature where
    overloadedMethod _ = audioRingBufferSetSample

-- method AudioRingBuffer::set_timestamp
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "readseg", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timestamp", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, 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_ring_buffer_set_timestamp" gst_audio_ring_buffer_set_timestamp :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    Int32 ->                                -- readseg : TBasicType TInt
    Word64 ->                               -- timestamp : TBasicType TUInt64
    IO ()

{- |
/No description available in the introspection data./
-}
audioRingBufferSetTimestamp ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    -> Int32
    -> Word64
    -> m ()
audioRingBufferSetTimestamp buf readseg timestamp = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    gst_audio_ring_buffer_set_timestamp buf' readseg timestamp
    touchManagedPtr buf
    return ()

data AudioRingBufferSetTimestampMethodInfo
instance (signature ~ (Int32 -> Word64 -> m ()), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferSetTimestampMethodInfo a signature where
    overloadedMethod _ = audioRingBufferSetTimestamp

-- method AudioRingBuffer::start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to start", 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_ring_buffer_start" gst_audio_ring_buffer_start :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Start processing samples from the ringbuffer.
-}
audioRingBufferStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to start -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be started, FALSE on error.

MT safe. -}
audioRingBufferStart buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_start buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferStartMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferStartMethodInfo a signature where
    overloadedMethod _ = audioRingBufferStart

-- method AudioRingBuffer::stop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "buf", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstAudioRingBuffer to stop", 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_ring_buffer_stop" gst_audio_ring_buffer_stop :: 
    Ptr AudioRingBuffer ->                  -- buf : TInterface (Name {namespace = "GstAudio", name = "AudioRingBuffer"})
    IO CInt

{- |
Stop processing samples from the ringbuffer.
-}
audioRingBufferStop ::
    (B.CallStack.HasCallStack, MonadIO m, IsAudioRingBuffer a) =>
    a
    {- ^ /@buf@/: the 'GI.GstAudio.Objects.AudioRingBuffer.AudioRingBuffer' to stop -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the device could be stopped, FALSE on error.

MT safe. -}
audioRingBufferStop buf = liftIO $ do
    buf' <- unsafeManagedPtrCastPtr buf
    result <- gst_audio_ring_buffer_stop buf'
    let result' = (/= 0) result
    touchManagedPtr buf
    return result'

data AudioRingBufferStopMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAudioRingBuffer a) => O.MethodInfo AudioRingBufferStopMethodInfo a signature where
    overloadedMethod _ = audioRingBufferStop

-- method AudioRingBuffer::debug_spec_buff
-- method type : MemberFunction
-- Args : [Arg {argCName = "spec", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the spec to debug", 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_ring_buffer_debug_spec_buff" gst_audio_ring_buffer_debug_spec_buff :: 
    Ptr GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> -- spec : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"})
    IO ()

{- |
Print debug info about the buffer sized in /@spec@/ to the debug log.
-}
audioRingBufferDebugSpecBuff ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GstAudio.AudioRingBufferSpec.AudioRingBufferSpec
    {- ^ /@spec@/: the spec to debug -}
    -> m ()
audioRingBufferDebugSpecBuff spec = liftIO $ do
    spec' <- unsafeManagedPtrGetPtr spec
    gst_audio_ring_buffer_debug_spec_buff spec'
    touchManagedPtr spec
    return ()

-- method AudioRingBuffer::debug_spec_caps
-- method type : MemberFunction
-- Args : [Arg {argCName = "spec", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the spec to debug", 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_ring_buffer_debug_spec_caps" gst_audio_ring_buffer_debug_spec_caps :: 
    Ptr GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> -- spec : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"})
    IO ()

{- |
Print debug info about the parsed caps in /@spec@/ to the debug log.
-}
audioRingBufferDebugSpecCaps ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GstAudio.AudioRingBufferSpec.AudioRingBufferSpec
    {- ^ /@spec@/: the spec to debug -}
    -> m ()
audioRingBufferDebugSpecCaps spec = liftIO $ do
    spec' <- unsafeManagedPtrGetPtr spec
    gst_audio_ring_buffer_debug_spec_caps spec'
    touchManagedPtr spec
    return ()

-- method AudioRingBuffer::parse_caps
-- method type : MemberFunction
-- Args : [Arg {argCName = "spec", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a spec", 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_ring_buffer_parse_caps" gst_audio_ring_buffer_parse_caps :: 
    Ptr GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> -- spec : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"})
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Parse /@caps@/ into /@spec@/.
-}
audioRingBufferParseCaps ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GstAudio.AudioRingBufferSpec.AudioRingBufferSpec
    {- ^ /@spec@/: a spec -}
    -> Gst.Caps.Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the caps could be parsed. -}
audioRingBufferParseCaps spec caps = liftIO $ do
    spec' <- unsafeManagedPtrGetPtr spec
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_audio_ring_buffer_parse_caps spec' caps'
    let result' = (/= 0) result
    touchManagedPtr spec
    touchManagedPtr caps
    return result'