19 Jun '13 - 01:48 *
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: Restarting of channel fails  (Read 1496 times)
rogier21
Posts: 33


« on: 30 Apr '08 - 16:24 »
Reply with quoteQuote

I am having trouble with freeing a stream and re-creating it.

My simplified code:
function start();
begin
    Mixer := BASS_Mixer_StreamCreate(44100, 2, BASS_MIXER_NONSTOP or BASS_SAMPLE_FX or BASS_SAMPLE_FLOAT);
    if Mixer = 0 then
    begin
      ShowMessage("Failed to create!");
      Exit;
    end;
end;

function stop();
begin
  BASS_ChannelStop(Mixer);
  BASS_StreamFree(Mixer);
end;

If I call start first, it works fine, then I call stop, the mixer stops playing, BUT Mixer still has a handle assigned. If I call start again, it will fail with an unknown error (BASS_ERROR_UNKNOWN).

I have a bit trouble figuring out how to completely free a channel.
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #1 on: 1 May '08 - 13:38 »
Reply with quoteQuote

BASS_StreamFree will completely free the stream, but it won't/can't set your handle variable to 0; you need to do that yourself Smiley

  BASS_StreamFree(Mixer);
  Mixer := 0;
Logged
rogier21
Posts: 33


« Reply #2 on: 2 May '08 - 19:03 »
Reply with quoteQuote

Hello Ian, thanks your reply.

I tried doing this, but when I try to re-initialize the same handle, it gives me a unknown error.

So if I do with the code from my first post:
Start(); // fine
Stop(); // fine, I guess
Start(); // error?
Is there a step I forget the completely destroy a channel before able to re-initialize it?
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #3 on: 5 May '08 - 13:35 »
Reply with quoteQuote

That looks like it should be fine; the BASS_Mixer_StreamCreate call shouldn't be affected by any previously/currently existing streams anyway. When you say an "unknown error", do you mean BASS_ErrorGetCode is returning BASS_ERROR_UNKNOWN? If not, please check what it is returning.
Logged
rogier21
Posts: 33


« Reply #4 on: 13 May '08 - 20:23 »
Reply with quoteQuote

I checked again and fiddeled with it but I keep getting the BASS_ERROR_UNKNOWN error code back, and the handle will be unchanged and empty.

I have found out, if I change the output device it will create fine, but if I change it again to the 1 I already used it won't work. I dont have the source by hand now but I will give you an example Smiley
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines