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

A base class for value mapping objects that attaches control sources to gobject
properties. Such an object is taking one or more 'GI.Gst.Objects.ControlSource.ControlSource' instances,
combines them and maps the resulting value to the type and value range of the
bound property.
-}

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

module GI.Gst.Objects.ControlBinding
    (

-- * Exported types
    ControlBinding(..)                      ,
    IsControlBinding                        ,
    toControlBinding                        ,
    noControlBinding                        ,


 -- * Methods
-- ** getGValueArray #method:getGValueArray#

#if ENABLE_OVERLOADING
    ControlBindingGetGValueArrayMethodInfo  ,
#endif
    controlBindingGetGValueArray            ,


-- ** getValue #method:getValue#

#if ENABLE_OVERLOADING
    ControlBindingGetValueMethodInfo        ,
#endif
    controlBindingGetValue                  ,


-- ** isDisabled #method:isDisabled#

#if ENABLE_OVERLOADING
    ControlBindingIsDisabledMethodInfo      ,
#endif
    controlBindingIsDisabled                ,


-- ** setDisabled #method:setDisabled#

#if ENABLE_OVERLOADING
    ControlBindingSetDisabledMethodInfo     ,
#endif
    controlBindingSetDisabled               ,


-- ** syncValues #method:syncValues#

#if ENABLE_OVERLOADING
    ControlBindingSyncValuesMethodInfo      ,
#endif
    controlBindingSyncValues                ,




 -- * Properties
-- ** name #attr:name#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ControlBindingNamePropertyInfo          ,
#endif
    constructControlBindingName             ,
#if ENABLE_OVERLOADING
    controlBindingName                      ,
#endif
    getControlBindingName                   ,


-- ** object #attr:object#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ControlBindingObjectPropertyInfo        ,
#endif
    constructControlBindingObject           ,
#if ENABLE_OVERLOADING
    controlBindingObject                    ,
#endif
    getControlBindingObject                 ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gst.Objects.Object as Gst.Object

-- | Memory-managed wrapper type.
newtype ControlBinding = ControlBinding (ManagedPtr ControlBinding)
foreign import ccall "gst_control_binding_get_type"
    c_gst_control_binding_get_type :: IO GType

instance GObject ControlBinding where
    gobjectType = c_gst_control_binding_get_type


-- | Type class for types which can be safely cast to `ControlBinding`, for instance with `toControlBinding`.
class (GObject o, O.IsDescendantOf ControlBinding o) => IsControlBinding o
instance (GObject o, O.IsDescendantOf ControlBinding o) => IsControlBinding o

instance O.HasParentTypes ControlBinding
type instance O.ParentTypes ControlBinding = '[Gst.Object.Object, GObject.Object.Object]

-- | Cast to `ControlBinding`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toControlBinding :: (MonadIO m, IsControlBinding o) => o -> m ControlBinding
toControlBinding = liftIO . unsafeCastTo ControlBinding

-- | A convenience alias for `Nothing` :: `Maybe` `ControlBinding`.
noControlBinding :: Maybe ControlBinding
noControlBinding = Nothing

#if ENABLE_OVERLOADING
type family ResolveControlBindingMethod (t :: Symbol) (o :: *) :: * where
    ResolveControlBindingMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolveControlBindingMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveControlBindingMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveControlBindingMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolveControlBindingMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveControlBindingMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveControlBindingMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveControlBindingMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolveControlBindingMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolveControlBindingMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolveControlBindingMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolveControlBindingMethod "isDisabled" o = ControlBindingIsDisabledMethodInfo
    ResolveControlBindingMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveControlBindingMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveControlBindingMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveControlBindingMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolveControlBindingMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveControlBindingMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolveControlBindingMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveControlBindingMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveControlBindingMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveControlBindingMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolveControlBindingMethod "syncValues" o = ControlBindingSyncValuesMethodInfo
    ResolveControlBindingMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveControlBindingMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolveControlBindingMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolveControlBindingMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveControlBindingMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolveControlBindingMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolveControlBindingMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveControlBindingMethod "getGValueArray" o = ControlBindingGetGValueArrayMethodInfo
    ResolveControlBindingMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
    ResolveControlBindingMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolveControlBindingMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolveControlBindingMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveControlBindingMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveControlBindingMethod "getValue" o = ControlBindingGetValueMethodInfo
    ResolveControlBindingMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolveControlBindingMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolveControlBindingMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolveControlBindingMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveControlBindingMethod "setDisabled" o = ControlBindingSetDisabledMethodInfo
    ResolveControlBindingMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolveControlBindingMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolveControlBindingMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveControlBindingMethod l o = O.MethodResolutionFailed l o

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

--- XXX Duplicated object with different types:
  --- Name {namespace = "Gst", name = "ControlBinding"} -> Property {propName = "name", propType = TBasicType TUTF8, propFlags = [PropertyReadable,PropertyWritable,PropertyConstructOnly], propReadNullable = Nothing, propWriteNullable = Nothing, propTransfer = TransferNothing, propDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, propDeprecated = Nothing}
  --- Name {namespace = "Gst", name = "Object"} -> Property {propName = "name", propType = TBasicType TUTF8, propFlags = [PropertyReadable,PropertyWritable,PropertyConstruct], propReadNullable = Nothing, propWriteNullable = Nothing, propTransfer = TransferNothing, propDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, propDeprecated = Nothing}
-- VVV Prop "name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@name@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' controlBinding #name
@
-}
getControlBindingName :: (MonadIO m, IsControlBinding o) => o -> m (Maybe T.Text)
getControlBindingName obj = liftIO $ B.Properties.getObjectPropertyString obj "name"

