Author Topic: Question about streaming a file  (Read 5276 times)

Pit

  • Posts: 3
Question about streaming a file
« on: 12 Jul '03 - 12:21 »
I have a question about streaming a file:

For example, i have a 5 MB file. First 10 kb of this file is the executable(player). Second part - 4990kb - is the MP3 file. Question: how can i play the MP3 file?

I've tried to create a stream using BASS_StreamCreate with STREAMFILEPROC callback function, such as in example of STREAMFILEPROC in BASS documentation. All is fine, BUT!
My program now used ~5MB of memory(it depends of size of MP3 file), but if i try BASS_StreamCreateFile with this stand alone MP3 file it takes only ~500 kb. And i want to take RAM as less as possible.
Help, please! ???

P.S. I use VC++
« Last Edit: 12 Jul '03 - 12:23 by Pit »

Ian @ un4seen

  • Administrator
  • Posts: 26155
Re: Question about streaming a file
« Reply #1 on: 12 Jul '03 - 13:36 »
To minimize the memory usage of a custom file stream, you want to "stream the file in blocks" - return 0 in response to the BASS_FILE_LEN action in your STREAMFILEPROC.

Pit

  • Posts: 3
Re: Question about streaming a file
« Reply #2 on: 13 Jul '03 - 09:38 »
It works - memory usage is ~400kb.
But with this metod i can't get stream length and time.

Ian @ un4seen

  • Administrator
  • Posts: 26155
Re: Question about streaming a file
« Reply #3 on: 13 Jul '03 - 18:37 »
Yep. If you want to still be able to get the length, then you can use the BASS_STREAM_BLOCK flag in your BASS_StreamCreate call (instead of the above).

Pit

  • Posts: 3
Re: Question about streaming a file
« Reply #4 on: 13 Jul '03 - 23:10 »
Is the  BASS_STREAM_BLOCK flag in BASS_StreamCreate function "undocumented"? I can't find it in function description. When i use this flag memory usage is low, but i still can't get stream length, using BASS_StreamGetLength function - it returns zero. BASS_ChannelBytes2Seconds doesn't work correctly, too.

Ian @ un4seen

  • Administrator
  • Posts: 26155
Re: Question about streaming a file
« Reply #5 on: 13 Jul '03 - 23:30 »
Oops. Yep, I forgot, BASS doesn't estimate the length when using BASS_STREAM_BLOCK - it's primarily for internet streaming.

But, if I understand correctly what you're trying to do... you could simply use BASS_StreamCreateFile, passing the offset and length of the MP3 data in the "offset" and "length" parameters.