Author Topic: BASSWASAPI beta  (Read 154557 times)

Wishmaster

  • Posts: 149
Re: BASSWASAPI beta
« Reply #225 on: 2 Oct '12 - 08:24 »
hi
Quote
Does the problem happen even if you use the real device number that the "-2" device points to.
Yes!

i did some more testing and found that the first BASS_WASAPI_Init() will be stopped by the second  call  of BASS_WASAPI_Init() 
and it does not matter whether it is an input or output;

so if I am doing it like this, it will not work!
Code: [Select]
// Init the Output Device
 BASS_WASAPI_Init(-1, 0, 0, DevFlag, 0.4, 0, @Output_Wasapi_Proc, Pointer(Self))
 BASS_WASAPI_Start();

 // Init the Input Device
 BASS_WASAPI_Init(-2, 0, 0, DevFlag, 1, 0.1, @Input_Wasapi_Proc, Pointer(Self))
 BASS_WASAPI_Start();



solution.

first i initialize both Input and Output! then i use BASS_WASAPI_SetDevice() with the real device number.
and finally I start the device with BASS_WASAPI_Start();


Code: [Select]
// Init the Output Device
 BASS_WASAPI_Init(-1, 0, 0, DevFlag, 0.4, 0, @Output_Wasapi_Proc, Pointer(Self))
 // Init the Input Device
 BASS_WASAPI_Init(-2, 0, 0, DevFlag, 1, 0.1, @Input_Wasapi_Proc, Pointer(Self))


Code: [Select]
// Start the Output Device
  BASS_WASAPI_SetDevice(26)
  BASS_WASAPI_Start();

 // Start the Input Device
  BASS_WASAPI_SetDevice(71)
  BASS_WASAPI_Start();

Smoov

  • Posts: 13
Re: BASSWASAPI beta
« Reply #226 on: 2 Oct '12 - 15:58 »
I was reading a post over in Re: Problem after upgrading from version 2.4.4 of BASS to version 2.4.6, and saw how bass had an issue with MMDEVAPI callball backs related to COM.

Ian have you pulled the device notification model from the basswasapi.dll as well?

I have verified if we try and dynamically use the basswasapi.dll to query available wasapi device, when we release the dll we sometime receive this MMDevAPI.dll crash..


This is the call stack of the dump..

>   MMDevAPI.dll!CDeviceEnumerator::OnDeviceStateChanged()  + 0x5b bytes   
    MMDevAPI.dll!CLocalEndpointEnumerator::OnMediaNotification()  + 0x4b29 bytes   
    MMDevAPI.dll!CMediaNotifications::OnMediaNotificationWorkerHandler()  - 0x2f bytes   
    MMDevAPI.dll!CMediaNotifications::MediaNotificationWorkerHandler()  + 0x10 bytes   
    ntdll.dll!_TppSimplepExecuteCallback@8()  + 0x7b bytes   
    ntdll.dll!_TppWorkerThread@4()  + 0x5a4 bytes   
    kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes   
    ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes   
    ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes   


Any suggestions how to address this issue?


PS. Do you have a release version of WASAPI yet?

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #227 on: 2 Oct '12 - 16:07 »
i did some more testing and found that the first BASS_WASAPI_Init() will be stopped by the second  call  of BASS_WASAPI_Init()  
and it does not matter whether it is an input or output;

Does it make a difference whether the 2 devices are on the same soundcard, ie. does the problem still happen if they are on separate soundcards? If you haven't tried that, please do so, and then also try with both devices on the 2nd soundcard, to see if the problem is something specific to the 1st soundcard.

I was reading a post over in Re: Problem after upgrading from version 2.4.4 of BASS to version 2.4.6, and saw how bass had an issue with MMDEVAPI callball backs related to COM.

Ian have you pulled the device notification model from the basswasapi.dll as well?

I have verified if we try and dynamically use the basswasapi.dll to query available wasapi device, when we release the dll we sometime receive this MMDevAPI.dll crash..

