Author Topic: Abborting BASS_StreamCreateURL  (Read 2573 times)

atza

  • Posts: 116
Abborting BASS_StreamCreateURL
« on: 9 Feb '11 - 08:16 »
Is it possible to abbort BASS_StreamCreateURL  procedure once it has started ?
From time to time I come across a link that take to long to load and it would be usefull to force-interrupt the procedure.
Conection timeout doesnt work,and I'm starting URL from another thread,so application doesn't freeze but createURL never ends,so I must restart application.
For example try this radio station:
http://www.gotradio.com/player/launch.asp?refer=web&id=64&cr=48

Station is accessible because it plays in other radio player software

atza

  • Posts: 116
Re: Abborting BASS_StreamCreateURL
« Reply #1 on: 10 Feb '11 - 07:47 »
No answer ?

fmcoder

  • Posts: 436
Re: Abborting BASS_StreamCreateURL
« Reply #2 on: 10 Feb '11 - 10:40 »
You're right calling it from another thread. But you shouldn't care if it returns or not at all.
In my app, a new thread is created for each call of BASS_StreamCreateURL, and the "old" thread(s) are marked as Terminated and they are destroyed when StreamCreateURL finally returns.
BTW it's not a good idea to call the TerminateThread to force termination of "old" threads... This allows very strange bugs happening in perspective :) - random access violations, etc.

atza

  • Posts: 116
Re: Abborting BASS_StreamCreateURL
« Reply #3 on: 10 Feb '11 - 14:42 »
Well ,I have to care ,because I have only one URL playing,(because of the nature of my application),and if it doesn't end I can't open new URL.

fmcoder

  • Posts: 436
Re: Abborting BASS_StreamCreateURL
« Reply #4 on: 11 Feb '11 - 10:23 »
Why that? You can have one BASS_StreamCreateURL call in one thread, and you can make another call to BASS_StreamCreateURL in another thread. Those calls are independent.
This is how it works in my app. When user wants to play an URL, a new thread is created and all work is done there (CreateURL, buffering, etc). This thread sends messages to UI thread, like how much is buffered and if stream is ready to be played. User may start another URL in any time, for example while previous stream is buffering or even it's still in BASS_StreamCreateURL - this doesn't make any difference.

atza

  • Posts: 116
Re: Abborting BASS_StreamCreateURL
« Reply #5 on: 11 Feb '11 - 15:17 »
Because it might start playing in any time later (i can't be sure what is going to happen)
So,I need to have just one stream active at any time

smodilo

  • Posts: 48
Re: Abborting BASS_StreamCreateURL
« Reply #6 on: 11 Feb '11 - 16:07 »
I have that same problem occasionally, so a solution would be great.

(Try to create a stream...doesn't work.... try another one... works ...  and all of a sudden the first one starts too).


Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: Abborting BASS_StreamCreateURL
« Reply #7 on: 11 Feb '11 - 17:34 »
To avoid that, you would need to signal the 1st thread that you want to cancel the stream creation, and have it discard (BASS_StreamFree) the stream if the BASS_StreamCreateURL call returns successfully. That cancellation signalling could be done via a member of a parameter structure passed to the thread...

Code: [Select]
// stream creation thread
HSTREAM stream=BASS_StreamCreateURL(param->url, ...); // open the URL
if (param->cancel) BASS_StreamFree(stream); // discard the stream

...

// main thread wanting to cancel the stream creation
param->cancel=1;