FILEREADPROC callback

User file read callback function.

DWORD CALLBACK FileReadProc(
    void *buffer,
    DWORD length,
    void *user
);

Parameters

bufferPointer to the buffer to put the data in.
lengthMaximum number of bytes to read.
userThe user instance data given when BASS_StreamCreateFileUser was called, or returned by a FILEOPENPROC.

Return value

The number of bytes read... -1 = end of file, 0 = end of file (STREAMFILE_BUFFER file system only).

Remarks

When using the unbuffered file system (STREAMFILE_NOBUFFER), this function should try to return the requested amount of data during stream creation, but be as quick as possible during playback; it is better to return less data (even none) rather than wait for more because any delays can also affect the playback of other streams and MOD musics (this can be mitigated by using multiple update threads via the BASS_CONFIG_UPDATETHREADS option).

When using the buffered file systems, this function can just return whatever data is currently available. If there is none available but more is expected, then it should wait for some to become available. The function runs in its own thread in this case, so any delays will not affect other streams like with the unbuffered file system.

See also

BASS_StreamCreateFileUser, BASS_FILEPROCS structure