BASSWASAPI does still use device notifications, and your crash does look like the old "device notifications when dynamic loading" issue. Please try calling BASS_WASAPI_SetNotify with proc=NULL when your app is closing, to release the device notification stuff. That option was introduced last December (here), so also make sure you're not using an older version than that (the current BASS_WASAPI_GetVersion = 15). Let me know if the problem still occurs after doing this.

Wishmaster

  • Posts: 149
Re: BASSWASAPI beta
« Reply #228 on: 5 Oct '12 - 04:16 »
hi
I have tested it on different equipments and variations. to me it looks like, as soon as the second device is initialized
the first device loses the connection  to the device which has been initialized first;

because I use WASAPI for Playback and Recording at the same time and obviously
i have to Start, Pause, Stop the devices. so i have to use BASS_WASAPI_SetDevice anyways.
I guess that there nothing that you can do.


there is an error in the BASSWASAPI documentation

BASS_WASAPI_SetVolume has no flags
Quote
BOOL BASS_WASAPI_SetVolume(
    BOOL linear,
    float volume
);

Parameters
flags Any combination of these flags.               <<<<<<
linear Use a linear curve? Otherwise logarithmic. 
volume The volume level... 0 (silent) to 1 (max) if linear, or else a dB level. 



thanks for a great lib. and your hard work!!!


Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #229 on: 5 Oct '12 - 16:04 »
i did some more testing and found that the first BASS_WASAPI_Init() will be stopped by the second  call  of BASS_WASAPI_Init()  
and it does not matter whether it is an input or output;

so if I am doing it like this, it will not work!
Code: [Select]
// Init the Output Device
 BASS_WASAPI_Init(-1, 0, 0, DevFlag, 0.4, 0, @Output_Wasapi_Proc, Pointer(Self))
 BASS_WASAPI_Start();

 // Init the Input Device
 BASS_WASAPI_Init(-2, 0, 0, DevFlag, 1, 0.1, @Input_Wasapi_Proc, Pointer(Self))
 BASS_WASAPI_Start();

I just tried some quick tests of that and it seemed to go fine, ie. the output and input WASAPIPROC functions both continued to be called. In your case, does the input WASAPIPROC (Input_Wasapi_Proc) continue to be called and the output WASAPIPROC (Output_Wasapi_Proc) doesn't?

My simple test code looked like this...

Code: [Select]
HSTREAM bufstream=0; // stream to buffer input data

...

DWORD CALLBACK InWasapiProc(void *buffer, DWORD length, void *user)
{
BASS_StreamPutData(bufstream, buffer, length); // feed data to buffer stream
return 1;
}

DWORD CALLBACK OutWasapiProc(void *buffer, DWORD length, void *user)
{
DWORD r=BASS_ChannelGetData(bufstream, buffer, length); // get data from buffer stream
if (r==(DWORD)-1) return 0;
return r;
}

...

BASS_Init(0, 48000, 0, 0, NULL); // initialize BASS "no sound" device
BASS_WASAPI_Init(-1, 0, 0, 0, 0.4, 0, OutWasapiProc, NULL); // inititialize default WASAPI output
BASS_WASAPI_Start(); // start the output
BASS_WASAPI_Init(-2, 0, 0, 0, 1,0. 1, InWasapiProc, NULL); // inititialize default WASAPI input
BASS_WASAPI_INFO wi;
BASS_WASAPI_GetInfo(&wi);
bufstream=BASS_StreamCreate(wi.freq, wi.chans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_PUSH, 0); // create a stream to buffer input data
BASS_WASAPI_Start(); // start the input

there is an error in the BASSWASAPI documentation...

Oops! That's corrected now, thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #230 on: 9 Nov '12 - 15:46 »
An updated BASSWASAPI version is up in the 1st post. It adds support for Windows' hybrid volume curve to the BASS_WASAPI_Set/GetVolume functions, and also has a device enumeration tweak to fix an issue with Citrix XenApp.

yps

  • Posts: 144
Re: BASSWASAPI beta
« Reply #231 on: 20 Nov '12 - 10:05 »
Has anyone come accross the condition when a particular device reports an insanely high values for the mixing samplerate and mixing channels? This has happend to one of my users with a Delta 66 card on Windows 8:

Quote
21:25:11.735 (0) WASAPI Playback Device {0.0.0.00000000}.{1287dc4a-eff3-4740-974f-d15cefbeb1b1} (2), Digitale audio (S/PDIF) (ESI MAYA44 Audio), 44100, 2 channels, flags 1
21:25:11.748 (0) WASAPI Record Device {0.0.0.00000000}.{1287dc4a-eff3-4740-974f-d15cefbeb1b1} (3), Digitale audio (S/PDIF) (ESI MAYA44 Audio) (loopback), 44100, 2 channels, flags 25
21:25:11.769 (0) WASAPI Playback Device {0.0.0.00000000}.{33f24838-f3e9-47a3-9f1f-df8368530978} (6), Luidsprekers (ESI MAYA44 Audio), 44100, 2 channels, flags 1
21:25:11.783 (0) WASAPI Record Device {0.0.0.00000000}.{33f24838-f3e9-47a3-9f1f-df8368530978} (7), Luidsprekers (ESI MAYA44 Audio) (loopback), 44100, 2 channels, flags 25
21:25:11.794 (0) WASAPI Playback Device {0.0.0.00000000}.{37f135a0-9335-4cd4-bfc8-789f7e9baebf} (8), S/PDIF (M-Audio Delta 66), 10540928, 10553036 channels, flags 1
21:25:53.584 (0) WASAPI Record Device {0.0.0.00000000}.{37f135a0-9335-4cd4-bfc8-789f7e9baebf} (9), S/PDIF (M-Audio Delta 66) (loopback), 10540928, 10548732 channels, flags 25
21:25:53.651 (0) WASAPI Playback Device {0.0.0.00000000}.{612f434a-9cab-4b0c-bfae-ea9dd90212bf} (12), Luidsprekers (Aureon 7.1 USB), 44100, 2 channels, flags 1
21:25:53.656 (0) WASAPI Record Device {0.0.0.00000000}.{612f434a-9cab-4b0c-bfae-ea9dd90212bf} (13), Luidsprekers (Aureon 7.1 USB) (loopback), 44100, 2 channels, flags 25
21:25:53.660 (0) WASAPI Playback Device {0.0.0.00000000}.{6bf6e2be-27cd-4309-8048-b26994ab8ca5} (14), Line 3/4 (M-Audio Delta 66), 10540928, 10553036 channels, flags 1

(This is the output from BASS_WASAPI_GetDeviceInfo; first number is mixfreq, second number is mixchans, last number is flags.)

I'm not sure if this is related to Windows 8. The Delta driver seems to be a bit broken anyway (at least on his machine), you get errors when you try to initialize the device via DirectSound.

Oh, and on the manual page here, http://www.un4seen.com/doc/basswasapi/BASS_WASAPI_DEVICEINFO.html, the first sentence should read "Used with BASS_WASAPI_GetDeviceInfo to retrieve information on a device."

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #232 on: 20 Nov '12 - 14:44 »
That's strange. Do the numbers change, eg. do they appear to be random? Also, what does Windows say about the output format in the "Advanced" page of the device's properties?

The problem in the BASS_WASAPI_DEVICEINFO documentation has now been corrected, thanks.

yps

  • Posts: 144
Re: BASSWASAPI beta
« Reply #233 on: 22 Nov '12 - 21:49 »
I only have the debug output from two runs, but I see that the numbers are not consistent.

Windows Control Panel reports 44100 and 2 channels, as normal.

Here's another log (there's two different Delta cards now, apparently):