{- |
Construct a `GValueConstruct` with valid value for the “@name@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructControlBindingName :: (IsControlBinding o) => T.Text -> IO (GValueConstruct o)
constructControlBindingName val = B.Properties.constructObjectPropertyString "name" (Just val)

#if ENABLE_OVERLOADING
data ControlBindingNamePropertyInfo
instance AttrInfo ControlBindingNamePropertyInfo where
    type AttrAllowedOps ControlBindingNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ControlBindingNamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint ControlBindingNamePropertyInfo = IsControlBinding
    type AttrGetType ControlBindingNamePropertyInfo = (Maybe T.Text)
    type AttrLabel ControlBindingNamePropertyInfo = "name"
    type AttrOrigin ControlBindingNamePropertyInfo = ControlBinding
    attrGet _ = getControlBindingName
    attrSet _ = undefined
    attrConstruct _ = constructControlBindingName
    attrClear _ = undefined
#endif

-- VVV Prop "object"
   -- Type: TInterface (Name {namespace = "Gst", name = "Object"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@object@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' controlBinding #object
@
-}
getControlBindingObject :: (MonadIO m, IsControlBinding o) => o -> m (Maybe Gst.Object.Object)
getControlBindingObject obj = liftIO $ B.Properties.getObjectPropertyObject obj "object" Gst.Object.Object

{- |
Construct a `GValueConstruct` with valid value for the “@object@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructControlBindingObject :: (IsControlBinding o, Gst.Object.IsObject a) => a -> IO (GValueConstruct o)
constructControlBindingObject val = B.Properties.constructObjectPropertyObject "object" (Just val)

#if ENABLE_OVERLOADING
data ControlBindingObjectPropertyInfo
instance AttrInfo ControlBindingObjectPropertyInfo where
    type AttrAllowedOps ControlBindingObjectPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ControlBindingObjectPropertyInfo = Gst.Object.IsObject
    type AttrBaseTypeConstraint ControlBindingObjectPropertyInfo = IsControlBinding
    type AttrGetType ControlBindingObjectPropertyInfo = (Maybe Gst.Object.Object)
    type AttrLabel ControlBindingObjectPropertyInfo = "object"
    type AttrOrigin ControlBindingObjectPropertyInfo = ControlBinding
    attrGet _ = getControlBindingObject
    attrSet _ = undefined
    attrConstruct _ = constructControlBindingObject
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList ControlBinding
type instance O.AttributeList ControlBinding = ControlBindingAttributeList
type ControlBindingAttributeList = ('[ '("name", ControlBindingNamePropertyInfo), '("object", ControlBindingObjectPropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
controlBindingName :: AttrLabelProxy "name"
controlBindingName = AttrLabelProxy

controlBindingObject :: AttrLabelProxy "object"
controlBindingObject = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList ControlBinding = ControlBindingSignalList
type ControlBindingSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method ControlBinding::get_g_value_array
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "Gst", name = "ControlBinding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the control binding", 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 "the time that should be processed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the time spacing between subsequent values", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_values", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of values", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "values", argType = TCArray False (-1) 3 (TInterface (Name {namespace = "GObject", name = "Value"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "array to put control-values in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "n_values", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of values", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_control_binding_get_g_value_array" gst_control_binding_get_g_value_array ::
    Ptr ControlBinding ->                   -- binding : TInterface (Name {namespace = "Gst", name = "ControlBinding"})
    Word64 ->                               -- timestamp : TBasicType TUInt64
    Word64 ->                               -- interval : TBasicType TUInt64
    Word32 ->                               -- n_values : TBasicType TUInt
    Ptr GValue ->                           -- values : TCArray False (-1) 3 (TInterface (Name {namespace = "GObject", name = "Value"}))
    IO CInt

{- |
Gets a number of @/GValues/@ for the given controlled property starting at the
requested time. The array /@values@/ need to hold enough space for /@nValues@/ of
'GI.GObject.Structs.Value.Value'.

This function is useful if one wants to e.g. draw a graph of the control
curve or apply a control curve sample by sample.
-}
controlBindingGetGValueArray ::
    (B.CallStack.HasCallStack, MonadIO m, IsControlBinding a) =>
    a
    {- ^ /@binding@/: the control binding -}
    -> Word64
    {- ^ /@timestamp@/: the time that should be processed -}
    -> Word64
    {- ^ /@interval@/: the time spacing between subsequent values -}
    -> [GValue]
    {- ^ /@values@/: array to put control-values in -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the given array could be filled, 'False' otherwise -}
controlBindingGetGValueArray binding timestamp interval values = liftIO $ do
    let nValues = fromIntegral $ length values
    binding' <- unsafeManagedPtrCastPtr binding
    values' <- mapM unsafeManagedPtrGetPtr values
    values'' <- packBlockArray 24 values'
    result <- gst_control_binding_get_g_value_array binding' timestamp interval nValues values''
    let result' = (/= 0) result
    touchManagedPtr binding
    mapM_ touchManagedPtr values
    freeMem values''
    return result'

#if ENABLE_OVERLOADING
data ControlBindingGetGValueArrayMethodInfo
instance (signature ~ (Word64 -> Word64 -> [GValue] -> m Bool), MonadIO m, IsControlBinding a) => O.MethodInfo ControlBindingGetGValueArrayMethodInfo a signature where
    overloadedMethod _ = controlBindingGetGValueArray

#endif

-- method ControlBinding::get_value
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "Gst", name = "ControlBinding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the control binding", 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 "the time the control-change should be read from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Value"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_control_binding_get_value" gst_control_binding_get_value ::
    Ptr ControlBinding ->                   -- binding : TInterface (Name {namespace = "Gst", name = "ControlBinding"})
    Word64 ->                               -- timestamp : TBasicType TUInt64
    IO (Ptr GValue)

{- |
Gets the value for the given controlled property at the requested time.
-}
controlBindingGetValue ::
    (B.CallStack.HasCallStack, MonadIO m, IsControlBinding a) =>
    a
    {- ^ /@binding@/: the control binding -}
    -> Word64
    {- ^ /@timestamp@/: the time the control-change should be read from -}
    -> m (Maybe GValue)
    {- ^ __Returns:__ the GValue of the property at the given time,
or 'Nothing' if the property isn\'t controlled. -}
controlBindingGetValue binding timestamp = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- gst_control_binding_get_value binding' timestamp
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed GValue) result'
        return result''
    touchManagedPtr binding
    return maybeResult

#if ENABLE_OVERLOADING
data ControlBindingGetValueMethodInfo
instance (signature ~ (Word64 -> m (Maybe GValue)), MonadIO m, IsControlBinding a) => O.MethodInfo ControlBindingGetValueMethodInfo a signature where
    overloadedMethod _ = controlBindingGetValue

#endif

-- method ControlBinding::is_disabled
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "Gst", name = "ControlBinding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the control binding", 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_control_binding_is_disabled" gst_control_binding_is_disabled ::
    Ptr ControlBinding ->                   -- binding : TInterface (Name {namespace = "Gst", name = "ControlBinding"})
    IO CInt

{- |
Check if the control binding is disabled.
-}
controlBindingIsDisabled ::
    (B.CallStack.HasCallStack, MonadIO m, IsControlBinding a) =>
    a
    {- ^ /@binding@/: the control binding -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the binding is inactive -}
controlBindingIsDisabled binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- gst_control_binding_is_disabled binding'
    let result' = (/= 0) result
    touchManagedPtr binding
    return result'

#if ENABLE_OVERLOADING
data ControlBindingIsDisabledMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsControlBinding a) => O.MethodInfo ControlBindingIsDisabledMethodInfo a signature where
    overloadedMethod _ = controlBindingIsDisabled

#endif

-- method ControlBinding::set_disabled
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "Gst", name = "ControlBinding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the control binding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "disabled", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "boolean that specifies whether to disable the controller\nor not.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_control_binding_set_disabled" gst_control_binding_set_disabled ::
    Ptr ControlBinding ->                   -- binding : TInterface (Name {namespace = "Gst", name = "ControlBinding"})
    CInt ->                                 -- disabled : TBasicType TBoolean
    IO ()

{- |
This function is used to disable a control binding for some time, i.e.
'GI.Gst.Objects.Object.objectSyncValues' will do nothing.
-}
controlBindingSetDisabled ::
    (B.CallStack.HasCallStack, MonadIO m, IsControlBinding a) =>
    a
    {- ^ /@binding@/: the control binding -}
    -> Bool
    {- ^ /@disabled@/: boolean that specifies whether to disable the controller
or not. -}
    -> m ()
controlBindingSetDisabled binding disabled = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    let disabled' = (fromIntegral . fromEnum) disabled
    gst_control_binding_set_disabled binding' disabled'
    touchManagedPtr binding
    return ()

#if ENABLE_OVERLOADING
data ControlBindingSetDisabledMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsControlBinding a) => O.MethodInfo ControlBindingSetDisabledMethodInfo a signature where
    overloadedMethod _ = controlBindingSetDisabled

#endif

-- method ControlBinding::sync_values
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "Gst", name = "ControlBinding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the control binding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "object", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the object that has controlled properties", 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 "the time that should be processed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "last_sync", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the last time this was called", 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_control_binding_sync_values" gst_control_binding_sync_values ::
    Ptr ControlBinding ->                   -- binding : TInterface (Name {namespace = "Gst", name = "ControlBinding"})
    Ptr Gst.Object.Object ->                -- object : TInterface (Name {namespace = "Gst", name = "Object"})
    Word64 ->                               -- timestamp : TBasicType TUInt64
    Word64 ->                               -- last_sync : TBasicType TUInt64
    IO CInt

{- |
Sets the property of the /@object@/, according to the @/GstControlSources/@ that
handle them and for the given timestamp.

If this function fails, it is most likely the application developers fault.
Most probably the control sources are not setup correctly.
-}
controlBindingSyncValues ::
    (B.CallStack.HasCallStack, MonadIO m, IsControlBinding a, Gst.Object.IsObject b) =>
    a
    {- ^ /@binding@/: the control binding -}
    -> b
    {- ^ /@object@/: the object that has controlled properties -}
    -> Word64
    {- ^ /@timestamp@/: the time that should be processed -}
    -> Word64
    {- ^ /@lastSync@/: the last time this was called -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the controller value could be applied to the object
property, 'False' otherwise -}
controlBindingSyncValues binding object timestamp lastSync = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    object' <- unsafeManagedPtrCastPtr object
    result <- gst_control_binding_sync_values binding' object' timestamp lastSync
    let result' = (/= 0) result
    touchManagedPtr binding
    touchManagedPtr object
    return result'

#if ENABLE_OVERLOADING
data ControlBindingSyncValuesMethodInfo
instance (signature ~ (b -> Word64 -> Word64 -> m Bool), MonadIO m, IsControlBinding a, Gst.Object.IsObject b) => O.MethodInfo ControlBindingSyncValuesMethodInfo a signature where
    overloadedMethod _ = controlBindingSyncValues

#endif