User defined output/input processing callback function.

    void *buffer,
    DWORD length,
    void *user


bufferPointer to the buffer to put the sample data for an output device, or to get the data from an input device. The sample data is always 32-bit floating-point.
lengthThe number of bytes to process.
userThe user instance data given when BASS_WASAPI_Init was called.

Return value

In the case of an output device, the number of bytes written to the buffer. If the value is negative (high bit set), it will be treated as 0. In the case of an input device, 0 = stop the device, else continue.


An output/input processing function should obviously be as quick as possible, to avoid buffer underruns (output) or overruns (input). Using a larger buffer makes that less crucial. BASS_WASAPI_GetData (BASS_DATA_AVAILABLE) can be used to check how much data is buffered.

If an output device has been initialized to use exclusive mode and less data than requested is returned, the remainder of the buffer will be filled with silence.

Do not call BASS_WASAPI_Free from within a callback function.

BASS_WASAPI_GetDevice can be used by the callback function to check which device it is dealing with.


Feed a BASS decoding channel to an output device, and stop the device at the end.
DWORD CALLBACK OutputWasapiProc(void *buffer, DWORD length, void *user)
    int c=BASS_ChannelGetData(decoder, buffer, length);
    if (c<0) { // at the end
        if (!BASS_WASAPI_GetData(NULL, BASS_DATA_AVAILABLE)) // check no buffered data remaining
            BASS_WASAPI_Stop(FALSE); // stop the output
        return 0;
    return c;

See also