                return (format, minSize, maxSize, async)
                            | otherwise = Nothing
 
-eventParseLatency :: Event
+eventParseLatency :: EventClass event
+                  => event
                   -> Maybe ClockTime
 eventParseLatency event | eventType event == EventLatency =
     Just $ unsafePerformIO $ alloca $ \latencyPtr ->
-        do {# call event_parse_latency #} event
+        do {# call event_parse_latency #} (toEvent event)
                                           latencyPtr
            liftM fromIntegral $ peek latencyPtr
                         | otherwise = Nothing
 
-eventParseNewSegment :: Event
+eventParseNewSegment :: EventClass event
+                     => event
                      -> Maybe (Bool, Double, Format, Int64, Int64, Int64)
 eventParseNewSegment event | eventType event == EventNewSegment =
     Just $ unsafePerformIO $ alloca $ \updatePtr ->
         alloca $ \ratePtr -> alloca $ \formatPtr ->
             alloca $ \startPtr -> alloca $ \stopPtr ->
                 alloca $ \positionPtr ->
-                    do {# call event_parse_new_segment #} event
+                    do {# call event_parse_new_segment #} (toEvent event)
                                                           ratePtr
                                                           updatePtr
                                                           formatPtr

                       return (update, rate, format, start, stop, position)
                           | otherwise = Nothing

eventParseNewSegmentFull :: Event
                         -> Maybe (Bool, Double, Double, Format, Int64, Int64, Int64)
eventParseNewSegmentFull event | eventType event == EventNewSegment =
    Just $ unsafePerformIO $ alloca $ \updatePtr ->
        alloca $ \ratePtr -> alloca $ \appliedRatePtr ->
            alloca $ \formatPtr -> alloca $ \startPtr ->
                alloca $ \stopPtr -> alloca $ \positionPtr ->
                    do {# call event_parse_new_segment_full #} event
                                                               ratePtr
                                                               appliedRatePtr
                                                               updatePtr

--  available under LGPL Version 2. The documentation included with
--  this library is based on the original GStreamer documentation.
-- 
--  |
--  Maintainer  : gtk2hs-devel\@lists.sourceforge.net
--  Stability   : alpha
--  Portability : portable (depends on GHC)
--  
--  An object describing events that are passed up and down a pipeline.
module Media.Streaming.GStreamer.Core.Event (

-- * Detail

  -- | An 'Event' is a message that is passed up and down a pipeline.
  --   
  --   There are a number of predefined events and functions returning
  --   events. To send an event an application will usually use
  --   'Media.Streaming.GStreamer.Core.Element.elementSendEvent', and
  --   elements will use
  --   'Media.Streaming.GStreamer.Core.Pad.padSendEvent' or
  --   'Media.Streaming.GStreamer.Core.padPushEvent'.
  --   
  --   

-- * Types
  Event,
  EventClass,
  EventType(..),

-- * Event Operations
  eventType,
  eventNewCustom,
  eventNewEOS,
  eventNewFlushStart,
  eventNewFlushStop,
  eventNewLatency,
  eventNewNavigation,
  eventNewNewSegment,
  eventNewNewSegmentFull,
  eventNewQOS,
  eventNewSeek,
  eventNewTag,
  eventParseBufferSize,
  eventParseLatency,
  eventParseNewSegment,
  eventParseNewSegmentFull,
  eventParseQOS,
  eventParseSeek,
  eventParseTag,
  eventTypeGetName,
  eventTypeGetFlags,
  ) where


import Control.Monad (liftM)
{#import Media.Streaming.GStreamer.Core.Types#}
