Internet stream download callback function.

void CALLBACK DownloadProc(
    const void *buffer,
    DWORD length,
    void *user


bufferPointer to the downloaded data... NULL = finished downloading.
lengthThe number of bytes in the buffer... 0 = HTTP or ICY tags.
userThe user instance data given when BASS_StreamCreateURL was called.


The callback will be called before the BASS_StreamCreateURL call returns (if it's successful), with the initial downloaded data. So any initialization (eg. creating the file if writing to disk) needs to be done either before the call, or in the callback function.

When the BASS_STREAM_STATUS flag is specified in the BASS_StreamCreateURL call, HTTP and ICY tags may be passed to the callback during connection, before any stream data is received. The tags are given exactly as would be returned by BASS_ChannelGetTags. You can distinguish between HTTP and ICY tags by checking what the first string starts with: "HTTP" or "ICY".

A download callback function could be used in conjunction with a BASS_SYNC_META sync set via BASS_ChannelSetSync to save individual tracks to disk from a Shoutcast stream.


Stream an MP3 file, and save a local copy.
FILE *file=NULL;
void CALLBACK MyDownloadProc(const void *buffer, DWORD length, void *user)
    if (!file) file=fopen("afile.mp3", "wb"); // create the file
    if (!buffer) fclose(file); // finished downloading
    else fwrite(buffer, 1, length, file);
HSTREAM stream=BASS_StreamCreateURL("", 0, 0, MyDownloadProc, 0);

See also