                                           fromIntegral destVal)
                    else return Nothing
 
+-- | Query an element for its stream position.
 elementQueryPosition :: ElementClass element
-                     => element
-                     -> Format
-                     -> IO (Maybe (Format, Word64))
+                     => element -- ^ @element@ - the element to query
+                     -> Format  -- ^ @format@ - the format requested
+                     -> IO (Maybe (Format, Word64)) -- ^ the resulting format and value
 elementQueryPosition element format =
     alloca $ \formatPtr ->
         alloca $ \curPtr ->

  State(..),
  StateChange(..),
  StateChangeReturn(..),
  elementAddPad,
  elementGetPad,
  elementGetCompatiblePad,
  elementGetCompatiblePadTemplate,
  elementGetRequestPad,
  elementGetStaticPad,
  elementNoMorePads,
  elementReleaseRequestPad,
  elementRemovePad,
  elementIteratePads,

        {# call element_get_query_types #} (toElement element) >>=
            peekArray0 0

-- | Perform a query on the given element.
--   
--   For elements that don't implement a query handler, this function
--   forwards the query to a random srcpad or to the peer of a random
--   linked sinkpad of this element.
elementQuery :: (ElementClass element, QueryClass query)
             => element -- ^ @element@ - 
             -> query   -- ^ @query@ - 
             -> IO Bool -- ^ 'True' if the query could be performed
elementQuery element query =
    do query' <- {# call mini_object_copy #} (toMiniObject query) >>=
                    newForeignPtr_ . castPtr
       fmap toBool $ {# call element_query #} (toElement element) $ Query query'

-- | Query an element for the convertion of a value from one format to
--   another.
elementQueryConvert :: ElementClass element
                    => element -- ^ @element@ - the element to query
                    -> Format  -- ^ @srcFormat@ - the format to convert from
                    -> Int64   -- ^ @srcVal@ - the value to convert
                    -> Format  -- ^ @destFormat@ - the format to convert to
                    -> IO (Maybe (Format, Word64)) -- ^ the resulting format and value
elementQueryConvert element srcFormat srcVal destFormat =
    alloca $ \destFormatPtr ->
        alloca $ \destValPtr ->
            do poke destFormatPtr $ fromIntegral $ fromEnum destFormat
               success <- {# call element_query_convert #} (toElement element)
                                                       (fromIntegral $ fromEnum srcFormat)
                                                       (fromIntegral srcVal)
                                                       destFormatPtr
