Author Topic: BASS_StreamCreateURL() and saving the received stream  (Read 3352 times)

3delite

  • Posts: 895
Hi!

I want to save the received internet audio stream.
Call BASS_StreamCreateURL() with a specified callback function and works fine for a DI stream but fails with this one: http://download.pacebreaker.com/karolyi_-_Fall_of_2012_Chillout.m3u
The callback function is called only once and a file is created which always goes to and stays at 519KB.
The stream is correctly reported as 02:24:06.92 length and does play (left playing for 10 minutes) all the time but the callback function is only called once, at the start.
Additionally the file format is MP3 but BASS_CHANNELINFO.ctype is 66305 ($10301) = BASS_CTYPE_STREAM_WMA_MP3. What is the reason it's not detected as plain MP3?
This is the reason why the callback is not called?

Any help would be appreciated.

Ian @ un4seen

  • Administrator
  • Posts: 20400
That looks like BASS was unable to detect/handle it as an MP3 stream, but BASSWMA did detect it as MP3 and that's handling it instead. Unfortunately, the DOWNLOADPROC callback system doesn't work with BASSWMA because BASS isn't handling the download in that case, so that will be why your callback function doesn't get called. Trying the URL here (eg. with the NETRADIO example), BASS is handling it fine, so I'm not sure why that's not happening there. What BASS and Windows version are you using?

3delite

  • Posts: 895
I am trying on Windows XP SP3 and BASS 2.4.10.0.
I think the file that is created is only an 519KB ID3v2.2 tag (with cover art) and a little audio data.

Tried the netradio Delphi example, and it is reporting BASS_CHANNELINFO.ctype = BASS_CTYPE_STREAM_MP3 and starts buffering the whole 300MB file and the progress slowly advances without playing. Modified to buffer only 2% and then it is also playing fine.

What could be the reason that in my app. it switches to WMA mode? Some config options that I set or something!??? :-\

EDIT: A little better! Added the BASS_STREAM_BLOCK flag, and now it is saving the stream. Now it is identified as BASS_CTYPE_STREAM_MP3.
But this now means no seeking and also the bit rate calculation results 0?
If I comment out the LoadBASSPlugin('basswma.dll'); line then BASS_StreamCreateURL() completly fails, gives back 0. If I add the BASS_STREAM_BLOCK flag then reports BASS_CHANNELINFO.ctype = BASS_CTYPE_STREAM_MP3.

Also tryed specifying 0 as flags for BASS_StreamCreateURL(), no change.

Any ideas?

EDIT2: Not loading the WMA plugin, when BASS_StreamCreateURL() fails, BASS_ErrorGetCode returns BASS_ERROR_MEM.

EDIT3: Tried on Windows 7 64bit and there works. I have 3.25GB in XP, 4GB in Windows 7 and the file is  330MB. Could it be that BASS wants to allocate 330MB and it fails?
« Last Edit: 8 Mar '13 - 11:41 by 3delite »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Yes, that looks like BASS failed to allocate a block of memory to hold the downloaded file; when the BASS_STREAM_BLOCK flag isn't used (and the file length is known), then BASS will try to allocate a block of memory to hold the entire file. A 32-bit Windows process will have 2GB of address space available, so I think 330MB would usually be fine (eg. it's OK with the NETRADIO example), but in your app's case perhaps a bunch of memory blocks have already been allocated and that means there isn't a large enough continuous block available. 64-bit processes have a much larger address space available, hence no problem there.

3delite

  • Posts: 895
My app is allocating around 120MB, possibly this is causing problems. But there's at least 2GB free...
And running it on Windows 7 64bit was also a Win32 process. But that's good news it means at least works sometimes... :)

Anyway, my current solution is, if no advice, to put a 'BASS_STREAM_BLOCK' option when creating URL streams - so that they can be saved.

But not quite understand this, running the netradio example and looking at the task manager, it isn't allocating 330MB in one go but the memory usage is slowly increasing.
« Last Edit: 8 Mar '13 - 13:35 by 3delite »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Actually, thinking about it, the current NETRADIO example does use the BASS_STREAM_BLOCK flag in its BASS_StreamCreateURL calls but I think it didn't in the past, so perhaps you're using an old version of it? Anyway, if you don't need seeking (like the NETRADIO example doesn't), then I think it is generally a good idea to use the BASS_STREAM_BLOCK flag.

Regarding Task Manager, the "Mem Usage" column will be how much physical memory the process is using, but the memory block allocated for the download won't immediately use physical memory (that will happen as the download progresses). You can look at the "VM Size" column for the total allocated memory.

3delite

  • Posts: 895
Yes, probably a previous version, only BASS_STREAM_STATUS flag is specified.
And yes, you were right, 'VM Size' does show 340MB allocated.
It's sad that my app's reported 'VM Size' is 140MB and it can not allocate 330MB when I have 2GB free!? Is the memory so much fragmented?

But I thought that BASS doesn't allocate all that many bytes for an URL stream, just for the playback buffer and when seeking then seeks for the download position and continues downloading from there, or this isn't possible? I mean it's a bit silly allocating 300MB memory for a sound stream... whatever... :)

And yes I have a 'BASS_STREAM_BLOCK' option now in my app. But is it possible to calculate the bit rate in this case (no ICY header)?
« Last Edit: 8 Mar '13 - 15:26 by 3delite »

karolyi

  • Posts: 2
Hi!

I want to save the received internet audio stream.
Call BASS_StreamCreateURL() with a specified callback function and works fine for a DI stream but fails with this one: http://download.pacebreaker.com/karolyi_-_Fall_of_2012_Chillout.m3u
The callback function is called only once and a file is created which always goes to and stays at 519KB.
The stream is correctly reported as 02:24:06.92 length and does play (left playing for 10 minutes) all the time but the callback function is only called once, at the start.
Additionally the file format is MP3 but BASS_CHANNELINFO.ctype is 66305 ($10301) = BASS_CTYPE_STREAM_WMA_MP3. What is the reason it's not detected as plain MP3?
This is the reason why the callback is not called?

Any help would be appreciated.


Hi,

Well, thank you for your interest in my mix :) Why don't you just take the mp3 url and download it? You can reach it by downloading the m3u file and then opening it in a simple text editor, so you can see the original mix url :) But let me help you, the file you're seeking is:

http://download.pacebreaker.com/karolyi_-_Fall_of_2012_Chillout.mp3

The reason why BASS would fail to save the stream could be that i store the tracklist and albumart in the file, which could cause problems to stream savers when the file gets http streamed.

As always, any comments on it are appreciated :) Enjoy!

Cheers,
http://soundcloud.com/karolyi
« Last Edit: 8 Mar '13 - 17:36 by karolyi »

3delite

  • Posts: 895
Welcome to the un4seen forum!

Your files are ok, no problem there, we are just having software issues. :)

Nice music! I already downloaded 1 mix yesterday and one a couple of minutes ago with exactly the way you suggested. ;)

One thing I can comment on is that the files are tagged with an ID3v2.2 version tag. This version is obsolete now, ID3v2.3 and 2.4 are much more widely supported.

Thank you for the music! :)

karolyi

  • Posts: 2
Welcome to the un4seen forum!

Your files are ok, no problem there, we are just having software issues. :)

Nice music! I already downloaded 1 mix yesterday and one a couple of minutes ago with exactly the way you suggested. ;)

One thing I can comment on is that the files are tagged with an ID3v2.2 version tag. This version is obsolete now, ID3v2.3 and 2.4 are much more widely supported.

Thank you for the music! :)

You're welcome, more to come :)

I use iTunes to add the lyrics and artwork to them, so iTunes is the faulty one in this case :)