Author Topic: About BASS_WASAPI_Init  (Read 234 times)

pzs7602

  • Posts: 80
About BASS_WASAPI_Init
« on: 27 Oct '22 - 05:35 »
My app use BASSWASAPI exclusive mode to play dsf in DoP mode in Windows, the app has a audio files list(with different dsd files in it) for continuous playing. When start playing, My code:
Code: [Select]
Bass.BASS_Init(...);  // init "no sound" device
stream = BassDsd.BASS_DSD_StreamCreateFile("test.dsf", 0, 0, BASSFlag.BASS_DSD_DOP | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE, 0);   // dsd audio in DoP mode
// get sample rate of the dsf file
BASS_CHANNELINFO ci;
ci = Bass.BASS_ChannelGetInfo(stream);
// Initializes a Wasapi device with specified sample rate
bool code = BassWasapi.BASS_WASAPI_Init(-1, ci.freq, ci.chans, BASSWASAPIInit.BASS_WASAPI_EXCLUSIVE, 0.4f, 0, _wasapiProc, user); // initialize the WASAPI output device
// Starts processing the current Wasapi device
code = BassWasapi.BASS_WASAPI_Start();

after the end of the first audio playing, my app respond to BASS_SYNC_END event in callback and start to play the next audio file, because the next audio file may have different sample rate, may be  BassWasapi.BASS_WASAPI_Init should be called again? but I know from this forum that:
Quote
Unfortunately, that is isn't currently possible. A device can only be initialized once at a time in BASSWASAPI, the same as in BASS.

So, I try to call BassDsd.BASS_DSD_StreamCreateFile with another dsf file and BassWasapi.BASS_WASAPI_Start (without invoking BassWasapi.BASS_WASAPI_Init again) but no sound played.
what's the right way to continuously play different dsd audios in dop mode with WASAPI in windows ?

Ian @ un4seen

  • Administrator
  • Posts: 24792
Re: About BASS_WASAPI_Init
« Reply #1 on: 27 Oct '22 - 12:22 »
You will need to reinitialize the device to change the sample format, ie. call BASS_WASAPI_Free and then BASS_WASAPI_Init again with the new format.

pzs7602

  • Posts: 80
Re: About BASS_WASAPI_Init
« Reply #2 on: 27 Oct '22 - 13:28 »
I call BassWasapi.BASS_WASAPI_Free in BASSSync.BASS_SYNC_END callback , but BASS_WASAPI_Free does not return(app hanged, find this by debugging). Do I need to call Bass.BASS_Free first or do something before calling BassWasapi.BASS_WASAPI_Free ?

Ian @ un4seen

  • Administrator
  • Posts: 24792
Re: About BASS_WASAPI_Init
« Reply #3 on: 27 Oct '22 - 16:27 »
You mustn't call BASS_WASAPI_Free within a WASAPIPROC callback, which is probably where the BASS_SYNC_END callback is currently running. Try adding the BASS_SYNC_THREAD flag to the BASS_ChannelSetSync call to move the sync's callback (and so BASS_WASAPI_Free call) to another thread.