22 May '13 - 04:34 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Stuttering audio when the network is not available!  (Read 589 times)
shuttle
Posts: 70


« on: 8 Feb '12 - 11:48 »
Reply with quoteQuote

This is a very serious problem: if my software is playing a network audio file (opened with BASS_StreamCreateFile) and the network goes down (even for a fraction of a second) or the PC where the file is located doens't respond (even for a fraction of a second), BASS starts looping the buffer for several minutes until it stops and in the meanwhile the software is freezed.
I already asked Ian but he says that Bass can not do anything to solve.
Anyone can help?
I tried with "winmm.dll" API and this does not happen.
Logged
Smoov
Posts: 12


« Reply #1 on: 8 Feb '12 - 13:30 »
Reply with quoteQuote

We have taken many steps in out software to try and address this solution.

- Currently if we can identify the audio/video is going to play, we make a local copy of the file in a temp directory we use for playback. Our player is smart enough to always look for a local copy before attempting network playback.

- We are also looking into (when time permits) trying to treat the file as a downloadable file and use the StreamCreateURL concept to produce an equivalent StreamCreateNetworkFile or StreamCreateDownloadFile call. The concepts are really the same.

Maybe Ian even has, can give ideas or could quickly produce us the same model functional call, that treats all files as if they are remote?

Ideally we would like the function to support; ftp, http, https, UNC, window drive mappings, external devices (thumb drives) ... The idea for us is once the file is downloaded we could loose connection with the device/location and play uninterrupted. We generally would like to put a cap on our buffer-size, so if we tried to play a 2.0 gig video file it doesn't use 2 gig of memory or 2 gig of temp hard drive space.  Until the files start reaching above 100 MB or so the memory and file storage are of little concern.

Then the steam itself would be localizing the file into memory or file cache, and managing the buffering for you.
Logged
shuttle
Posts: 70


« Reply #2 on: 8 Feb '12 - 16:55 »
Reply with quoteQuote

Hi Smoov!
Yes, I already used that method.

Thank you.

Logged
Smoov
Posts: 12


« Reply #3 on: 10 Feb '12 - 21:50 »
Reply with quoteQuote

Ian,

Any good advice how to accomplish such a task?

Quote
Ideally we would like the function to support; ftp, http, https, UNC, window drive mappings, external devices (thumb drives) ... The idea for us is once the file is downloaded we could loose connection with the device/location and play uninterrupted. We generally would like to put a cap on our buffer-size, so if we tried to play a 2.0 gig video file it doesn't use 2 gig of memory or 2 gig of temp hard drive space.  Until the files start reaching above 100 MB or so the memory and file storage are of little concern.

Could you maybe give us a blue print on what we would do to implement this?
Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #4 on: 13 Feb '12 - 15:32 »
Reply with quoteQuote

Regarding "downloading" network files to memory, you could use BASS_StreamCreateFileUser and the "buffered" file system (STREAMFILE_BUFFER) to implement that. BASS will download the file to memory as quickly as possible in the background, and if a network interruption does occur mid-read, the network might recover before playback reaches it, but if not, it will at least not block the decoder. Note the looping buffer/sound is caused by the file reading call getting stuck and blocking the decoder when using the "unbuffered" file system.

The stream's BASS_FILEPROCS functions could simply wrap the normal file reading functions. For example, something like this...

void CALLBACK MyFileCloseProc(void *user)
{
    fclose(user); // close the file
}

QWORD CALLBACK MyFileLenProc(void *user)
{
    struct stat s;
    fstat(fileno(user), &s);
    return s.st_size; // return the file length
}

DWORD CALLBACK MyFileReadProc(void *buffer, DWORD length, void *user)
{
    return fread(buffer, 1, length, user); // read from file
}

...

BASS_FILEPROCS fileprocs={MyFileCloseProc, MyFileLenProc, MyFileReadProc, NULL}; // callback table
FILE *file=fopen(filename, "rb"); // open the file
stream=BASS_StreamCreateFileUser(STREAMFILE_BUFFER, 0, &fileprocs, file); // create the stream
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines