{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gst.Objects.Allocator
(
Allocator(..) ,
IsAllocator ,
toAllocator ,
#if defined(ENABLE_OVERLOADING)
ResolveAllocatorMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
AllocatorAllocMethodInfo ,
#endif
allocatorAlloc ,
allocatorFind ,
#if defined(ENABLE_OVERLOADING)
AllocatorFreeMethodInfo ,
#endif
allocatorFree ,
allocatorRegister ,
#if defined(ENABLE_OVERLOADING)
AllocatorSetDefaultMethodInfo ,
#endif
allocatorSetDefault ,
) 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.BasicTypes as B.Types
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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
import {-# SOURCE #-} qualified GI.Gst.Structs.AllocationParams as Gst.AllocationParams
import {-# SOURCE #-} qualified GI.Gst.Structs.Memory as Gst.Memory
newtype Allocator = Allocator (SP.ManagedPtr Allocator)
deriving (Allocator -> Allocator -> Bool
(Allocator -> Allocator -> Bool)
-> (Allocator -> Allocator -> Bool) -> Eq Allocator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Allocator -> Allocator -> Bool
$c/= :: Allocator -> Allocator -> Bool
== :: Allocator -> Allocator -> Bool
$c== :: Allocator -> Allocator -> Bool
Eq)
instance SP.ManagedPtrNewtype Allocator where
toManagedPtr :: Allocator -> ManagedPtr Allocator
toManagedPtr (Allocator ManagedPtr Allocator
p) = ManagedPtr Allocator
p
foreign import ccall "gst_allocator_get_type"
c_gst_allocator_get_type :: IO B.Types.GType
instance B.Types.TypedObject Allocator where
glibType :: IO GType
glibType = IO GType
c_gst_allocator_get_type
instance B.Types.GObject Allocator
instance B.GValue.IsGValue Allocator where
toGValue :: Allocator -> IO GValue
toGValue Allocator
o = do
GType
gtype <- IO GType
c_gst_allocator_get_type
Allocator -> (Ptr Allocator -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Allocator
o (GType
-> (GValue -> Ptr Allocator -> IO ()) -> Ptr Allocator -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Allocator -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
fromGValue :: GValue -> IO Allocator
fromGValue GValue
gv = do
Ptr Allocator
ptr <- GValue -> IO (Ptr Allocator)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Allocator)
(ManagedPtr Allocator -> Allocator)
-> Ptr Allocator -> IO Allocator
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Allocator -> Allocator
Allocator Ptr Allocator
ptr
class (SP.GObject o, O.IsDescendantOf Allocator o) => IsAllocator o
instance (SP.GObject o, O.IsDescendantOf Allocator o) => IsAllocator o
instance O.HasParentTypes Allocator
type instance O.ParentTypes Allocator = '[Gst.Object.Object, GObject.Object.Object]
toAllocator :: (MonadIO m, IsAllocator o) => o -> m Allocator
toAllocator :: o -> m Allocator
toAllocator = IO Allocator -> m Allocator
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Allocator -> m Allocator)
-> (o -> IO Allocator) -> o -> m Allocator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Allocator -> Allocator) -> o -> IO Allocator
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Allocator -> Allocator
Allocator
#if defined(ENABLE_OVERLOADING)
type family ResolveAllocatorMethod (t :: Symbol) (o :: *) :: * where
ResolveAllocatorMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
ResolveAllocatorMethod "alloc" o = AllocatorAllocMethodInfo
ResolveAllocatorMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveAllocatorMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveAllocatorMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
ResolveAllocatorMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveAllocatorMethod "free" o = AllocatorFreeMethodInfo
ResolveAllocatorMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveAllocatorMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveAllocatorMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
ResolveAllocatorMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
ResolveAllocatorMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
ResolveAllocatorMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
ResolveAllocatorMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveAllocatorMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveAllocatorMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveAllocatorMethod "ref" o = Gst.Object.ObjectRefMethodInfo
ResolveAllocatorMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveAllocatorMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
ResolveAllocatorMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveAllocatorMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveAllocatorMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveAllocatorMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
ResolveAllocatorMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
ResolveAllocatorMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveAllocatorMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
ResolveAllocatorMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
ResolveAllocatorMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveAllocatorMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
ResolveAllocatorMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
ResolveAllocatorMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveAllocatorMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
ResolveAllocatorMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
ResolveAllocatorMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
ResolveAllocatorMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
ResolveAllocatorMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveAllocatorMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveAllocatorMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
ResolveAllocatorMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
ResolveAllocatorMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
ResolveAllocatorMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
ResolveAllocatorMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveAllocatorMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveAllocatorMethod "setDefault" o = AllocatorSetDefaultMethodInfo
ResolveAllocatorMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
ResolveAllocatorMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
ResolveAllocatorMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveAllocatorMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAllocatorMethod t Allocator, O.MethodInfo info Allocator p) => OL.IsLabel t (Allocator -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Allocator
type instance O.AttributeList Allocator = AllocatorAttributeList
type AllocatorAttributeList = ('[ '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Allocator = AllocatorSignalList
type AllocatorSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "gst_allocator_alloc" gst_allocator_alloc ::
Ptr Allocator ->
Word64 ->
Ptr Gst.AllocationParams.AllocationParams ->
IO (Ptr Gst.Memory.Memory)
allocatorAlloc ::
(B.CallStack.HasCallStack, MonadIO m, IsAllocator a) =>
a
-> Word64
-> Maybe (Gst.AllocationParams.AllocationParams)
-> m (Maybe Gst.Memory.Memory)
allocatorAlloc :: a -> Word64 -> Maybe AllocationParams -> m (Maybe Memory)
allocatorAlloc a
allocator Word64
size Maybe AllocationParams
params = IO (Maybe Memory) -> m (Maybe Memory)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Memory) -> m (Maybe Memory))
-> IO (Maybe Memory) -> m (Maybe Memory)
forall a b. (a -> b) -> a -> b
$ do
Ptr Allocator
allocator' <- a -> IO (Ptr Allocator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
allocator
Ptr AllocationParams
maybeParams <- case Maybe AllocationParams
params of
Maybe AllocationParams
Nothing -> Ptr AllocationParams -> IO (Ptr AllocationParams)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr AllocationParams
forall a. Ptr a
nullPtr
Just AllocationParams
jParams -> do
Ptr AllocationParams
jParams' <- AllocationParams -> IO (Ptr AllocationParams)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AllocationParams
jParams
Ptr AllocationParams -> IO (Ptr AllocationParams)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr AllocationParams
jParams'
Ptr Memory
result <- Ptr Allocator -> Word64 -> Ptr AllocationParams -> IO (Ptr Memory)
gst_allocator_alloc Ptr Allocator
allocator' Word64
size Ptr AllocationParams
maybeParams
Maybe Memory
maybeResult <- Ptr Memory -> (Ptr Memory -> IO Memory) -> IO (Maybe Memory)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Memory
result ((Ptr Memory -> IO Memory) -> IO (Maybe Memory))
-> (Ptr Memory -> IO Memory) -> IO (Maybe Memory)
forall a b. (a -> b) -> a -> b
$ \Ptr Memory
result' -> do
Memory
result'' <- ((ManagedPtr Memory -> Memory) -> Ptr Memory -> IO Memory
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Memory -> Memory
Gst.Memory.Memory) Ptr Memory
result'
Memory -> IO Memory
forall (m :: * -> *) a. Monad m => a -> m a
return Memory
result''
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
allocator
Maybe AllocationParams -> (AllocationParams -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe AllocationParams
params AllocationParams -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Maybe Memory -> IO (Maybe Memory)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Memory
maybeResult
#if defined(ENABLE_OVERLOADING)
data AllocatorAllocMethodInfo
instance (signature ~ (Word64 -> Maybe (Gst.AllocationParams.AllocationParams) -> m (Maybe Gst.Memory.Memory)), MonadIO m, IsAllocator a) => O.MethodInfo AllocatorAllocMethodInfo a signature where
overloadedMethod = allocatorAlloc
#endif
foreign import ccall "gst_allocator_free" gst_allocator_free ::
Ptr Allocator ->
Ptr Gst.Memory.Memory ->
IO ()
allocatorFree ::
(B.CallStack.HasCallStack, MonadIO m, IsAllocator a) =>
a
-> Gst.Memory.Memory
-> m ()
allocatorFree :: a -> Memory -> m ()
allocatorFree a
allocator Memory
memory = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Allocator
allocator' <- a -> IO (Ptr Allocator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
allocator
Ptr Memory
memory' <- Memory -> IO (Ptr Memory)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Memory
memory
Ptr Allocator -> Ptr Memory -> IO ()
gst_allocator_free Ptr Allocator
allocator' Ptr Memory
memory'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
allocator
Memory -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Memory
memory
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data AllocatorFreeMethodInfo
instance (signature ~ (Gst.Memory.Memory -> m ()), MonadIO m, IsAllocator a) => O.MethodInfo AllocatorFreeMethodInfo a signature where
overloadedMethod = allocatorFree
#endif
foreign import ccall "gst_allocator_set_default" gst_allocator_set_default ::
Ptr Allocator ->
IO ()
allocatorSetDefault ::
(B.CallStack.HasCallStack, MonadIO m, IsAllocator a) =>
a
-> m ()
allocatorSetDefault :: a -> m ()
allocatorSetDefault a
allocator = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Allocator
allocator' <- a -> IO (Ptr Allocator)
forall a b. (HasCallStack, GObject a) => a -> IO (Ptr b)
B.ManagedPtr.disownObject a
allocator
Ptr Allocator -> IO ()
gst_allocator_set_default Ptr Allocator
allocator'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
allocator
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data AllocatorSetDefaultMethodInfo
instance (signature ~ (m ()), MonadIO m, IsAllocator a) => O.MethodInfo AllocatorSetDefaultMethodInfo a signature where
overloadedMethod = allocatorSetDefault
#endif
foreign import ccall "gst_allocator_find" gst_allocator_find ::
CString ->
IO (Ptr Allocator)
allocatorFind ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe (T.Text)
-> m (Maybe Allocator)
allocatorFind :: Maybe Text -> m (Maybe Allocator)
allocatorFind Maybe Text
name = IO (Maybe Allocator) -> m (Maybe Allocator)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Allocator) -> m (Maybe Allocator))
-> IO (Maybe Allocator) -> m (Maybe Allocator)
forall a b. (a -> b) -> a -> b
$ do
Ptr CChar
maybeName <- case Maybe Text
name of
Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
Just Text
jName -> do
Ptr CChar
jName' <- Text -> IO (Ptr CChar)
textToCString Text
jName
Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jName'
Ptr Allocator
result <- Ptr CChar -> IO (Ptr Allocator)
gst_allocator_find Ptr CChar
maybeName
Maybe Allocator
maybeResult <- Ptr Allocator
-> (Ptr Allocator -> IO Allocator) -> IO (Maybe Allocator)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Allocator
result ((Ptr Allocator -> IO Allocator) -> IO (Maybe Allocator))
-> (Ptr Allocator -> IO Allocator) -> IO (Maybe Allocator)
forall a b. (a -> b) -> a -> b
$ \Ptr Allocator
result' -> do
Allocator
result'' <- ((ManagedPtr Allocator -> Allocator)
-> Ptr Allocator -> IO Allocator
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Allocator -> Allocator
Allocator) Ptr Allocator
result'
Allocator -> IO Allocator
forall (m :: * -> *) a. Monad m => a -> m a
return Allocator
result''
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeName
Maybe Allocator -> IO (Maybe Allocator)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Allocator
maybeResult
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "gst_allocator_register" gst_allocator_register ::
CString ->
Ptr Allocator ->
IO ()
allocatorRegister ::
(B.CallStack.HasCallStack, MonadIO m, IsAllocator a) =>
T.Text
-> a
-> m ()
allocatorRegister :: Text -> a -> m ()
allocatorRegister Text
name a
allocator = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr CChar
name' <- Text -> IO (Ptr CChar)
textToCString Text
name
Ptr Allocator
allocator' <- a -> IO (Ptr Allocator)
forall a b. (HasCallStack, GObject a) => a -> IO (Ptr b)
B.ManagedPtr.disownObject a
allocator
Ptr CChar -> Ptr Allocator -> IO ()
gst_allocator_register Ptr CChar
name' Ptr Allocator
allocator'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
allocator
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
name'
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
#endif