Jump to content

SpiGetTime

From EDM2

The SpiGetTime function retrieves the current position of a stream, expressed in terms of stream time. This is the primary method for tracking playback or recording progress in an OS/2 Multimedia application.

Syntax

SpiGetTime(hstream, pmmtime)

Parameters

hstream (HSTREAM) - input
The handle of the stream for which the time is being queried.
pmmtime (PMMTIME) - in/out
A pointer to an MMTIME variable. On successful return, this variable contains the current stream time. The time is represented in units of **1/3000th of a second**.

Return Value

rc (ULONG) - returns
Return codes indicating success or the type of failure:
  • NO_ERROR: Success.
  • ERROR_INVALID_FUNCTION: Invalid function requested.
  • ERROR_INVALID_STREAM: The provided stream handle is not valid.
  • ERROR_INVALID_BLOCK: An invalid pointer was passed.
  • ERROR_QUERY_STREAM_TIME: Neither the source nor the target stream handler is capable of reporting stream time.
  • FAILURE: A stream handler-specific error occurred.

Remarks

In the context of the Sync/Stream Manager, **stream time** is functionally equivalent to **stream position**.

  • **Availability**: You can query the time for any stream that has been created, whether it is currently playing (active), paused, or stopped. This remains valid until SpiDestroyStream is called.
  • **Accuracy**: The accuracy of the time returned depends on the stream handler's ability to report its progress. Most hardware-backed handlers (like audio drivers) provide highly accurate timing.
  • **Units**: Because the unit is 1/3000th of a second, you can convert it to seconds by dividing the result by 3000.
  • **Changing Position**: To move the current pointer to a different time/position, use the SpiSeekStream function.

Example Code

The following example demonstrates how to query the current progress of a stream.

#include <os2.h>
#include <os2me.h>

ULONG   ulRC;     /* Error return code */
HSTREAM hStream;  /* Stream handle     */
MMTIME  mmtime;   /* Stream time       */

/* ... Stream is created and started via SpiStartStream ... */

/* Retrieve the current playback/record position */
ulRC = SpiGetTime(hStream, &mmtime);

if (ulRC == NO_ERROR) {
    /* 
     * Success! 
     * To get seconds: double seconds = (double)mmtime / 3000.0;
     */
} else {
    /* Handle error */
}

Related Functions

Related Messages

  • SHC_GET_TIME