Quote
06:15:28.672 (0) WASAPI Playback Device {0.0.0.00000000}.{1287dc4a-eff3-4740-974f-d15cefbeb1b1} (2), Digitale audio (S/PDIF) (ESI MAYA44 Audio), 44100, 2 channels, flags 1
06:15:28.676 (0) WASAPI Record Device {0.0.0.00000000}.{1287dc4a-eff3-4740-974f-d15cefbeb1b1} (3), Digitale audio (S/PDIF) (ESI MAYA44 Audio) (loopback), 44100, 2 channels, flags 25
06:15:28.682 (0) WASAPI Playback Device {0.0.0.00000000}.{33f24838-f3e9-47a3-9f1f-df8368530978} (6), Luidsprekers (ESI MAYA44 Audio), 44100, 2 channels, flags 1
06:15:28.687 (0) WASAPI Record Device {0.0.0.00000000}.{33f24838-f3e9-47a3-9f1f-df8368530978} (7), Luidsprekers (ESI MAYA44 Audio) (loopback), 44100, 2 channels, flags 25
06:15:28.691 (0) WASAPI Playback Device {0.0.0.00000000}.{37f135a0-9335-4cd4-bfc8-789f7e9baebf} (8), S/PDIF (M-Audio Delta 66), 7284676, 7288740 channels, flags 1
06:15:41.249 (0) WASAPI Record Device {0.0.0.00000000}.{37f135a0-9335-4cd4-bfc8-789f7e9baebf} (9), S/PDIF (M-Audio Delta 66) (loopback), 7284676, 7292552 channels, flags 25
06:15:41.280 (0) WASAPI Playback Device {0.0.0.00000000}.{612f434a-9cab-4b0c-bfae-ea9dd90212bf} (12), Luidsprekers (Aureon 7.1 USB), 44100, 2 channels, flags 1
06:15:41.284 (0) WASAPI Record Device {0.0.0.00000000}.{612f434a-9cab-4b0c-bfae-ea9dd90212bf} (13), Luidsprekers (Aureon 7.1 USB) (loopback), 44100, 2 channels, flags 25
06:15:41.288 (0) WASAPI Playback Device {0.0.0.00000000}.{6bf6e2be-27cd-4309-8048-b26994ab8ca5} (14), Line 3/4 (M-Audio Delta 66), 7284676, 7288740 channels, flags 1
06:15:56.899 (0) WASAPI Record Device {0.0.0.00000000}.{6bf6e2be-27cd-4309-8048-b26994ab8ca5} (15), Line 3/4 (M-Audio Delta 66) (loopback), 7284676, 7292552 channels, flags 25
06:15:56.904 (0) WASAPI Playback Device {0.0.0.00000000}.{744ede52-c839-4152-8f6b-ca284b6f0ec3} (16), Multichannel (M-Audio Delta Audiophile), 7284676, 7288740 channels, flags 1
06:15:56.909 (0) WASAPI Record Device {0.0.0.00000000}.{744ede52-c839-4152-8f6b-ca284b6f0ec3} (17), Multichannel (M-Audio Delta Audiophile) (loopback), 7284676, 7292552 channels, flags 25
06:15:56.918 (0) WASAPI Playback Device {0.0.0.00000000}.{9eeafb3b-c0ee-43ff-91d9-350cd028f910} (20), Line 1/2 (M-Audio Delta Audiophile), 7284676, 7288740 channels, flags 1
06:15:56.923 (0) WASAPI Record Device {0.0.0.00000000}.{9eeafb3b-c0ee-43ff-91d9-350cd028f910} (21), Line 1/2 (M-Audio Delta Audiophile) (loopback), 7284676, 7292552 channels, flags 25
06:15:56.931 (0) WASAPI Playback Device {0.0.0.00000000}.{cb2e110d-f474-4a7a-9e84-a17b19ba3536} (24), Line 1/2 (M-Audio Delta 66), 7284676, 7288740 channels, flags 3
06:15:56.936 (0) WASAPI Record Device {0.0.0.00000000}.{cb2e110d-f474-4a7a-9e84-a17b19ba3536} (25), Line 1/2 (M-Audio Delta 66) (loopback), 7284676, 7292552 channels, flags 25
06:15:56.941 (0) WASAPI Playback Device {0.0.0.00000000}.{eecb6704-6a5f-4426-9443-b793d4540688} (26), Multichannel (M-Audio Delta 66), 7284676, 7288740 channels, flags 1
06:15:56.946 (0) WASAPI Record Device {0.0.0.00000000}.{eecb6704-6a5f-4426-9443-b793d4540688} (27), Multichannel (M-Audio Delta 66) (loopback), 7284676, 7292552 channels, flags 25
06:15:56.952 (0) WASAPI Playback Device {0.0.0.00000000}.{eed1da2b-822c-4b75-ab14-88024bf1ea97} (28), S/PDIF (M-Audio Delta Audiophile), 7284676, 7288740 channels, flags 1
06:15:56.958 (0) WASAPI Record Device {0.0.0.00000000}.{eed1da2b-822c-4b75-ab14-88024bf1ea97} (29), S/PDIF (M-Audio Delta Audiophile) (loopback), 7284676, 7292552 channels, flags 25
06:15:56.962 (0) WASAPI Playback Device {0.0.0.00000000}.{f5c51c29-9b05-4057-92dd-ab6d02aafc9a} (30), Digitale audio (S/PDIF) (High Definition Audio-apparaat), 44100, 2 channels, flags 1
06:15:56.972 (0) WASAPI Record Device {0.0.1.00000000}.{10f279e3-f08f-4be4-800c-441c717a4f34} (32), Lijn (Aureon 7.1 USB), 44100, 2 channels, flags 17
06:15:56.978 (0) WASAPI Record Device {0.0.1.00000000}.{12ffee4b-1623-47b7-98a3-2adccb5403d3} (33), Microfoon (Aureon 7.1 USB), 44100, 2 channels, flags 19
06:15:56.986 (0) WASAPI Record Device {0.0.1.00000000}.{214704e1-85d8-4585-b1c4-7f241337b881} (34), S/PDIF (M-Audio Delta Audiophile), 7284676, 7292552 channels, flags 17
06:15:56.993 (0) WASAPI Record Device {0.0.1.00000000}.{2de1312c-6b3d-460a-a1a8-049b5c0a84cb} (35), Monitor (M-Audio Delta Audiophile), 7284676, 7292552 channels, flags 17
06:15:57.001 (0) WASAPI Record Device {0.0.1.00000000}.{42c2011a-04b5-4442-b1c4-ca0cf93d018f} (37), Stereo-mix (ESI MAYA44 Audio), 44100, 2 channels, flags 17
06:15:57.006 (0) WASAPI Record Device {0.0.1.00000000}.{44896d97-12f6-4ef1-83ca-fc4e601009a8} (38), Lijningang (High Definition Audio-apparaat), 44100, 2 channels, flags 17
06:15:57.011 (0) WASAPI Record Device {0.0.1.00000000}.{571b5f73-a8c8-4904-90ba-0936f684c219} (39), Lijn (ESI MAYA44 Audio), 44100, 2 channels, flags 17
06:15:57.022 (0) WASAPI Record Device {0.0.1.00000000}.{6d25bf36-c0f6-47e6-a298-8460f6f6541d} (42), Line 1/2 (M-Audio Delta Audiophile), 7284676, 7292552 channels, flags 17
06:15:57.029 (0) WASAPI Record Device {0.0.1.00000000}.{74a80897-41fb-4d60-bc0e-401ad90a80bb} (43), Line 1/2 (M-Audio Delta 66), 7284676, 7292552 channels, flags 17
06:15:57.035 (0) WASAPI Record Device {0.0.1.00000000}.{836841e0-933e-4f2e-a0ce-c1f41b04bcbd} (44), Microfoon (ESI MAYA44 Audio), 44100, 2 channels, flags 17
06:15:57.044 (0) WASAPI Record Device {0.0.1.00000000}.{9543f2e3-ae17-4e94-90e0-0a761a487a64} (46), Monitor (M-Audio Delta 66), 7284676, 7292552 channels, flags 17
06:15:57.052 (0) WASAPI Record Device {0.0.1.00000000}.{96c0da85-c9fe-483c-92e1-ab6958c91cb8} (47), Line 3/4 (M-Audio Delta 66), 7284676, 7292552 channels, flags 17
06:15:57.061 (0) WASAPI Record Device {0.0.1.00000000}.{a04fe300-6ebf-4487-b7eb-c4403d0dc557} (49), Multichannel (M-Audio Delta 66), 7284676, 7292552 channels, flags 17
06:15:57.067 (0) WASAPI Record Device {0.0.1.00000000}.{be7fd6ec-a93d-4532-8ca0-f89f072623aa} (50), Microfoon (High Definition Audio-apparaat), 44100, 2 channels, flags 17
06:15:57.073 (0) WASAPI Record Device {0.0.1.00000000}.{e330aa1c-e0a7-44d1-b446-199a242d24a0} (52), SPDIF-interface (Aureon 7.1 USB), 44100, 2 channels, flags 17
06:15:57.079 (0) WASAPI Record Device {0.0.1.00000000}.{f00d8650-2e1e-412f-99be-e910f4e353d9} (53), S/PDIF (M-Audio Delta 66), 7284676, 7292552 channels, flags 17
06:15:57.086 (0) WASAPI Record Device {0.0.1.00000000}.{f2dfdf97-6fac-49b9-99aa-83c5457b496b} (54), Multichannel (M-Audio Delta Audiophile), 7284676, 7292552 channels, flags 17

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #234 on: 23 Nov '12 - 15:45 »
I notice that BASS_WASAPI_GetDeviceInfo isn't 0-initializing the provided BASS_WASAPI_DEVICEINFO structure, so if it's unable to get the device's mix format, then the "mixfreq" and "mixchans" members will be left as they were before the call. If you're not 0-initializing the structure either, that could explain what you're seeing. I'll send you a debug version to confirm if (and hopefully why) the mix format request is failing with that device.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #235 on: 31 Jan '13 - 17:14 »
An update with support for WASAPI's event-driven buffering system is now up in the BASSWASAPI package (in the 1st post). The CONTEST example has also been updated to include that option.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #236 on: 19 Mar '13 - 17:19 »
A VB version of the RECTEST example is now included in the BASSWASAPI package, courtesy of Jobby.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #237 on: 13 Sep '13 - 15:47 »
The BASSWASAPI add-on has now left "beta" status and is available from the BASS page. The 64-bit version is available from the Win64 thread...

   www.un4seen.com/forum/?topic=9038

jalbers

  • Posts: 81
Re: BASSWASAPI beta
« Reply #238 on: 20 Oct '13 - 05:57 »
Perhaps this is a naive question (since I've now read through the entire thread and didn't see my question asked), but why does the use of BASSWASAPI require making calls via the BASS_WASAPI_ prefix?

In other words, why can't I just load the BASSWASAPI plugin and then make a call to BASS_Init et cetera and have it utilize WASAPI (when available) and fallback to DirectSound/CoreAudio/ALSA (when not available)? That approach would feel more like how the other add-ons work.

I like the features that the WASAPI plugin brings, but it appears as though upgrading my existing cross-platform project to use WASAPI when available might be a rather daunting task. Am I wrong?

Some additional questions I have:
1. I'm noticing that some sound devices support audio-jack detection on only specific ports (eg. only on the green L&R port), some on all ports, and some on no ports. Can I determine when the jack detection feature is available on an individual port basis? Similarly, can I detect when a jack is plugged/unplugged on a per port basis (including events)?

2. In an earlier thread I read that you have not exposed the "DEVICE_STATE_NOTPRESENT" constant within BASS. Is this still the case? I would very much like to expose all known devices to the user and then allow them the option of enabling them (both at the Device Manager and Sound control panel levels) directly within my application. Is there a way to enable/disable these devices within WASAPI?

3. I'm reading only two available options within the docs for detecting speaker availability. I can either use BASS_DEVICE_CPSPEAKERS to mirror the configuration within the Sound control panel, or I can use BASS_DEVICE_SPEAKERS to force assignment up to 8 speakers regardless of actual device capability. Why are these the only two options? When I view the "Jack Information" section of the device properties within the Sound control panel, it tells me exactly how many speakers it thinks the device has and how they are color coded and assigned. Why isn't there a flag for this? I don't want to have to tell people they need to change the speaker configuration within the Sound control panel in order to access additional speakers, but I also don't want to force assignment up to 8 and have people select speakers that don't actually exist.
« Last Edit: 20 Oct '13 - 17:24 by jalbers »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #239 on: 21 Oct '13 - 15:53 »
Perhaps this is a naive question (since I've now read through the entire thread and didn't see my question asked), but why does the use of BASSWASAPI require making calls via the BASS_WASAPI_ prefix?

In other words, why can't I just load the BASSWASAPI plugin and then make a call to BASS_Init et cetera and have it utilize WASAPI (when available) and fallback to DirectSound/CoreAudio/ALSA (when not available)? That approach would feel more like how the other add-ons work.

I like the features that the WASAPI plugin brings, but it appears as though upgrading my existing cross-platform project to use WASAPI when available might be a rather daunting task. Am I wrong?

Add-ons that provide support for additional file formats can be plugged into the standard BASS sample/stream creation functions via BASS_PluginLoad, and add-ons that provide effects (eg. BASS_FX) can plug into BASS_ChannelSetFX, but other add-ons (like BASSWASAPI) need to be called directly. In audio player terms, BASS currently supports "input" and "dsp" plugins, but not "output" plugins. There are no plans for it at present, but it may be that an "output" plugin system will be introduced in future.

For now, the difference when using ASIO/WASAPI output is that you would create "decoding channels" (via the BASS_STREAM_DECODE flag) and call BASS_ChannelGetData to get the data for playback, eg. in an ASIOPROC/WASAPIPROC callback function. If you want to play multiple streams at a time, then you would use the BASSmix add-on to create a mixer (with the same sample format as the ASIO/WASAPI output), and plug the sources into that and have the ASIOPROC/WASAPIPROC get the data from it.

To simplify things, you could write some wrapper functions, eg. a source "play" function could call BASS_ChannelPlay with BASS output and BASS_Mixer_StreamAddChannel with BASSASIO/BASSWASAPI output.

Some additional questions I have:
1. I'm noticing that some sound devices support audio-jack detection on only specific ports (eg. only on the green L&R port), some on all ports, and some on no ports. Can I determine when the jack detection feature is available on an individual port basis? Similarly, can I detect when a jack is plugged/unplugged on a per port basis (including events)?

As far as I can see, it isn't possible to check individual ports on a device, but the device's state is available from BASS_WASAPI_GetDeviceInfo, eg. check for BASS_DEVICE_UNPLUGGED (=DEVICE_STATE_UNPLUGGED). You can request notification of device state changes via BASS_WASAPI_SetNotify.

2. In an earlier thread I read that you have not exposed the "DEVICE_STATE_NOTPRESENT" constant within BASS. Is this still the case? I would very much like to expose all known devices to the user and then allow them the option of enabling them (both at the Device Manager and Sound control panel levels) directly within my application. Is there a way to enable/disable these devices within WASAPI?

BASSWASAPI will include disabled devices in its device list (available from BASS_WASAPI_GetDeviceInfo), but I'm not sure there is any way to programatically enable/disable devices; I think that needs to be done by the user via the control panel.

3. I'm reading only two available options within the docs for detecting speaker availability. I can either use BASS_DEVICE_CPSPEAKERS to mirror the configuration within the Sound control panel, or I can use BASS_DEVICE_SPEAKERS to force assignment up to 8 speakers regardless of actual device capability. Why are these the only two options? When I view the "Jack Information" section of the device properties within the Sound control panel, it tells me exactly how many speakers it thinks the device has and how they are color coded and assigned. Why isn't there a flag for this? I don't want to have to tell people they need to change the speaker configuration within the Sound control panel in order to access additional speakers, but I also don't want to force assignment up to 8 and have people select speakers that don't actually exist.

The BASS_DEVICE_SPEAKERS and BASS_DEVICE_CPSPEAKERS BASS_Init flags originate from pre-Vista times when it was tricky to detect the number of available speakers and the detection could be incorrect in some cases. Windows Vista made speaker detection more straightforward, so the BASS_DEVICE_SPEAKERS and BASS_DEVICE_CPSPEAKERS flags are unnecessary and ignored by BASS_Init there.

serkanp

  • Posts: 64
jack detection not working
« Reply #240 on: 18 Feb '14 - 10:23 »
Code: [Select]

 private WASAPINOTIFYPROC plugnotify;

public void enableJackDetection()
        {
            plugnotify = new WASAPINOTIFYPROC(onDevicePlug);
            bool result= BassWasapi.BASS_WASAPI_SetNotify(plugnotify, IntPtr.Zero);
        }

private void onDevicePlug(BASSWASAPINotify notify, int device, IntPtr user)
{
  console.writeline("device:" + device + ",state:" + notify.toString();
}

 when i call enableJackDetection() and plug-in,plug-out the connected devices, this code is not working and nothing happens onDevicePlug event .. or i am doing something wrong :))
tested in 4 different computer.. still same..

what is wrong? :)

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: jack detection not working
« Reply #241 on: 18 Feb '14 - 18:01 »
Is the BASS_WASAPI_SetNotify call returning TRUE to indicate success?

Also, the "console.writeline" line seems to be missing a closing bracket; I presume that is just a typo in the post and not in the code? :)

serkanp

  • Posts: 64
Re: BASSWASAPI beta
« Reply #242 on: 19 Feb '14 - 14:18 »
yes it returns true

and yes, it is a type error on post. on real code it is ok:) (the real code writes to a log file.. so i put console.writeline to this post, and i have breakpoints to see if the code comes to that event part)

and yes, still not firing event..

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #243 on: 19 Feb '14 - 17:38 »
To clarify, are you (un)plugging devices (eg. USB soundcards) or is it just audio cables? If you watch the Sound control panel at the same time, do you see things changing in there?

Also, here's a little test that you can use to confirm whether the problem is something specific to your code...

   www.un4seen.com/stuff/wasapi-notify.exe

That'll display any notifications received while it's running.

serkanp

  • Posts: 64
Re: BASSWASAPI beta
« Reply #244 on: 19 Feb '14 - 18:20 »
there are 3 different state we have
1-when you unplug the audio cable, some audio cards disables itself from system and you can see that they are disabled on device manager.
2-when you unplug the audio cable, some other cards only shows that the audio cable plugged or unplugged
3-when you unplug the audio cable, some other other :) cards does nothing. playback continues whether you plug or unplug the cable.

option 1 and 2 is important for me. i want to detect if the audio card disabled/enabled or the audio cable plugged or unplugged.
in case 1, some clients unplugs the audio cable, and the default audio card changes (ex: spidif or hdmi audio becomes default), when they plug the audio cable, audio card becomes enabled but there is no sound output from my player, because the output channel becomes the last audio card. so i want to get the selected card's id, if the device becomes unavailable , i will pause the music, when becomes available , i will set the sound output to that audio card.
on option 2, we see that there is output from our application but there is no sound on speakers. because the cable is unplugged. so i want to  report to the client that the cable is unplugged..

on option 3 , its ok for us.. i know that we cant do anything..


serkanp

  • Posts: 64
Re: BASSWASAPI beta
« Reply #245 on: 19 Feb '14 - 18:30 »
i tested your application.
it shows when the device disabled/enabled.
but it does not detect when the audio cable is plugged or unplugged..

as you see on 2 screenshot (plug.jpg and unplug.jpg). windows (realtek high definition audio) detects audio cable plug/unplug
disabled.jpg shows when you disable/enable audio card.


ps: my code shows exactly what your test app shows.. it shows disabled/enabled device events only.
« Last Edit: 19 Feb '14 - 18:51 by serkanp »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASSWASAPI beta
« Reply #246 on: 20 Feb '14 - 16:01 »
Those "Information" notifications are from the Realtek software rather than Windows, aren't they? If so, I'm not sure whether they'll be available to other software. If you watch the device states in Windows' Sound control panel, do you see any changes there?