 
 {# 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 #}

    withTagList tagList ({# call event_new_tag #} . castPtr) >>=
        takeMiniObject

eventParseBufferSize :: Event
                     -> Maybe (Format, Int64, Int64, Bool)
eventParseBufferSize event | eventType event == EventBufferSize =
    Just $ unsafePerformIO $ alloca $ \formatPtr -> alloca $ \minSizePtr ->
        alloca $ \maxSizePtr -> alloca $ \asyncPtr ->
            do {# call event_parse_buffer_size #} event
                                                  formatPtr
                                                  minSizePtr
                                                  maxSizePtr

               return (proportion, diff, timestamp)
                    | otherwise = Nothing

eventParseSeek :: EventClass event
               => 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 #} (toEvent event)
                                                   ratePtr
                                                   formatPtr
                                                   flagsPtr
