SpiDetermineSyncMaster
Appearance
Determines the optimal master stream for a synchronization group based on hardware capabilities and timing granularity.
Syntax
#include <os2.h> ULONG SpiDetermineSyncMaster( PHSTREAM phstreamMaster, /* Returns best master handle */ PMASTER paMasterList, /* Array of candidate streams */ ULONG ulNumMasters /* Number of candidates */ );
Parameters
- phstreamMaster (PHSTREAM) - output
- Pointer to the variable that receives the handle of the determined master stream.
- paMasterList (PMASTER) - input
- Array of MASTER structures containing handles of candidate streams.
- ulNumMasters (ULONG) - input
- The count of elements in the paMasterList array.
Return Value
- rc
- (ULONG) Returns 0 (NO_ERROR) on success, otherwise:
- ERROR_INVALID_STREAM: One of the handles is invalid.
- ERROR_MASTER_CONFLICT: Multiple streams have incompatible master-only flags.
- ERROR_NO_MASTER: No streams in the list are capable of being a master.
- ERROR_NO_SYNC: Target stream does not support synchronization.
Remarks
The function selects the master by comparing the sync pulse granularity (mmtimeSync) defined in the SPCB of each candidate. The stream with the finest (lowest) granularity is chosen to ensure the highest precision for the slave streams.
Related Functions
Example
HSTREAM hMasterResult;
MASTER candidates[2];
candidates[0].hstreamMaster = hStreamAudio;
candidates[1].hstreamMaster = hStreamVideo;
if (!SpiDetermineSyncMaster(&hMasterResult, candidates, 2)) {
/* Use hMasterResult in SpiEnableSync */
}