gi-gst-1.0.18: GI/Gst/Objects/Bus.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
The 'GI.Gst.Objects.Bus.Bus' is an object responsible for delivering 'GI.Gst.Structs.Message.Message' packets in
a first-in first-out way from the streaming threads (see 'GI.Gst.Objects.Task.Task') to the
application.
Since the application typically only wants to deal with delivery of these
messages from one thread, the GstBus will marshall the messages between
different threads. This is important since the actual streaming of media
is done in another thread than the application.
The GstBus provides support for 'GI.GLib.Structs.Source.Source' based notifications. This makes it
possible to handle the delivery in the glib mainloop.
The 'GI.GLib.Structs.Source.Source' callback function 'GI.Gst.Objects.Bus.busAsyncSignalFunc' can be used to
convert all bus messages into signal emissions.
A message is posted on the bus with the 'GI.Gst.Objects.Bus.busPost' method. With the
'GI.Gst.Objects.Bus.busPeek' and 'GI.Gst.Objects.Bus.busPop' methods one can look at or retrieve a
previously posted message.
The bus can be polled with the 'GI.Gst.Objects.Bus.busPoll' method. This methods blocks
up to the specified timeout value until one of the specified messages types
is posted on the bus. The application can then 'GI.Gst.Objects.Bus.busPop' the messages
from the bus to handle them.
Alternatively the application can register an asynchronous bus function
using 'GI.Gst.Objects.Bus.busAddWatch' or @/gst_bus_add_watch()/@. This function will
install a 'GI.GLib.Structs.Source.Source' in the default glib main loop and will deliver messages
a short while after they have been posted. Note that the main loop should
be running for the asynchronous callbacks.
It is also possible to get messages from the bus without any thread
marshalling with the 'GI.Gst.Objects.Bus.busSetSyncHandler' method. This makes it
possible to react to a message in the same thread that posted the
message on the bus. This should only be used if the application is able
to deal with messages from different threads.
Every 'GI.Gst.Objects.Pipeline.Pipeline' has one bus.
Note that a 'GI.Gst.Objects.Pipeline.Pipeline' will set its bus into flushing state when changing
from READY to NULL state.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gst.Objects.Bus
(
-- * Exported types
Bus(..) ,
IsBus ,
toBus ,
noBus ,
-- * Methods
-- ** addSignalWatch #method:addSignalWatch#
#if ENABLE_OVERLOADING
BusAddSignalWatchMethodInfo ,
#endif
busAddSignalWatch ,
-- ** addSignalWatchFull #method:addSignalWatchFull#
#if ENABLE_OVERLOADING
BusAddSignalWatchFullMethodInfo ,
#endif
busAddSignalWatchFull ,
-- ** addWatch #method:addWatch#
#if ENABLE_OVERLOADING
BusAddWatchMethodInfo ,
#endif
busAddWatch ,
-- ** asyncSignalFunc #method:asyncSignalFunc#
#if ENABLE_OVERLOADING
BusAsyncSignalFuncMethodInfo ,
#endif
busAsyncSignalFunc ,
-- ** createWatch #method:createWatch#
#if ENABLE_OVERLOADING
BusCreateWatchMethodInfo ,
#endif
busCreateWatch ,
-- ** disableSyncMessageEmission #method:disableSyncMessageEmission#
#if ENABLE_OVERLOADING
BusDisableSyncMessageEmissionMethodInfo ,
#endif
busDisableSyncMessageEmission ,
-- ** enableSyncMessageEmission #method:enableSyncMessageEmission#
#if ENABLE_OVERLOADING
BusEnableSyncMessageEmissionMethodInfo ,
#endif
busEnableSyncMessageEmission ,
-- ** getPollfd #method:getPollfd#
#if ENABLE_OVERLOADING
BusGetPollfdMethodInfo ,
#endif
busGetPollfd ,
-- ** havePending #method:havePending#
#if ENABLE_OVERLOADING
BusHavePendingMethodInfo ,
#endif
busHavePending ,
-- ** new #method:new#
busNew ,
-- ** peek #method:peek#
#if ENABLE_OVERLOADING
BusPeekMethodInfo ,
#endif
busPeek ,
-- ** poll #method:poll#
#if ENABLE_OVERLOADING
BusPollMethodInfo ,
#endif
busPoll ,
-- ** pop #method:pop#
#if ENABLE_OVERLOADING
BusPopMethodInfo ,
#endif
busPop ,
-- ** popFiltered #method:popFiltered#
#if ENABLE_OVERLOADING
BusPopFilteredMethodInfo ,
#endif
busPopFiltered ,
-- ** post #method:post#
#if ENABLE_OVERLOADING
BusPostMethodInfo ,
#endif
busPost ,
-- ** removeSignalWatch #method:removeSignalWatch#
#if ENABLE_OVERLOADING
BusRemoveSignalWatchMethodInfo ,
#endif
busRemoveSignalWatch ,
-- ** removeWatch #method:removeWatch#
#if ENABLE_OVERLOADING
BusRemoveWatchMethodInfo ,
#endif
busRemoveWatch ,
-- ** setFlushing #method:setFlushing#
#if ENABLE_OVERLOADING
BusSetFlushingMethodInfo ,
#endif
busSetFlushing ,
-- ** setSyncHandler #method:setSyncHandler#
#if ENABLE_OVERLOADING
BusSetSyncHandlerMethodInfo ,
#endif
busSetSyncHandler ,
-- ** syncSignalHandler #method:syncSignalHandler#
#if ENABLE_OVERLOADING
BusSyncSignalHandlerMethodInfo ,
#endif
busSyncSignalHandler ,
-- ** timedPop #method:timedPop#
#if ENABLE_OVERLOADING
BusTimedPopMethodInfo ,
#endif
busTimedPop ,
-- ** timedPopFiltered #method:timedPopFiltered#
#if ENABLE_OVERLOADING
BusTimedPopFilteredMethodInfo ,
#endif
busTimedPopFiltered ,
-- * Properties
-- ** enableAsync #attr:enableAsync#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
BusEnableAsyncPropertyInfo ,
#endif
#if ENABLE_OVERLOADING
busEnableAsync ,
#endif
constructBusEnableAsync ,
-- * Signals
-- ** message #signal:message#
BusMessageCallback ,
#if ENABLE_OVERLOADING
BusMessageSignalInfo ,
#endif
C_BusMessageCallback ,
afterBusMessage ,
genClosure_BusMessage ,
mk_BusMessageCallback ,
noBusMessageCallback ,
onBusMessage ,
wrap_BusMessageCallback ,
-- ** syncMessage #signal:syncMessage#
BusSyncMessageCallback ,
#if ENABLE_OVERLOADING
BusSyncMessageSignalInfo ,
#endif
C_BusSyncMessageCallback ,
afterBusSyncMessage ,
genClosure_BusSyncMessage ,
mk_BusSyncMessageCallback ,
noBusSyncMessageCallback ,
onBusSyncMessage ,
wrap_BusSyncMessageCallback ,
) 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.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Callbacks as Gst.Callbacks
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Flags as Gst.Flags
import {-# SOURCE #-} qualified GI.Gst.Objects.Object as Gst.Object
import {-# SOURCE #-} qualified GI.Gst.Structs.Message as Gst.Message
-- | Memory-managed wrapper type.
newtype Bus = Bus (ManagedPtr Bus)
foreign import ccall "gst_bus_get_type"
c_gst_bus_get_type :: IO GType
instance GObject Bus where
gobjectType = c_gst_bus_get_type
-- | Type class for types which can be safely cast to `Bus`, for instance with `toBus`.
class (GObject o, O.IsDescendantOf Bus o) => IsBus o
instance (GObject o, O.IsDescendantOf Bus o) => IsBus o
instance O.HasParentTypes Bus
type instance O.ParentTypes Bus = '[Gst.Object.Object, GObject.Object.Object]
-- | Cast to `Bus`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toBus :: (MonadIO m, IsBus o) => o -> m Bus
toBus = liftIO . unsafeCastTo Bus
-- | A convenience alias for `Nothing` :: `Maybe` `Bus`.
noBus :: Maybe Bus
noBus = Nothing
#if ENABLE_OVERLOADING
type family ResolveBusMethod (t :: Symbol) (o :: *) :: * where
ResolveBusMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
ResolveBusMethod "addSignalWatch" o = BusAddSignalWatchMethodInfo
ResolveBusMethod "addSignalWatchFull" o = BusAddSignalWatchFullMethodInfo
ResolveBusMethod "addWatch" o = BusAddWatchMethodInfo
ResolveBusMethod "asyncSignalFunc" o = BusAsyncSignalFuncMethodInfo
ResolveBusMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveBusMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveBusMethod "createWatch" o = BusCreateWatchMethodInfo
ResolveBusMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
ResolveBusMethod "disableSyncMessageEmission" o = BusDisableSyncMessageEmissionMethodInfo
ResolveBusMethod "enableSyncMessageEmission" o = BusEnableSyncMessageEmissionMethodInfo
ResolveBusMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveBusMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveBusMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveBusMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
ResolveBusMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
ResolveBusMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
ResolveBusMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
ResolveBusMethod "havePending" o = BusHavePendingMethodInfo
ResolveBusMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveBusMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveBusMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveBusMethod "peek" o = BusPeekMethodInfo
ResolveBusMethod "poll" o = BusPollMethodInfo
ResolveBusMethod "pop" o = BusPopMethodInfo
ResolveBusMethod "popFiltered" o = BusPopFilteredMethodInfo
ResolveBusMethod "post" o = BusPostMethodInfo
ResolveBusMethod "ref" o = Gst.Object.ObjectRefMethodInfo
ResolveBusMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveBusMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
ResolveBusMethod "removeSignalWatch" o = BusRemoveSignalWatchMethodInfo
ResolveBusMethod "removeWatch" o = BusRemoveWatchMethodInfo
ResolveBusMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveBusMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveBusMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveBusMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
ResolveBusMethod "syncSignalHandler" o = BusSyncSignalHandlerMethodInfo
ResolveBusMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
ResolveBusMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveBusMethod "timedPop" o = BusTimedPopMethodInfo
ResolveBusMethod "timedPopFiltered" o = BusTimedPopFilteredMethodInfo
ResolveBusMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
ResolveBusMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
ResolveBusMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveBusMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
ResolveBusMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
ResolveBusMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveBusMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
ResolveBusMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
ResolveBusMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
ResolveBusMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
ResolveBusMethod "getPollfd" o = BusGetPollfdMethodInfo
ResolveBusMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveBusMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveBusMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
ResolveBusMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
ResolveBusMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
ResolveBusMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
ResolveBusMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveBusMethod "setFlushing" o = BusSetFlushingMethodInfo
ResolveBusMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
ResolveBusMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
ResolveBusMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveBusMethod "setSyncHandler" o = BusSetSyncHandlerMethodInfo
ResolveBusMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveBusMethod t Bus, O.MethodInfo info Bus p) => OL.IsLabel t (Bus -> 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
-- signal Bus::message
{- |
A message has been posted on the bus. This signal is emitted from a
GSource added to the mainloop. this signal will only be emitted when
there is a mainloop running.
-}
type BusMessageCallback =
Gst.Message.Message
{- ^ /@message@/: the message that has been posted asynchronously -}
-> IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `BusMessageCallback`@.
noBusMessageCallback :: Maybe BusMessageCallback
noBusMessageCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_BusMessageCallback =
Ptr () -> -- object
Ptr Gst.Message.Message ->
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_BusMessageCallback`.
foreign import ccall "wrapper"
mk_BusMessageCallback :: C_BusMessageCallback -> IO (FunPtr C_BusMessageCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_BusMessage :: MonadIO m => BusMessageCallback -> m (GClosure C_BusMessageCallback)
genClosure_BusMessage cb = liftIO $ do
let cb' = wrap_BusMessageCallback cb
mk_BusMessageCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `BusMessageCallback` into a `C_BusMessageCallback`.
wrap_BusMessageCallback ::
BusMessageCallback ->
C_BusMessageCallback
wrap_BusMessageCallback _cb _ message _ = do
B.ManagedPtr.withTransient Gst.Message.Message message $ \message' -> do
_cb message'
{- |
Connect a signal handler for the “@message@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' bus #message callback
@
-}
onBusMessage :: (IsBus a, MonadIO m) => a -> BusMessageCallback -> m SignalHandlerId
onBusMessage obj cb = liftIO $ do
let cb' = wrap_BusMessageCallback cb
cb'' <- mk_BusMessageCallback cb'
connectSignalFunPtr obj "message" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@message@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' bus #message callback
@
-}
afterBusMessage :: (IsBus a, MonadIO m) => a -> BusMessageCallback -> m SignalHandlerId
afterBusMessage obj cb = liftIO $ do
let cb' = wrap_BusMessageCallback cb
cb'' <- mk_BusMessageCallback cb'
connectSignalFunPtr obj "message" cb'' SignalConnectAfter
-- signal Bus::sync-message
{- |
A message has been posted on the bus. This signal is emitted from the
thread that posted the message so one has to be careful with locking.
This signal will not be emitted by default, you have to call
'GI.Gst.Objects.Bus.busEnableSyncMessageEmission' before.
-}
type BusSyncMessageCallback =
Gst.Message.Message
{- ^ /@message@/: the message that has been posted synchronously -}
-> IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `BusSyncMessageCallback`@.
noBusSyncMessageCallback :: Maybe BusSyncMessageCallback
noBusSyncMessageCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_BusSyncMessageCallback =
Ptr () -> -- object
Ptr Gst.Message.Message ->
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_BusSyncMessageCallback`.
foreign import ccall "wrapper"
mk_BusSyncMessageCallback :: C_BusSyncMessageCallback -> IO (FunPtr C_BusSyncMessageCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_BusSyncMessage :: MonadIO m => BusSyncMessageCallback -> m (GClosure C_BusSyncMessageCallback)
genClosure_BusSyncMessage cb = liftIO $ do
let cb' = wrap_BusSyncMessageCallback cb
mk_BusSyncMessageCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `BusSyncMessageCallback` into a `C_BusSyncMessageCallback`.
wrap_BusSyncMessageCallback ::
BusSyncMessageCallback ->
C_BusSyncMessageCallback
wrap_BusSyncMessageCallback _cb _ message _ = do
B.ManagedPtr.withTransient Gst.Message.Message message $ \message' -> do
_cb message'
{- |
Connect a signal handler for the “@sync-message@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' bus #syncMessage callback
@
-}
onBusSyncMessage :: (IsBus a, MonadIO m) => a -> BusSyncMessageCallback -> m SignalHandlerId
onBusSyncMessage obj cb = liftIO $ do
let cb' = wrap_BusSyncMessageCallback cb
cb'' <- mk_BusSyncMessageCallback cb'
connectSignalFunPtr obj "sync-message" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@sync-message@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' bus #syncMessage callback
@
-}
afterBusSyncMessage :: (IsBus a, MonadIO m) => a -> BusSyncMessageCallback -> m SignalHandlerId
afterBusSyncMessage obj cb = liftIO $ do
let cb' = wrap_BusSyncMessageCallback cb
cb'' <- mk_BusSyncMessageCallback cb'
connectSignalFunPtr obj "sync-message" cb'' SignalConnectAfter
-- VVV Prop "enable-async"
-- Type: TBasicType TBoolean
-- Flags: [PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Construct a `GValueConstruct` with valid value for the “@enable-async@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructBusEnableAsync :: (IsBus o) => Bool -> IO (GValueConstruct o)
constructBusEnableAsync val = B.Properties.constructObjectPropertyBool "enable-async" val
#if ENABLE_OVERLOADING
data BusEnableAsyncPropertyInfo
instance AttrInfo BusEnableAsyncPropertyInfo where
type AttrAllowedOps BusEnableAsyncPropertyInfo = '[ 'AttrConstruct]
type AttrSetTypeConstraint BusEnableAsyncPropertyInfo = (~) Bool
type AttrBaseTypeConstraint BusEnableAsyncPropertyInfo = IsBus
type AttrGetType BusEnableAsyncPropertyInfo = ()
type AttrLabel BusEnableAsyncPropertyInfo = "enable-async"
type AttrOrigin BusEnableAsyncPropertyInfo = Bus
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructBusEnableAsync
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Bus
type instance O.AttributeList Bus = BusAttributeList
type BusAttributeList = ('[ '("enableAsync", BusEnableAsyncPropertyInfo), '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
busEnableAsync :: AttrLabelProxy "enableAsync"
busEnableAsync = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
data BusMessageSignalInfo
instance SignalInfo BusMessageSignalInfo where
type HaskellCallbackType BusMessageSignalInfo = BusMessageCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_BusMessageCallback cb
cb'' <- mk_BusMessageCallback cb'
connectSignalFunPtr obj "message" cb'' connectMode
data BusSyncMessageSignalInfo
instance SignalInfo BusSyncMessageSignalInfo where
type HaskellCallbackType BusSyncMessageSignalInfo = BusSyncMessageCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_BusSyncMessageCallback cb
cb'' <- mk_BusSyncMessageCallback cb'
connectSignalFunPtr obj "sync-message" cb'' connectMode
type instance O.SignalList Bus = BusSignalList
type BusSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("message", BusMessageSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("syncMessage", BusSyncMessageSignalInfo)] :: [(Symbol, *)])
#endif
-- method Bus::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Bus"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_new" gst_bus_new ::
IO (Ptr Bus)
{- |
Creates a new 'GI.Gst.Objects.Bus.Bus' instance.
-}
busNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Bus
{- ^ __Returns:__ a new 'GI.Gst.Objects.Bus.Bus' instance -}
busNew = liftIO $ do
result <- gst_bus_new
checkUnexpectedReturnNULL "busNew" result
result' <- (wrapObject Bus) result
return result'
#if ENABLE_OVERLOADING
#endif
-- method Bus::add_signal_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus on which you want to receive the \"message\" signal", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_add_signal_watch" gst_bus_add_signal_watch ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO ()
{- |
Adds a bus signal watch to the default main context with the default priority
('GI.GLib.Constants.PRIORITY_DEFAULT'). It is also possible to use a non-default
main context set up using 'GI.GLib.Structs.MainContext.mainContextPushThreadDefault' (before
one had to create a bus watch source and attach it to the desired main
context \'manually\').
After calling this statement, the bus will emit the \"message\" signal for each
message posted on the bus.
This function may be called multiple times. To clean up, the caller is
responsible for calling 'GI.Gst.Objects.Bus.busRemoveSignalWatch' as many times as this
function is called.
MT safe.
-}
busAddSignalWatch ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' on which you want to receive the \"message\" signal -}
-> m ()
busAddSignalWatch bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
gst_bus_add_signal_watch bus'
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusAddSignalWatchMethodInfo
instance (signature ~ (m ()), MonadIO m, IsBus a) => O.MethodInfo BusAddSignalWatchMethodInfo a signature where
overloadedMethod _ = busAddSignalWatch
#endif
-- method Bus::add_signal_watch_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus on which you want to receive the \"message\" signal", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The priority of the watch.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_add_signal_watch_full" gst_bus_add_signal_watch_full ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Int32 -> -- priority : TBasicType TInt
IO ()
{- |
Adds a bus signal watch to the default main context with the given /@priority@/
(e.g. 'GI.GLib.Constants.PRIORITY_DEFAULT'). It is also possible to use a non-default main
context set up using 'GI.GLib.Structs.MainContext.mainContextPushThreadDefault'
(before one had to create a bus watch source and attach it to the desired
main context \'manually\').
After calling this statement, the bus will emit the \"message\" signal for each
message posted on the bus when the main loop is running.
This function may be called multiple times. To clean up, the caller is
responsible for calling 'GI.Gst.Objects.Bus.busRemoveSignalWatch' as many times as this
function is called.
There can only be a single bus watch per bus, you must remove any signal
watch before you can set another type of watch.
MT safe.
-}
busAddSignalWatchFull ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' on which you want to receive the \"message\" signal -}
-> Int32
{- ^ /@priority@/: The priority of the watch. -}
-> m ()
busAddSignalWatchFull bus priority = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
gst_bus_add_signal_watch_full bus' priority
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusAddSignalWatchFullMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsBus a) => O.MethodInfo BusAddSignalWatchFullMethodInfo a signature where
overloadedMethod _ = busAddSignalWatchFull
#endif
-- method Bus::add_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to create the watch for.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The priority of the watch.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "BusFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A function to call when a message is received.", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @func.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call when the source is removed.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_add_watch_full" gst_bus_add_watch_full ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Int32 -> -- priority : TBasicType TInt
FunPtr Gst.Callbacks.C_BusFunc -> -- func : TInterface (Name {namespace = "Gst", name = "BusFunc"})
Ptr () -> -- user_data : TBasicType TPtr
FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
IO Word32
{- |
Adds a bus watch to the default main context with the given /@priority@/ (e.g.
'GI.GLib.Constants.PRIORITY_DEFAULT'). It is also possible to use a non-default main
context set up using 'GI.GLib.Structs.MainContext.mainContextPushThreadDefault' (before
one had to create a bus watch source and attach it to the desired main
context \'manually\').
This function is used to receive asynchronous messages in the main loop.
There can only be a single bus watch per bus, you must remove it before you
can set a new one.
The bus watch will only work if a GLib main loop is being run.
When /@func@/ is called, the message belongs to the caller; if you want to
keep a copy of it, call @/gst_message_ref()/@ before leaving /@func@/.
The watch can be removed using 'GI.Gst.Objects.Bus.busRemoveWatch' or by returning 'False'
from /@func@/. If the watch was added to the default main context it is also
possible to remove the watch using 'GI.GLib.Functions.sourceRemove'.
The bus watch will take its own reference to the /@bus@/, so it is safe to unref
/@bus@/ using 'GI.Gst.Objects.Object.objectUnref' after setting the bus watch.
MT safe.
-}
busAddWatch ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to create the watch for. -}
-> Int32
{- ^ /@priority@/: The priority of the watch. -}
-> Gst.Callbacks.BusFunc
{- ^ /@func@/: A function to call when a message is received. -}
-> m Word32
{- ^ __Returns:__ The event source id or 0 if /@bus@/ already got an event source. -}
busAddWatch bus priority func = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
func' <- Gst.Callbacks.mk_BusFunc (Gst.Callbacks.wrap_BusFunc Nothing (Gst.Callbacks.drop_closures_BusFunc func))
let userData = castFunPtrToPtr func'
let notify = safeFreeFunPtrPtr
result <- gst_bus_add_watch_full bus' priority func' userData notify
touchManagedPtr bus
return result
#if ENABLE_OVERLOADING
data BusAddWatchMethodInfo
instance (signature ~ (Int32 -> Gst.Callbacks.BusFunc -> m Word32), MonadIO m, IsBus a) => O.MethodInfo BusAddWatchMethodInfo a signature where
overloadedMethod _ = busAddWatch
#endif
-- method Bus::async_signal_func
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TInterface (Name {namespace = "Gst", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstMessage received", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", 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_bus_async_signal_func" gst_bus_async_signal_func ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Ptr Gst.Message.Message -> -- message : TInterface (Name {namespace = "Gst", name = "Message"})
Ptr () -> -- data : TBasicType TPtr
IO CInt
{- |
A helper 'GI.Gst.Callbacks.BusFunc' that can be used to convert all asynchronous messages
into signals.
-}
busAsyncSignalFunc ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' -}
-> Gst.Message.Message
{- ^ /@message@/: the 'GI.Gst.Structs.Message.Message' received -}
-> Ptr ()
{- ^ /@data@/: user data -}
-> m Bool
{- ^ __Returns:__ 'True' -}
busAsyncSignalFunc bus message data_ = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
message' <- unsafeManagedPtrGetPtr message
result <- gst_bus_async_signal_func bus' message' data_
let result' = (/= 0) result
touchManagedPtr bus
touchManagedPtr message
return result'
#if ENABLE_OVERLOADING
data BusAsyncSignalFuncMethodInfo
instance (signature ~ (Gst.Message.Message -> Ptr () -> m Bool), MonadIO m, IsBus a) => O.MethodInfo BusAsyncSignalFuncMethodInfo a signature where
overloadedMethod _ = busAsyncSignalFunc
#endif
-- method Bus::create_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to create the watch for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_create_watch" gst_bus_create_watch ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO (Ptr GLib.Source.Source)
{- |
Create watch for this bus. The GSource will be dispatched whenever
a message is on the bus. After the GSource is dispatched, the
message is popped off the bus and unreffed.
-}
busCreateWatch ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to create the watch for -}
-> m (Maybe GLib.Source.Source)
{- ^ __Returns:__ a 'GI.GLib.Structs.Source.Source' that can be added to a mainloop. -}
busCreateWatch bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
result <- gst_bus_create_watch bus'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed GLib.Source.Source) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusCreateWatchMethodInfo
instance (signature ~ (m (Maybe GLib.Source.Source)), MonadIO m, IsBus a) => O.MethodInfo BusCreateWatchMethodInfo a signature where
overloadedMethod _ = busCreateWatch
#endif
-- method Bus::disable_sync_message_emission
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus on which you previously called\ngst_bus_enable_sync_message_emission()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_disable_sync_message_emission" gst_bus_disable_sync_message_emission ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO ()
{- |
Instructs GStreamer to stop emitting the \"sync-message\" signal for this bus.
See 'GI.Gst.Objects.Bus.busEnableSyncMessageEmission' for more information.
In the event that multiple pieces of code have called
'GI.Gst.Objects.Bus.busEnableSyncMessageEmission', the sync-message emissions will only
be stopped after all calls to 'GI.Gst.Objects.Bus.busEnableSyncMessageEmission' were
\"cancelled\" by calling this function. In this way the semantics are exactly
the same as 'GI.Gst.Objects.Object.objectRef' that which calls enable should also call
disable.
MT safe.
-}
busDisableSyncMessageEmission ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' on which you previously called
'GI.Gst.Objects.Bus.busEnableSyncMessageEmission' -}
-> m ()
busDisableSyncMessageEmission bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
gst_bus_disable_sync_message_emission bus'
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusDisableSyncMessageEmissionMethodInfo
instance (signature ~ (m ()), MonadIO m, IsBus a) => O.MethodInfo BusDisableSyncMessageEmissionMethodInfo a signature where
overloadedMethod _ = busDisableSyncMessageEmission
#endif
-- method Bus::enable_sync_message_emission
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus on which you want to receive the \"sync-message\" signal", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_enable_sync_message_emission" gst_bus_enable_sync_message_emission ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO ()
{- |
Instructs GStreamer to emit the \"sync-message\" signal after running the bus\'s
sync handler. This function is here so that code can ensure that they can
synchronously receive messages without having to affect what the bin\'s sync
handler is.
This function may be called multiple times. To clean up, the caller is
responsible for calling 'GI.Gst.Objects.Bus.busDisableSyncMessageEmission' as many times
as this function is called.
While this function looks similar to 'GI.Gst.Objects.Bus.busAddSignalWatch', it is not
exactly the same -- this function enables \<emphasis>synchronous\<\/emphasis> emission of
signals when messages arrive; 'GI.Gst.Objects.Bus.busAddSignalWatch' adds an idle callback
to pop messages off the bus \<emphasis>asynchronously\<\/emphasis>. The sync-message signal
comes from the thread of whatever object posted the message; the \"message\"
signal is marshalled to the main thread via the main loop.
MT safe.
-}
busEnableSyncMessageEmission ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' on which you want to receive the \"sync-message\" signal -}
-> m ()
busEnableSyncMessageEmission bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
gst_bus_enable_sync_message_emission bus'
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusEnableSyncMessageEmissionMethodInfo
instance (signature ~ (m ()), MonadIO m, IsBus a) => O.MethodInfo BusEnableSyncMessageEmissionMethodInfo a signature where
overloadedMethod _ = busEnableSyncMessageEmission
#endif
-- method Bus::get_pollfd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstBus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "GLib", name = "PollFD"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A GPollFD to fill", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_get_pollfd" gst_bus_get_pollfd ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Ptr GLib.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "GLib", name = "PollFD"})
IO ()
{- |
Gets the file descriptor from the bus which can be used to get notified about
messages being available with functions like 'GI.GLib.Functions.poll', and allows integration
into other event loops based on file descriptors.
Whenever a message is available, the POLLIN \/ 'GI.GLib.Flags.IOConditionIn' event is set.
Warning: NEVER read or write anything to the returned fd but only use it
for getting notifications via 'GI.GLib.Functions.poll' or similar and then use the normal
GstBus API, e.g. 'GI.Gst.Objects.Bus.busPop'.
/Since: 1.14/
-}
busGetPollfd ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: A 'GI.Gst.Objects.Bus.Bus' -}
-> m (GLib.PollFD.PollFD)
busGetPollfd bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
fd <- callocBoxedBytes 8 :: IO (Ptr GLib.PollFD.PollFD)
gst_bus_get_pollfd bus' fd
fd' <- (wrapBoxed GLib.PollFD.PollFD) fd
touchManagedPtr bus
return fd'
#if ENABLE_OVERLOADING
data BusGetPollfdMethodInfo
instance (signature ~ (m (GLib.PollFD.PollFD)), MonadIO m, IsBus a) => O.MethodInfo BusGetPollfdMethodInfo a signature where
overloadedMethod _ = busGetPollfd
#endif
-- method Bus::have_pending
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus 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_bus_have_pending" gst_bus_have_pending ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO CInt
{- |
Check if there are pending messages on the bus that
should be handled.
-}
busHavePending ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to check -}
-> m Bool
{- ^ __Returns:__ 'True' if there are messages on the bus to be handled, 'False'
otherwise.
MT safe. -}
busHavePending bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
result <- gst_bus_have_pending bus'
let result' = (/= 0) result
touchManagedPtr bus
return result'
#if ENABLE_OVERLOADING
data BusHavePendingMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsBus a) => O.MethodInfo BusHavePendingMethodInfo a signature where
overloadedMethod _ = busHavePending
#endif
-- method Bus::peek
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_peek" gst_bus_peek ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO (Ptr Gst.Message.Message)
{- |
Peek the message on the top of the bus\' queue. The message will remain
on the bus\' message queue. A reference is returned, and needs to be unreffed
by the caller.
-}
busPeek ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' -}
-> m (Maybe Gst.Message.Message)
{- ^ __Returns:__ the 'GI.Gst.Structs.Message.Message' that is on the
bus, or 'Nothing' if the bus is empty.
MT safe. -}
busPeek bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
result <- gst_bus_peek bus'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed Gst.Message.Message) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusPeekMethodInfo
instance (signature ~ (m (Maybe Gst.Message.Message)), MonadIO m, IsBus a) => O.MethodInfo BusPeekMethodInfo a signature where
overloadedMethod _ = busPeek
#endif
-- method Bus::poll
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "events", argType = TInterface (Name {namespace = "Gst", name = "MessageType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a mask of #GstMessageType, representing the set of message types to\npoll for (note special handling of extended message types below)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the poll timeout, as a #GstClockTime, or #GST_CLOCK_TIME_NONE to poll\nindefinitely.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_poll" gst_bus_poll ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
CUInt -> -- events : TInterface (Name {namespace = "Gst", name = "MessageType"})
Word64 -> -- timeout : TBasicType TUInt64
IO (Ptr Gst.Message.Message)
{- |
Poll the bus for messages. Will block while waiting for messages to come.
You can specify a maximum time to poll with the /@timeout@/ parameter. If
/@timeout@/ is negative, this function will block indefinitely.
All messages not in /@events@/ will be popped off the bus and will be ignored.
It is not possible to use message enums beyond @/GST_MESSAGE_EXTENDED/@ in the
/@events@/ mask
Because poll is implemented using the \"message\" signal enabled by
'GI.Gst.Objects.Bus.busAddSignalWatch', calling 'GI.Gst.Objects.Bus.busPoll' will cause the \"message\"
signal to be emitted for every message that poll sees. Thus a \"message\"
signal handler will see the same messages that this function sees -- neither
will steal messages from the other.
This function will run a main loop from the default main context when
polling.
You should never use this function, since it is pure evil. This is
especially true for GUI applications based on Gtk+ or Qt, but also for any
other non-trivial application that uses the GLib main loop. As this function
runs a GLib main loop, any callback attached to the default GLib main
context may be invoked. This could be timeouts, GUI events, I\/O events etc.;
even if 'GI.Gst.Objects.Bus.busPoll' is called with a 0 timeout. Any of these callbacks
may do things you do not expect, e.g. destroy the main application window or
some other resource; change other application state; display a dialog and
run another main loop until the user clicks it away. In short, using this
function may add a lot of complexity to your code through unexpected
re-entrancy and unexpected changes to your application\'s state.
For 0 timeouts use 'GI.Gst.Objects.Bus.busPopFiltered' instead of this function; for
other short timeouts use 'GI.Gst.Objects.Bus.busTimedPopFiltered'; everything else is
better handled by setting up an asynchronous bus watch and doing things
from there.
-}
busPoll ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' -}
-> [Gst.Flags.MessageType]
{- ^ /@events@/: a mask of 'GI.Gst.Flags.MessageType', representing the set of message types to
poll for (note special handling of extended message types below) -}
-> Word64
{- ^ /@timeout@/: the poll timeout, as a @/GstClockTime/@, or 'GI.Gst.Constants.CLOCK_TIME_NONE' to poll
indefinitely. -}
-> m (Maybe Gst.Message.Message)
{- ^ __Returns:__ the message that was received,
or 'Nothing' if the poll timed out. The message is taken from the
bus and needs to be unreffed with @/gst_message_unref()/@ after
usage. -}
busPoll bus events timeout = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
let events' = gflagsToWord events
result <- gst_bus_poll bus' events' timeout
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed Gst.Message.Message) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusPollMethodInfo
instance (signature ~ ([Gst.Flags.MessageType] -> Word64 -> m (Maybe Gst.Message.Message)), MonadIO m, IsBus a) => O.MethodInfo BusPollMethodInfo a signature where
overloadedMethod _ = busPoll
#endif
-- method Bus::pop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to pop", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_pop" gst_bus_pop ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO (Ptr Gst.Message.Message)
{- |
Get a message from the bus.
-}
busPop ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to pop -}
-> m (Maybe Gst.Message.Message)
{- ^ __Returns:__ the 'GI.Gst.Structs.Message.Message' that is on the
bus, or 'Nothing' if the bus is empty. The message is taken from
the bus and needs to be unreffed with @/gst_message_unref()/@ after
usage.
MT safe. -}
busPop bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
result <- gst_bus_pop bus'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed Gst.Message.Message) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusPopMethodInfo
instance (signature ~ (m (Maybe Gst.Message.Message)), MonadIO m, IsBus a) => O.MethodInfo BusPopMethodInfo a signature where
overloadedMethod _ = busPop
#endif
-- method Bus::pop_filtered
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to pop", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "types", argType = TInterface (Name {namespace = "Gst", name = "MessageType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "message types to take into account", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_pop_filtered" gst_bus_pop_filtered ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
CUInt -> -- types : TInterface (Name {namespace = "Gst", name = "MessageType"})
IO (Ptr Gst.Message.Message)
{- |
Get a message matching /@type@/ from the bus. Will discard all messages on
the bus that do not match /@type@/ and that have been posted before the first
message that does match /@type@/. If there is no message matching /@type@/ on
the bus, all messages will be discarded. It is not possible to use message
enums beyond @/GST_MESSAGE_EXTENDED/@ in the /@events@/ mask.
-}
busPopFiltered ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to pop -}
-> [Gst.Flags.MessageType]
{- ^ /@types@/: message types to take into account -}
-> m (Maybe Gst.Message.Message)
{- ^ __Returns:__ the next 'GI.Gst.Structs.Message.Message' matching
/@type@/ that is on the bus, or 'Nothing' if the bus is empty or there
is no message matching /@type@/. The message is taken from the bus
and needs to be unreffed with @/gst_message_unref()/@ after usage.
MT safe. -}
busPopFiltered bus types = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
let types' = gflagsToWord types
result <- gst_bus_pop_filtered bus' types'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed Gst.Message.Message) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusPopFilteredMethodInfo
instance (signature ~ ([Gst.Flags.MessageType] -> m (Maybe Gst.Message.Message)), MonadIO m, IsBus a) => O.MethodInfo BusPopFilteredMethodInfo a signature where
overloadedMethod _ = busPopFiltered
#endif
-- method Bus::post
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to post on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TInterface (Name {namespace = "Gst", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstMessage to post", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_post" gst_bus_post ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Ptr Gst.Message.Message -> -- message : TInterface (Name {namespace = "Gst", name = "Message"})
IO CInt
{- |
Post a message on the given bus. Ownership of the message
is taken by the bus.
-}
busPost ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to post on -}
-> Gst.Message.Message
{- ^ /@message@/: the 'GI.Gst.Structs.Message.Message' to post -}
-> m Bool
{- ^ __Returns:__ 'True' if the message could be posted, 'False' if the bus is flushing.
MT safe. -}
busPost bus message = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
message' <- B.ManagedPtr.disownBoxed message
result <- gst_bus_post bus' message'
let result' = (/= 0) result
touchManagedPtr bus
touchManagedPtr message
return result'
#if ENABLE_OVERLOADING
data BusPostMethodInfo
instance (signature ~ (Gst.Message.Message -> m Bool), MonadIO m, IsBus a) => O.MethodInfo BusPostMethodInfo a signature where
overloadedMethod _ = busPost
#endif
-- method Bus::remove_signal_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus you previously added a signal watch to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_remove_signal_watch" gst_bus_remove_signal_watch ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO ()
{- |
Removes a signal watch previously added with 'GI.Gst.Objects.Bus.busAddSignalWatch'.
MT safe.
-}
busRemoveSignalWatch ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' you previously added a signal watch to -}
-> m ()
busRemoveSignalWatch bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
gst_bus_remove_signal_watch bus'
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusRemoveSignalWatchMethodInfo
instance (signature ~ (m ()), MonadIO m, IsBus a) => O.MethodInfo BusRemoveSignalWatchMethodInfo a signature where
overloadedMethod _ = busRemoveSignalWatch
#endif
-- method Bus::remove_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to remove the watch from.", 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_bus_remove_watch" gst_bus_remove_watch ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
IO CInt
{- |
Removes an installed bus watch from /@bus@/.
/Since: 1.6/
-}
busRemoveWatch ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to remove the watch from. -}
-> m Bool
{- ^ __Returns:__ 'True' on success or 'False' if /@bus@/ has no event source. -}
busRemoveWatch bus = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
result <- gst_bus_remove_watch bus'
let result' = (/= 0) result
touchManagedPtr bus
return result'
#if ENABLE_OVERLOADING
data BusRemoveWatchMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsBus a) => O.MethodInfo BusRemoveWatchMethodInfo a signature where
overloadedMethod _ = busRemoveWatch
#endif
-- method Bus::set_flushing
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus", 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 "whether or not to flush the bus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_set_flushing" gst_bus_set_flushing ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
CInt -> -- flushing : TBasicType TBoolean
IO ()
{- |
If /@flushing@/, flush out and unref any messages queued in the bus. Releases
references to the message origin objects. Will flush future messages until
'GI.Gst.Objects.Bus.busSetFlushing' sets /@flushing@/ to 'False'.
MT safe.
-}
busSetFlushing ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' -}
-> Bool
{- ^ /@flushing@/: whether or not to flush the bus -}
-> m ()
busSetFlushing bus flushing = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
let flushing' = (fromIntegral . fromEnum) flushing
gst_bus_set_flushing bus' flushing'
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusSetFlushingMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsBus a) => O.MethodInfo BusSetFlushingMethodInfo a signature where
overloadedMethod _ = busSetFlushing
#endif
-- method Bus::set_sync_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to install the handler on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "BusSyncHandler"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "The handler function to install", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data that will be sent to the handler function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "called when @user_data becomes unused", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_set_sync_handler" gst_bus_set_sync_handler ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
FunPtr Gst.Callbacks.C_BusSyncHandler -> -- func : TInterface (Name {namespace = "Gst", name = "BusSyncHandler"})
Ptr () -> -- user_data : TBasicType TPtr
FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
IO ()
{- |
Sets the synchronous handler on the bus. The function will be called
every time a new message is posted on the bus. Note that the function
will be called in the same thread context as the posting object. This
function is usually only called by the creator of the bus. Applications
should handle messages asynchronously using the gst_bus watch and poll
functions.
You cannot replace an existing sync_handler. You can pass 'Nothing' to this
function, which will clear the existing handler.
-}
busSetSyncHandler ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to install the handler on -}
-> Maybe (Gst.Callbacks.BusSyncHandler)
{- ^ /@func@/: The handler function to install -}
-> m ()
busSetSyncHandler bus func = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
maybeFunc <- case func of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jFunc -> do
jFunc' <- Gst.Callbacks.mk_BusSyncHandler (Gst.Callbacks.wrap_BusSyncHandler Nothing (Gst.Callbacks.drop_closures_BusSyncHandler jFunc))
return jFunc'
let userData = castFunPtrToPtr maybeFunc
let notify = safeFreeFunPtrPtr
gst_bus_set_sync_handler bus' maybeFunc userData notify
touchManagedPtr bus
return ()
#if ENABLE_OVERLOADING
data BusSetSyncHandlerMethodInfo
instance (signature ~ (Maybe (Gst.Callbacks.BusSyncHandler) -> m ()), MonadIO m, IsBus a) => O.MethodInfo BusSetSyncHandlerMethodInfo a signature where
overloadedMethod _ = busSetSyncHandler
#endif
-- method Bus::sync_signal_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TInterface (Name {namespace = "Gst", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstMessage received", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "BusSyncReply"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_sync_signal_handler" gst_bus_sync_signal_handler ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Ptr Gst.Message.Message -> -- message : TInterface (Name {namespace = "Gst", name = "Message"})
Ptr () -> -- data : TBasicType TPtr
IO CUInt
{- |
A helper GstBusSyncHandler that can be used to convert all synchronous
messages into signals.
-}
busSyncSignalHandler ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' -}
-> Gst.Message.Message
{- ^ /@message@/: the 'GI.Gst.Structs.Message.Message' received -}
-> Ptr ()
{- ^ /@data@/: user data -}
-> m Gst.Enums.BusSyncReply
{- ^ __Returns:__ GST_BUS_PASS -}
busSyncSignalHandler bus message data_ = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
message' <- unsafeManagedPtrGetPtr message
result <- gst_bus_sync_signal_handler bus' message' data_
let result' = (toEnum . fromIntegral) result
touchManagedPtr bus
touchManagedPtr message
return result'
#if ENABLE_OVERLOADING
data BusSyncSignalHandlerMethodInfo
instance (signature ~ (Gst.Message.Message -> Ptr () -> m Gst.Enums.BusSyncReply), MonadIO m, IsBus a) => O.MethodInfo BusSyncSignalHandlerMethodInfo a signature where
overloadedMethod _ = busSyncSignalHandler
#endif
-- method Bus::timed_pop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to pop", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a timeout", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_timed_pop" gst_bus_timed_pop ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Word64 -> -- timeout : TBasicType TUInt64
IO (Ptr Gst.Message.Message)
{- |
Get a message from the bus, waiting up to the specified timeout.
If /@timeout@/ is 0, this function behaves like 'GI.Gst.Objects.Bus.busPop'. If /@timeout@/ is
'GI.Gst.Constants.CLOCK_TIME_NONE', this function will block forever until a message was
posted on the bus.
-}
busTimedPop ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to pop -}
-> Word64
{- ^ /@timeout@/: a timeout -}
-> m (Maybe Gst.Message.Message)
{- ^ __Returns:__ the 'GI.Gst.Structs.Message.Message' that is on the
bus after the specified timeout or 'Nothing' if the bus is empty
after the timeout expired. The message is taken from the bus
and needs to be unreffed with @/gst_message_unref()/@ after usage.
MT safe. -}
busTimedPop bus timeout = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
result <- gst_bus_timed_pop bus' timeout
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed Gst.Message.Message) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusTimedPopMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.Message.Message)), MonadIO m, IsBus a) => O.MethodInfo BusTimedPopMethodInfo a signature where
overloadedMethod _ = busTimedPop
#endif
-- method Bus::timed_pop_filtered
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBus to pop from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a timeout in nanoseconds, or GST_CLOCK_TIME_NONE to wait forever", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "types", argType = TInterface (Name {namespace = "Gst", name = "MessageType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "message types to take into account, GST_MESSAGE_ANY for any type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_bus_timed_pop_filtered" gst_bus_timed_pop_filtered ::
Ptr Bus -> -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
Word64 -> -- timeout : TBasicType TUInt64
CUInt -> -- types : TInterface (Name {namespace = "Gst", name = "MessageType"})
IO (Ptr Gst.Message.Message)
{- |
Get a message from the bus whose type matches the message type mask /@types@/,
waiting up to the specified timeout (and discarding any messages that do not
match the mask provided).
If /@timeout@/ is 0, this function behaves like 'GI.Gst.Objects.Bus.busPopFiltered'. If
/@timeout@/ is 'GI.Gst.Constants.CLOCK_TIME_NONE', this function will block forever until a
matching message was posted on the bus.
-}
busTimedPopFiltered ::
(B.CallStack.HasCallStack, MonadIO m, IsBus a) =>
a
{- ^ /@bus@/: a 'GI.Gst.Objects.Bus.Bus' to pop from -}
-> Word64
{- ^ /@timeout@/: a timeout in nanoseconds, or GST_CLOCK_TIME_NONE to wait forever -}
-> [Gst.Flags.MessageType]
{- ^ /@types@/: message types to take into account, GST_MESSAGE_ANY for any type -}
-> m (Maybe Gst.Message.Message)
{- ^ __Returns:__ a 'GI.Gst.Structs.Message.Message' matching the
filter in /@types@/, or 'Nothing' if no matching message was found on
the bus until the timeout expired. The message is taken from
the bus and needs to be unreffed with @/gst_message_unref()/@ after
usage.
MT safe. -}
busTimedPopFiltered bus timeout types = liftIO $ do
bus' <- unsafeManagedPtrCastPtr bus
let types' = gflagsToWord types
result <- gst_bus_timed_pop_filtered bus' timeout types'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed Gst.Message.Message) result'
return result''
touchManagedPtr bus
return maybeResult
#if ENABLE_OVERLOADING
data BusTimedPopFilteredMethodInfo
instance (signature ~ (Word64 -> [Gst.Flags.MessageType] -> m (Maybe Gst.Message.Message)), MonadIO m, IsBus a) => O.MethodInfo BusTimedPopFilteredMethodInfo a signature where
overloadedMethod _ = busTimedPopFiltered
#endif