                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 (proportion, diff, timestamp)
                    | otherwise = Nothing

eventParseSeek :: Event
               -> Maybe (Double, Format, [SeekFlags], SeekType, Int64, SeekType, Int64)
eventParseSeek event | eventType event == EventSeek =
    Just $ unsafePerformIO $ alloca $ \ratePtr ->
        alloca $ \formatPtr -> alloca $ \flagsPtr ->
            alloca $ \startTypePtr -> alloca $ \startPtr ->
                alloca $ \stopTypePtr -> alloca $ \stopPtr ->
                    do {# call event_parse_seek #} event
                                                   ratePtr
                                                   formatPtr
                                                   flagsPtr


{# context lib = "gstreamer" prefix = "gst" #}

eventType :: EventClass event
          => event
          -> EventType
eventType event =
    cToEnum $ unsafePerformIO $ withMiniObject (toEvent event) cEventType
foreign import ccall unsafe "_hs_gst_event_type"
    cEventType :: Ptr Event
               -> IO {# type GstEventType #}
