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

                       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

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

eventParseQOS :: EventClass event
              => event
              -> Maybe (Double, ClockTimeDiff, ClockTime)
eventParseQOS event | eventType event == EventQOS =
    Just $ unsafePerformIO $ alloca $ \proportionPtr ->
        alloca $ \diffPtr -> alloca $ \timestampPtr ->
            do {# call event_parse_qos #} (toEvent event)
                                          proportionPtr
                                          diffPtr
                                          timestampPtr
