18 Jun '13 - 08:38 *
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: WASAPI Crash at the end of a track if left alone to play  (Read 634 times)
pwatel
Posts: 48


« on: 24 Jan '12 - 06:07 »
Reply with quoteQuote

Hello
If all has been prepared the the device id, input stream, the WASAPI initialization:
To play a file is simply BASS_WASAPI_Start() and it plays

the problem if untended at the end of the track it crashes (big windows crash)
in BASS or BASSASIO the program not dies in the end but the music stops

Is there a way to have a notification without resorting to the loop in the example provided contest.exe
which has to check  BASS_ChannelIsActive(mixer) all the time taking a lot of resources and preventing the user to do other things
and I do not want to create thread for this.

Thank you regards
PW

Logged
Ian @ un4seen
Administrator
Posts: 15352


« Reply #1 on: 25 Jan '12 - 13:12 »
Reply with quoteQuote

Please post your WASAPIPROC function to have a look at. I suspect it may look something like this?

DWORD CALLBACK WASAPIPROC(void *buffer, DWORD length, void *user)
{
return BASS_ChannelGetData(decoder, buffer, length);
}

Note that BASS_ChannelGetData will return -1 when it reaches the end of the file, so you would need to check for that...

DWORD CALLBACK WASAPIPROC(void *buffer, DWORD length, void *user)
{
int r=BASS_ChannelGetData(decoder, buffer, length);
if (r==-1) return 0; // error = no data
return r;
}
Logged
pwatel
Posts: 48


« Reply #2 on: 25 Jan '12 - 15:23 »
Reply with quoteQuote

Here is my Callback - Do not give me too much credit , I copied yours from the example given I am learning wasapi I do not know yet what I am doing

  // ------------------------------------------------------------------------------
function WasapiProc(buffer: pointer; length: dword; user: pointer): dword;
  stdcall;
// ------------------------------------------------------------------------------
var
  c: dword;
begin
  c := Bass_ChannelGetData(oMusic, buffer, length);
  if (c = -1) then
    c := 0;
  Result := c;
end;

it could be that c is declared as dword which does not take negative values and therefore cannot trap for -1

Thanks regards
PW
« Last Edit: 25 Jan '12 - 15:25 by pwatel » Logged
Ian @ un4seen
Administrator
Posts: 15352


« Reply #3 on: 25 Jan '12 - 17:57 »
Reply with quoteQuote

In a 32-bit integer, -1 (signed) is the same thing as 4294967295 or 0xFFFFFFFF (unsigned). I'm not sure if Delphi will consider them the same, but you can use the DW_ERROR constant instead if not...

  if (c = DW_ERROR) then
Logged
pwatel
Posts: 48


« Reply #4 on: 27 Jan '12 - 03:50 »
Reply with quoteQuote

Delphi would not consider them the same
-1 does not exits for non negative integer in C you can get away with it but not in pascal
but I had replaced by c: longint and it works

I have tried  also DW_ERROR  with a c defined as Bass.dWord and it works.
thanks


« Last Edit: 27 Jan '12 - 04:20 by pwatel » Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines