PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.47k stars 305 forks source link

WASAPI "Format Not Supported" Error - RC 19.7 #527

Closed c319chris closed 2 years ago

c319chris commented 3 years ago

Release candidate 19.7 compiled without error on newly-updated version of Microsoft Visual Studio Community 2019, Version 16.9.0.

Still getting a "format not supported" error when using WASAPI.

Upon testing, the problem seems to be with the .dll file. The .lib file does not give this error.

My program works OK using .dll file from 2016.

philburk commented 3 years ago

We need to decide whether this should block shipping of 19.7.

Is this a recent regression? 2016 to 2021 is a big time span.

What is the impact of this bug on applications?

c319chris commented 3 years ago

Re: Ticket #527

What is the impact of this bug on applications?

In the case of my recording program written in PureBasic, the program doesn't run at all using WASAPI. It doesn't get past the blocking error message the program throws.

The program runs with the dll compiled in 2016.

It would be interesting to know if Audacity has had similar problems.

Thank you for all of your efforts in supporting PortAudio.

-----Original Message----- From: Phil Burk @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Author @.> Sent: Mon, Mar 15, 2021 5:56 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

We need to decide whether this should block shipping of 19.7. Is this a recent regression? 2016 to 2021 is a big time span. What is the impact of this bug on applications? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

dmitrykos commented 3 years ago

There is little information available regarding this report: Shared/Exclusive mode, what format app is trying to use, what formats sound card supports and what format is set in Audio CPL and etc.

@c319chris, Upon testing, the problem seems to be with the .dll file. The .lib file does not give this error.

Do you mean statically linked library (.lib) works well (source code of the current version) but .dll does not?

Would you please clarify all this with example of usage, otherwise it is a search of a needle in a haystack.

philburk commented 3 years ago

We need to decide whether to block the release for this bug:

  1. What apps are broken by 19.7?
  2. What apps still work on 19.7?
  3. What are the repro steps for the bug?
  4. Can it be reproduced in a simple C program?
  5. What is the exact message?
c319chris commented 3 years ago

Hi Phil -

We need to decide whether to block the release for this bug: What apps are broken by 19.7? What apps still work on 19.7? What are the repro steps for the bug? Can it be reproduced in a simple C program? What is the exact message?

My recommendation is NOT to block the upcoming release for issue #527.

I may be the only one having this issue. Mine is not even a publicly-distributed project. I am not aware that the problem is bothering Audacity, which IS a publicly-distributed project and is also capable of recording audio using WASAPI. In addition, we don't know how much a fix for this issue would delay the upcoming release. It is a step forward that PortAudio now compiles without error and "out-of-the-box" on the latest version of MS Visual Studio (16.9.1, just now updated). I think it is good if PortAudio can record 24-bit samples without relying on ASIO.

There is a distinct air of urgency to release the next update, so don't let this issue hold it up.

I will try to add more detail to the ticket.

-----Original Message----- From: Phil Burk @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Tue, Mar 16, 2021 7:33 am Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

We need to decide whether to block the release for this bug: What apps are broken by 19.7? What apps still work on 19.7? What are the repro steps for the bug? Can it be reproduced in a simple C program? What is the exact message? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

c319chris commented 3 years ago

Upon testing, the problem seems to be with the .dll file. The .lib file does not give this error. Do you mean statically linked library (.lib) works well (source code of the current version) but .dll does not? Would you please clarify all this with example of usage, otherwise it is a search of a needle in a haystack.

There are no errors using the dll and lib files from 2016. If I substitute the dll file from2016 with one compiled in 2021, I get an error.

The audio device is a MOTU M2, a USB interface. I was also having trouble with a Mackie Blackjack.

Here is the code that throws the error:

result = Pa_IsFormatSupported(@in_streamparms, #Null, sampleRate)
If result <> #paFormatIsSupported
// throw error message
Endif

I am trying to open a 1-channel stream, 24 bits, 48,000 Hz using WASAPI. Problem also occurs when opening a 2-channel stream.

Problem also occurs with 1- and 2-channel 16-bit stream.

Also, there is this code which is passed to Pa_IsFormatSupported()

Select bitDepth Case 16 sampleFormat = #paInt16 Case 24 sampleFormat = #paInt24 ;Case 32 ; sampleFormat = #paInt32 EndSelect Also: WasapiInfo\flags = #paWinWasapiExclusive | #paWinWasapiPolling Exclusive mode is enabled in audio recording control panel.

dmitrykos commented 3 years ago

@c319chris, thank you for more details.

Could it be some binary compatibility issue between PureBasic and compiled PA binaries? Does recording work if you enable shared mode and match frequency?

The best would be to compile PA library with only WASAPI interface and try this example: https://github.com/PortAudio/portaudio/blob/master/examples/paex_record.c

If it works then it is some binary compatibility issue.

You could also try installing Neutron Recorder application (it allows 7-day trial) if you are using Windows 10 (https://www.microsoft.com/en-us/p/neutron-audio-recorder/9nf4597d1j6z) and try recording something on your system. It is using PA WASAPI and by default will use Shared, Polling mode but you can force Exclusive via settings (Audio Hardware -> Exclusive Mode).

There are no other similar reports and therefore I believe it might be some local issue. Start first with paex_record.

c319chris commented 3 years ago

Hi Dmitry -

Could it be some binary compatibility issue between PureBasic and compiled PA binaries?

It's doubtful. My program works great if I use the dll and lib files compiled in 2016. So there was a regression after the 2016 version.

Shared mode is disabled; I'm using Exclusive mode. I have compiled it with only WASAPI support.

-----Original Message----- From: Dmitry Kostjuchenko @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Tue, Mar 16, 2021 1:14 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

@c319chris, thank you for more details. Could it be some binary compatibility issue between PureBasic and compiled PA binaries? Does recording work if you disable shared mode and match frequency? The best would be to compile PA library with only WASAPI interface and try this example: https://github.com/PortAudio/portaudio/blob/master/examples/paex_record.c If it works then it is some binary compatibility issue. You could also try installing Neutron Recorder application (it allows 7-day trial) if you are using Windows 10 (https://www.microsoft.com/en-us/p/neutron-audio-recorder/9nf4597d1j6z) and try recording something on your system. It is using PA WASAPI and by default will use Shared, Polling mode but you can force Exclusive via settings (Audio Hardware -> Exclusive Mode). There are no other similar reports and therefore I believe it might be some local issue. The best approach is to first try paex_record. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

c319chris commented 3 years ago

All of the following functions are failing, i.e. they return errors when called:

Pa_IsFormatSupported()

Pa_OpenStream()

Pa_StartStream()

To reiterate, they all work fine if I swap the 2016 files back in, WITH NO CHANGE TO MY CODE.

-----Original Message----- From: Dmitry Kostjuchenko @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Tue, Mar 16, 2021 1:14 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

@c319chris, thank you for more details. Could it be some binary compatibility issue between PureBasic and compiled PA binaries? Does recording work if you disable shared mode and match frequency? The best would be to compile PA library with only WASAPI interface and try this example: https://github.com/PortAudio/portaudio/blob/master/examples/paex_record.c If it works then it is some binary compatibility issue. You could also try installing Neutron Recorder application (it allows 7-day trial) if you are using Windows 10 (https://www.microsoft.com/en-us/p/neutron-audio-recorder/9nf4597d1j6z) and try recording something on your system. It is using PA WASAPI and by default will use Shared, Polling mode but you can force Exclusive via settings (Audio Hardware -> Exclusive Mode). There are no other similar reports and therefore I believe it might be some local issue. The best approach is to first try paex_record. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Lord-Kamina commented 3 years ago

But if the problem is only with the DLL, it might be a problem with something upstream of portaudio. No?

RossBencina commented 3 years ago

What format are you requesting? How are you requesting it.

The problem right now is that we don't know what parameters you are calling PortAudio with. If you can provide a test case in C that reproduces the issue then Dmitry will be able to test it and try to track down the cause.

c319chris commented 3 years ago

The problem occurs when either 16 or 24 bits are requested, 48 kHz sample rate, both stereo and mono, and WASAPI.

Are these values still correct?

paInDevelopment = 0 ; / use while developing support for a new host API /

paDirectSound = 1

paMME = 2

paASIO = 3

paSoundManager = 4

paCoreAudio = 5

paOSS = 7

paALSA = 8

paAL = 9

paBeOS = 10

paWDMKS = 11

paJACK = 12

paWASAPI = 13

paAudioScienceHPI = 14

-----Original Message----- From: Ross Bencina @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Thu, Mar 18, 2021 6:07 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

What format are you requesting? How are you requesting it. The problem right now is that we don't know what parameters you are calling PortAudio with. If you can provide a test case in C that reproduces the issue then Dmitry will be able to test it and try to track down the cause. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dmitrykos commented 3 years ago

@c319chris, the best approach for this case would be to compile PortAudio library with only WASAPI interface and compile the examples too. If paex_record works on your system then the problem is in interoperability between PureBasic and new binaries obtained with the latest version of Visual Studio you are using.

philburk commented 3 years ago

Are these values still correct?

paInDevelopment = 0 ; / use while developing support for a new host API /

Those match the current values.

https://github.com/PortAudio/portaudio/blob/f7efb6b53cf134ec9165da7f6a3c0172371b820a/include/portaudio.h#L275

Has anyone tried compile a sample C program like paex_sine using the 2016 code dynamically linking to a PortAudio DLL? Then we could try to run the 2016 executable with 2021 DLL.

dmitrykos commented 3 years ago

@philburk, tests are working fine on my machine, here are tests which @c319chris could run (namely paex_record) and check if it works on his machine. If it works then problem is in PureBasic interoperability and not connected to PA directly:

https://we.tl/t-gtFGvXgiid

For a test to succeed the input device format must be set to 44100 Hz / any bits in the Windows's Audio CPL.

p.s.: It does not make sense to interchange DLLs if these tests work. Whether it is DLL or a statically linked it will work the same.

c319chris commented 3 years ago

Dmitry: I believe you that it works OK on your machine.

If I compile the C-language paex_record.c and it works OK, it's not going to tell you a thing about how it works with PureBasic because it's the C-language version.

Let's apply some deductive reasoning:

The 2016 dll still works just fine with my program — no change to the PureBasic code, so what could have changed? Nothing, except the dll version. I can swap back and forth between the 2016 dll and the 2021 dll ad infinitum:

2016 dll - works

2021 dll - doesn't work

If there were a problem with PureBasic interoperability, don't you think the 2016 dll wouldn't work either?

philburk commented 3 years ago

Again, try to compile a sample C program like paex_sine using the 2016 code dynamically linking to a 2016 PortAudio DLL. Then try to run the 2016 executable with 2021 DLL. That would be a relevant test.

RossBencina commented 3 years ago

I notice that you mentioned 4-byte alignment in a message to the mailing list. Is it possible that your 2016 dll was compiled with different alignment than the 2021 dll that you are now using?

Chris: If you have not already done so, I recommend that you rebuild the 2016 dll from the sources, then check that it works. That will rule out issues with your build environment.

RossBencina commented 3 years ago

Chris, you wrote:

If I compile the C-language paex_record.c and it works OK, it's not going to tell you a thing about how it works with PureBasic because it's the C-language version.

We only care that the C-language version is working. If the C version works then it is a PureBasic problem for you to solve. We don't run PureBasic and we can not support PureBasic.

dmitrykos commented 3 years ago

@c319chris, have you tried running the compiled samples (they are for x64 Windows platform) which I linked in my previous e-mail, namely paex_record?

What is the result, does it work on your machine where the PureBasic app is failing to operate?

philburk commented 3 years ago

We know that PA 19.6 works and that PA 19.7 works. The issue is backward compatibility of the 19.7 DLLs.

Chris' program, which was compiled with PA 19.6, works with a 19.6 DLL but not with a 19.7 DLL. So why don't we recreate that scenario with a C program?

  1. Compile paex_sine using the 19.6 code dynamically linking to a 19.6 PortAudio DLL.
  2. Compile a 19.7 DLL from the current master.
  3. Try to run the paex_sine with the 19.7 DLL.

I tried to do this on a Windows VM but got stuck in the PA Tutorial for Windows. (that is another issue)

c319chris commented 3 years ago

To reiterate, I don't customarily program in C so building a C-language PortAudio example is foreign to me, sorry. I remember asking for help with compiling PA years ago on this list and the responses were less than helpful, to put it mildly. It was Trond Gunderson who got PA working under PureBasic, and he documented it quite well.

We only care that the C-language version is working. If the C version works then it is a PureBasic problem for you to solve. We don't run PureBasic and we can not support PureBasic.

I distinctly remember you saying PortAudio would never support more than 16 bit samples. Now look — lo and behold, it supports 24-bit samples in WASAPI. I remember helping Dmitry with that project back around 2010 - 2011, about 10 years ago.

So PortAudio support in PureBasic is officially dead.

-----Original Message----- From: Ross Bencina @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Fri, Mar 19, 2021 11:34 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

Chris, you wrote: If I compile the C-language paex_record.c and it works OK, it's not going to tell you a thing about how it works with PureBasic because it's the C-language version. We only care that the C-language version is working. If the C version works then it is a PureBasic problem for you to solve. We don't run PureBasic and we can not support PureBasic. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dmitrykos commented 3 years ago

To reiterate, I don't customarily program in C so building a C-language PortAudio example is foreign to me, sorry.

@c319chris, in my previous reply to you (https://github.com/PortAudio/portaudio/issues/527#issuecomment-803084256) I provided the link with compiled examples, so all you need is to run paex_record example and check if it works on your machine. Could you do that? It will help to understand whether it is PureBasic interoperability or something else.

Compiling PortAudio nowadays is very easy, all you need is to use CMake to generate the project with all examples and tests.

philburk commented 3 years ago

Could @dmitrykos or @RossBencina please try the DLL swapping test described above?

c319chris commented 3 years ago

Hi Dmitry -

The program paex_record.exe runs without error on my machine.

-----Original Message----- From: Dmitry Kostjuchenko @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Sun, Mar 21, 2021 12:44 am Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

To reiterate, I don't customarily program in C so building a C-language PortAudio example is foreign to me, sorry. @c319chris, in my previous reply to you (#527 (comment)) I provided the link with compiled examples, so all you need is to run paex_record example and check if it works on your machine. Could you do that? It will help to understand whether it is PureBasic interoperability or something else. Compiling PortAudio nowadays is very easy, all you need is to use CMake to generate the project with all examples and tests. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dmitrykos commented 3 years ago

@philburk, the binary I provided to @c319chris works fine, e.g. is recording and playing back the recording. There is no point to lookback if current version is working fine. If 19.6 is compiled with the same compiler version then it will work fine either.

I am sure it must be something with PureBasic interoperability as there are no any other similar reports, including my apps with an extremely wide coverage of systems running on x86, x64 and ARM CPU devices (Windows PCs, Laptops, Windows tablets).

@c319chris could try digging into the glue code of PA <> PureBasic interface and check what might be the reason. Microsoft phased out support for Windows XP and may be PureBasic glue code must be recompiled with the same compiler as PA's DLL if it was compiled with some older version of MSVC. If DLL is compiled for Windows 10 (as Win32) it may not work as it hooks some APIs not compatible with XP (specifically threading APIs). So my advise is to match compiler version for PureBasic glue code and PA's DLLs.

Another workaround is to use older version of MSVC which supports XP, if XP toolset is not already available as optional component. And the last option is to compile with MinGW (compatible with XP if targets it) or Clang for Windows.

c319chris commented 3 years ago

PureBasic is closed source.

-----Original Message----- From: Dmitry Kostjuchenko @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Sun, Mar 21, 2021 12:26 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

@philburk, the binary I provided to @c319chris works fine, e.g. is recording and playing back the record. There is no point to lookback if current version is working fine. If 19.6 is compiled with the same compiler version then it will work fine either. I am sure it must be something with PureBasic interoperability as there are no any other similar reports, including my apps with an extremely wide coverage of systems running on x86, x64 and ARM CPU devices (Windows PCs, Laptops, Windows tablets). @c319chris could try digging into the glue code of PA <> PureBasic interface and check what might be the reason. It is outside of our scope. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dmitrykos commented 3 years ago

@c319chris, you could try compiling PortAudio source code snapshot taken at some point in 2016 and check if it works, or not.

Also I need to correct myself regarding targeting Windows XP, the lowest version for targeting for WASAPI will be Windows Vista. I checked how PA's source is compiled by default - currently it targets the latest Windows version. Would you please try one of these DLLs which are targeting Windows Vista: https://we.tl/t-CxpNL5rzEu

RossBencina commented 3 years ago

Chris, please can you build a new v19.6 (2016) .dll today and confirm that it works? I would like to rule out the possibility that the v19.6 dll that you are testing is in some way non-standard (e.g. has different struct packing).

dmitrykos commented 3 years ago

@RossBencina, in addition to that it would be great to test DLLs provided here too: https://github.com/PortAudio/portaudio/issues/527#issuecomment-803853684

dmitrykos commented 3 years ago

As there is no activity from the side of the issue reporter and also no active participation in testing from the reporter's side, I propose to close this ticket and also remove the Bug label from it as it is unconfirmed. @philburk what do you think?

c319chris commented 3 years ago

I rebuilt the 2016 dll and it does not work.

-----Original Message----- From: Ross Bencina @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Wed, Mar 24, 2021 5:47 pm Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

Chris, please can you confirm that if you build a new v19.6 (2016) .dll today that it works? I would like to rule out the possibility that the v19.6 dll that you are testing is in some way non-standard (e.g. has different struct packing). — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dmitrykos commented 3 years ago

@c319chris , thank you for your reply. Would you please try linking against one of these precompiled DLLs, what result will be in this case?: https://we.tl/t-5idMnJ2Pwi

philburk commented 3 years ago

This looks like a build problem. Removing from 19.7 blocking milestone.

dmitrykos commented 2 years ago

Does not make sense to keep this issue open, as almost 1 year passed since last communication.

c319chris commented 2 years ago

The latest changes to PortAudio broke my code and killed my project, so I have given up on PortAudio.

-----Original Message----- From: Dmitry Kostjucenko @.> To: PortAudio/portaudio @.> Cc: c319chris @.>; Mention @.> Sent: Tue, Feb 8, 2022 11:59 am Subject: Re: [PortAudio/portaudio] WASAPI "Format Not Supported" Error - RC 19.7 (#527)

Does not make sense to keep this issue open, as almost 1 year passed since last communication. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.