Discussion:
WASAPI exclusive mode- specify latency crashes
(too old to reply)
Reid Bishop
2010-07-08 15:01:18 UTC
Permalink
All,



I am still trying to fine-tune WASAPI on Windows 7 64 bit, and running into
problems.



I am trying to run in exclusive mode now- when I do this I get mixed
behavior.



1) When I set suggestedLatency to any value between .001 and 0.5, PA
returns the following error: "General Audio Error: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt."



2) When I set suggestedLatency to 0.5 and greater, PA returns the
following error: "Audio Stream Error: Invalid device".



3) When I set suggestedLatency to 0, no error is thrown. However, I
MUST use the same sampleRate as is set by my Audio control panel (RealTek
HD Audio).



This seems very inconsistent with regards to the Latency settings. I should
be able to set my suggestedLatency between the High and Low latency values
provided by the driver, which indicates between .003 and .010. I find it
odd that I get memory corruption errors when I try to set it to any
reasonable value.



Thoughts?





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100708/0af73ba1/attachment.html>
Dmitry Kostjuchenko
2010-07-08 15:18:08 UTC
Permalink
Hi Reid,

WASAPI issue is for me :)

What type of stream are you opening, input, output or both as full-duplex? What is sample rate, bits are you using?

1) Where do you see this erro comming from? Popping up Windows GUI window or console message? PA WASAPI reports detailed error description + a line in code were error was triggered so if you could copy-paste what is shown in console it would help to locate the place.

2) I will check max. limit. Windows 7 imposed min/max limits and I also applied them in PA WASAPI but need to check the code then.

3) I did not understood clearly: However, I MUST use the same sampleRate... Please note that for Shared mode sample rate must be the same as in Control Panel for exclusive not, but if it is even so, I can't do anything about it as PA WASAPI simply passes parameters you set directly to WASAPI API thus have no control of further behavior.

I have Vista x64 on my dev. machine, not Windows 7 and Windows 7 WASAPI's behavior is a bit different from Vista. Anyway will find ability to test on 7 also. But first please reply on my questions.

Best regards,
Dmitry.
----- Original Message -----
From: Reid Bishop
To: 'Portaudio Mailing List'
Sent: Thursday, July 08, 2010 6:01 PM
Subject: [Portaudio] WASAPI exclusive mode- specify latency crashes


All,



I am still trying to fine-tune WASAPI on Windows 7 64 bit, and running into problems.



I am trying to run in exclusive mode now- when I do this I get mixed behavior.



1) When I set suggestedLatency to any value between .001 and 0.5, PA returns the following error: "General Audio Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."



2) When I set suggestedLatency to 0.5 and greater, PA returns the following error: "Audio Stream Error: Invalid device".



3) When I set suggestedLatency to 0, no error is thrown. However, I MUST use the same sampleRate as is set by my Audio control panel (RealTek HD Audio).



This seems very inconsistent with regards to the Latency settings. I should be able to set my suggestedLatency between the High and Low latency values provided by the driver, which indicates between .003 and .010. I find it odd that I get memory corruption errors when I try to set it to any reasonable value.



Thoughts?







------------------------------------------------------------------------------


_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100708/35acb4b0/attachment-0001.html>
Dmitry Kostjuchenko
2010-07-08 15:19:55 UTC
Permalink
Please also mention number of channels.

----- Original Message -----
From: Dmitry Kostjuchenko
To: Portaudio Mailing List
Sent: Thursday, July 08, 2010 6:18 PM
Subject: Re: [Portaudio] WASAPI exclusive mode- specify latency crashes


Hi Reid,

WASAPI issue is for me :)

What type of stream are you opening, input, output or both as full-duplex?
What is sample rate, bits are you using?

1) Where do you see this erro comming from? Popping up Windows GUI window or
console message? PA WASAPI reports detailed error description + a line in
code were error was triggered so if you could copy-paste what is shown in
console it would help to locate the place.

2) I will check max. limit. Windows 7 imposed min/max limits and I also
applied them in PA WASAPI but need to check the code then.

3) I did not understood clearly: However, I MUST use the same sampleRate...
Please note that for Shared mode sample rate must be the same as in Control
Panel for exclusive not, but if it is even so, I can't do anything about it
as PA WASAPI simply passes parameters you set directly to WASAPI API thus
have no control of further behavior.

I have Vista x64 on my dev. machine, not Windows 7 and Windows 7 WASAPI's
behavior is a bit different from Vista. Anyway will find ability to test on
7 also. But first please reply on my questions.

Best regards,
Dmitry.
----- Original Message -----
From: Reid Bishop
To: 'Portaudio Mailing List'
Sent: Thursday, July 08, 2010 6:01 PM
Subject: [Portaudio] WASAPI exclusive mode- specify latency crashes


All,

I am still trying to fine-tune WASAPI on Windows 7 64 bit, and running into
problems.

I am trying to run in exclusive mode now- when I do this I get mixed
behavior.

1) When I set suggestedLatency to any value between .001 and 0.5, PA
returns the following error: "General Audio Error: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt."

2) When I set suggestedLatency to 0.5 and greater, PA returns the
following error: "Audio Stream Error: Invalid device".

3) When I set suggestedLatency to 0, no error is thrown. However, I
MUST use the same sampleRate as is set by my Audio control panel (RealTek
HD Audio).

This seems very inconsistent with regards to the Latency settings. I should
be able to set my suggestedLatency between the High and Low latency values
provided by the driver, which indicates between .003 and .010. I find it
odd that I get memory corruption errors when I try to set it to any
reasonable value.

Thoughts?
Dmitry Kostjuchenko
2010-07-08 15:49:28 UTC
Permalink
Hello Reid,

It seems I found a problem with combination Exclusive + Native process, at this moment I would advise to set paWinWasapiPolling specific to WASAPI flag or wait for patch. It was a result of suggestedLatency/framesPerBuffer reimplementation.

As a matter of fact I arrived to conclusing that using Event interface of WASAPI is highly ineffective if WASAPI does not work 1:1 with user buffer as there is not CPU load compensation at all (Event interface allows to lock max buffer size only). Currently PA's WASAPI for Polling mode can go at lowest 5.33ms. I will implement check and if overall latency is set to be lower by user (lower than 5.33) PA will use Event interface which allows to go for less than 1ms under Vista and 3ms under 7.

Best regards,
Dmitry.
----- Original Message -----
From: Reid Bishop
To: 'Portaudio Mailing List'
Sent: Thursday, July 08, 2010 6:01 PM
Subject: [Portaudio] WASAPI exclusive mode- specify latency crashes


All,



I am still trying to fine-tune WASAPI on Windows 7 64 bit, and running into problems.



I am trying to run in exclusive mode now- when I do this I get mixed behavior.



1) When I set suggestedLatency to any value between .001 and 0.5, PA returns the following error: "General Audio Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."



2) When I set suggestedLatency to 0.5 and greater, PA returns the following error: "Audio Stream Error: Invalid device".



3) When I set suggestedLatency to 0, no error is thrown. However, I MUST use the same sampleRate as is set by my Audio control panel (RealTek HD Audio).



This seems very inconsistent with regards to the Latency settings. I should be able to set my suggestedLatency between the High and Low latency values provided by the driver, which indicates between .003 and .010. I find it odd that I get memory corruption errors when I try to set it to any reasonable value.



Thoughts?







------------------------------------------------------------------------------


_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100708/676dc086/attachment.html>
Dmitry Kostjuchenko
2010-07-08 21:07:07 UTC
Permalink
Hi Reid,

I just commited patch to PA WASAPI. It shall be fixing the issues you described. I did necessary testing of all modes in my application and WASAPI operates stable and correctly. I do not get any memory corruptions and/or related errors and etc.

Could you please test from your side as well.

Regards,
Dmitry.
----- Original Message -----
From: Reid Bishop
To: 'Portaudio Mailing List'
Sent: Thursday, July 08, 2010 6:01 PM
Subject: [Portaudio] WASAPI exclusive mode- specify latency crashes


All,



I am still trying to fine-tune WASAPI on Windows 7 64 bit, and running into problems.



I am trying to run in exclusive mode now- when I do this I get mixed behavior.



1) When I set suggestedLatency to any value between .001 and 0.5, PA returns the following error: "General Audio Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."



2) When I set suggestedLatency to 0.5 and greater, PA returns the following error: "Audio Stream Error: Invalid device".



3) When I set suggestedLatency to 0, no error is thrown. However, I MUST use the same sampleRate as is set by my Audio control panel (RealTek HD Audio).



This seems very inconsistent with regards to the Latency settings. I should be able to set my suggestedLatency between the High and Low latency values provided by the driver, which indicates between .003 and .010. I find it odd that I get memory corruption errors when I try to set it to any reasonable value.



Thoughts?







------------------------------------------------------------------------------


_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100709/b12c943e/attachment.html>
Bob McGwier
2010-07-08 21:18:42 UTC
Permalink
Thank you very much Dmitry for your continued efforts. At Flex Radio we
have many users who have moved to Windows 7 and they really do need
stable support of WASAPI for Windows 7 support of our virtual cable
software.


Best wishes,
Bob McGwier
Post by Dmitry Kostjuchenko
Hi Reid,
I just commited patch to PA WASAPI. It shall be fixing the issues you
described. I did necessary testing of all modes in my application and
WASAPI operates stable and correctly. I do not get any memory
corruptions and/or related errors and etc.
Could you please test from your side as well.
Regards,
Dmitry.
----- Original Message -----
*From:* Reid Bishop <mailto:rbish at attglobal.net>
*To:* 'Portaudio Mailing List' <mailto:portaudio at music.columbia.edu>
*Sent:* Thursday, July 08, 2010 6:01 PM
*Subject:* [Portaudio] WASAPI exclusive mode- specify latency crashes
All,
I am still trying to fine-tune WASAPI on Windows 7 64 bit, and
running into problems.
I am trying to run in exclusive mode now- when I do this I get mixed behavior.
1) When I set suggestedLatency to any value between .001 and 0.5,
PA returns the following error: "General Audio Error: Attempted
to read or write protected memory. This is often an indication
that other memory is corrupt."
2) When I set suggestedLatency to 0.5 and greater, PA returns the
following error: "Audio Stream Error: Invalid device".
3) When I set suggestedLatency to 0, no error is thrown. However,
I MUST use the same sampleRate as is set by my Audio control
panel (RealTek HD Audio).
This seems very inconsistent with regards to the Latency
settings. I should be able to set my suggestedLatency between the
High and Low latency values provided by the driver, which
indicates between .003 and .010. I find it odd that I get memory
corruption errors when I try to set it to any reasonable value.
Thoughts?
------------------------------------------------------------------------
_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100708/3aa20691/attachment-0001.html>
Reid Bishop
2010-07-09 04:03:25 UTC
Permalink
Hi Dmitri,



Sorry I did not respond to your earlier posts- I don't have personal e-mail
access at work.



I will try your WASAPI patches. To answer your questions, I am using
full-duplex, 44 or 96khz sample rate, specified buffers of 1024. The error
I was getting was being thrown as a System.Exception when I make the call to
Pa_OpenStream, but there was no line number to accompany it. I don't get a
console message, as I am running this in C# and using PortAudio compiled as
a DLL- no way to get debug output from non-managed code.



Regarding the fact that I must use the same sample rate as currently set in
the RealTek setup dialog. I know that if using Shared mode, I must match
this setting. If using exclusive, I should be able to use any sample rate
the card supports, as long as Windows is set up to allowed exclusive access.
I do know that ASIO4ALL can use other sample rates, as I have tested it. On
another note, ASIO4ALL seems to wedge the underlying hardware, as I
discovered in an earlier post regarding not being able to use 96khz properly
(more on that later after I check in with the ASIO4All folks.



I will try your patch, and see what happens. Thanks for your very quick
attention to this!



-Reid-





_____

From: portaudio-bounces at music.columbia.edu
[mailto:portaudio-bounces at music.columbia.edu] On Behalf Of Dmitry
Kostjuchenko
Sent: Thursday, July 08, 2010 3:07 PM
To: Portaudio Mailing List
Subject: Re: [Portaudio] WASAPI exclusive mode- specify latency crashes



Hi Reid,



I just commited patch to PA WASAPI. It shall be fixing the issues you
described. I did necessary testing of all modes in my application and WASAPI
operates stable and correctly. I do not get any memory corruptions and/or
related errors and etc.



Could you please test from your side as well.



Regards,

Dmitry.

----- Original Message -----

From: Reid Bishop <mailto:rbish at attglobal.net>

To: 'Portaudio <mailto:portaudio at music.columbia.edu> Mailing List'

Sent: Thursday, July 08, 2010 6:01 PM

Subject: [Portaudio] WASAPI exclusive mode- specify latency crashes



All,



I am still trying to fine-tune WASAPI on Windows 7 64 bit, and running into
problems.



I am trying to run in exclusive mode now- when I do this I get mixed
behavior.



1) When I set suggestedLatency to any value between .001 and 0.5, PA
returns the following error: "General Audio Error: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt."



2) When I set suggestedLatency to 0.5 and greater, PA returns the
following error: "Audio Stream Error: Invalid device".



3) When I set suggestedLatency to 0, no error is thrown. However, I
MUST use the same sampleRate as is set by my Audio control panel (RealTek
HD Audio).



This seems very inconsistent with regards to the Latency settings. I should
be able to set my suggestedLatency between the High and Low latency values
provided by the driver, which indicates between .003 and .010. I find it
odd that I get memory corruption errors when I try to set it to any
reasonable value.



Thoughts?






_____


_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100708/31030357/attachment-0001.html>
Reid Bishop
2010-07-09 05:44:49 UTC
Permalink
Dmitry,



I have compiled your latest and tested. Good news, and bad news.



First of all- no more memory corruption issues or errors- all is well on
that front.



The bad news. something is now amiss with the final output- it sounds as if
the latency values are way off base. This now occurs whether using shared
or exclusive mode. My output sounds like it has a high speed
motorboat/drone effect- I've heard this before, but don't recall what the
problem was. In addition, I now have pops and crackles that I cannot get
rid of, no matter how high I set my user latencies to. Note that before
this change, I could set user latency to "zero" when using shared mode and
WASAPI still performed perfectly.



Here's my current setup:

Full Duplex, 96khz, 1024 buffers, set to 5ms latency.



When running in shared mode, this is what I get from PA_GetStreamInfo:

SampleRate: 96000, InputLatency: 0.0213333331048489,
OutputLatency: 1024.02136230469

Sounds terrible- lots of pops and clicks, very ratty sounding.



When running in exclusive mode, this is what I get from PA_GetStreamInfo:

SampleRate: 96000, InputLatency: 0.0213333331048489,
OutputLatency: 1024.02136230469

Sounds better, but still that 'drone' style sound- something still isn't
right.



I have no issues with MME ( I usually have to set user latency to 35ms with
my setup), nor DirectSound (I set user latency to 0ms).



Thoughts?



-Reid-

W0CNN

CNNSDR Development



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100708/f25eac80/attachment-0001.html>
Dmitry Kostjuchenko
2010-07-09 05:58:06 UTC
Permalink
Hi Reid,

I will do extensive testing regarding full-duplex today and will come up with fix. But could you please metion following parameters:
- framesPerBuffer (your buffer)
- suggestedLatency (both input/output)
- sample bits

Best regards,
Dmitry.
----- Original Message -----
From: Reid Bishop
To: 'Reid Bishop' ; 'Portaudio Mailing List'
Sent: Friday, July 09, 2010 8:44 AM
Subject: Re: [Portaudio] WASAPI exclusive mode- specify latency crashes


Dmitry,



I have compiled your latest and tested. Good news, and bad news.



First of all- no more memory corruption issues or errors- all is well on that front.



The bad news. something is now amiss with the final output- it sounds as if the latency values are way off base. This now occurs whether using shared or exclusive mode. My output sounds like it has a high speed motorboat/drone effect- I've heard this before, but don't recall what the problem was. In addition, I now have pops and crackles that I cannot get rid of, no matter how high I set my user latencies to. Note that before this change, I could set user latency to "zero" when using shared mode and WASAPI still performed perfectly.



Here's my current setup:

Full Duplex, 96khz, 1024 buffers, set to 5ms latency.



When running in shared mode, this is what I get from PA_GetStreamInfo:

SampleRate: 96000, InputLatency: 0.0213333331048489, OutputLatency: 1024.02136230469

Sounds terrible- lots of pops and clicks, very ratty sounding.



When running in exclusive mode, this is what I get from PA_GetStreamInfo:

SampleRate: 96000, InputLatency: 0.0213333331048489, OutputLatency: 1024.02136230469

Sounds better, but still that 'drone' style sound- something still isn't right.



I have no issues with MME ( I usually have to set user latency to 35ms with my setup), nor DirectSound (I set user latency to 0ms).



Thoughts?



-Reid-

W0CNN

CNNSDR Development





------------------------------------------------------------------------------


_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100709/e2d23716/attachment.html>
Reid Bishop
2010-07-09 06:07:02 UTC
Permalink
Dmitry,



framesPerBuffer: 1024 (Yes, that's right- this is because of the nature of
the application)

suggestedLatency- .005 (I tested all the way up to .085, and no
improvement. Both input and output.

sample bits- PaFloat32



Now, one thing you might want to take note of. Notice below that I did a
Pa_GetStreamInfo after opening my stream:

SampleRate: 96000, InputLatency: 0.0213333331048489,
OutputLatency: 1024.02136230469



Note the OutputLatency above? It appears to be the actual latency ADDED to
my framesPerBuffer. Maybe that's what is wrong? I don't see this issue
when using MME or DirectSound. The above anomaly appears whether using
Exclusive or Shared mode.



-Reid-

W0CNN

CNNSDR Development



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100709/1e107c18/attachment.html>
Reid Bishop
2010-07-10 08:03:24 UTC
Permalink
Dmitry,



I tried your changes to WASAPI tonight. I sure hate to be the bearer of bad
news.



Using Shared Mode, I've now got stutter, pops, clicks- no matter what
latency I specify, and no matter what Sample Rate I choose. I have tried
1024 and 2048 framesPerBuffer, and it gets worse as I go higher. The nature
of my application prevents me from going below 1024 framesPerBuffer for the
time being.



Using Exclusive Mode, the same thing- but in addition it still has the
motorboat, drone effect (kind of like a very high speed echo).



I don't know what to say, other than I may try to dive into your code and
see what could be going on. This is a C# application, so doing any kind of
debugging is virtually impossible. For now, I'm going to hit the hay and
take a look in the morning.



-Reid-

W0CNN

CNNSDR Development



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100710/30d187b6/attachment.html>
Dmitry Kostjuchenko
2010-07-10 08:11:26 UTC
Permalink
Hello Reid,

Thanks for testing! No problem, I will try further then :) Anyway I started understanding the situation. I just modified patest_wire to test 1024/2048 framesPerBuffer and got damaged audio, I suspect similar to what you are getting. I completely forgot to test these values and was using 64/128 frames (small values are ok).

Because I can now reproduce bad sound with 1024/2048 I will come up with fixes later today. Seems that something is timing out in i/o loop.

Best regards,
Dmitry.

----- Original Message -----
From: Reid Bishop
To: 'Portaudio Mailing List'
Sent: Saturday, July 10, 2010 11:03 AM
Subject: Re: [Portaudio] WASAPI exclusive mode- specify latency crashes


Dmitry,



I tried your changes to WASAPI tonight. I sure hate to be the bearer of bad news.



Using Shared Mode, I've now got stutter, pops, clicks- no matter what latency I specify, and no matter what Sample Rate I choose. I have tried 1024 and 2048 framesPerBuffer, and it gets worse as I go higher. The nature of my application prevents me from going below 1024 framesPerBuffer for the time being.



Using Exclusive Mode, the same thing- but in addition it still has the motorboat, drone effect (kind of like a very high speed echo).



I don't know what to say, other than I may try to dive into your code and see what could be going on. This is a C# application, so doing any kind of debugging is virtually impossible. For now, I'm going to hit the hay and take a look in the morning.



-Reid-

W0CNN

CNNSDR Development





------------------------------------------------------------------------------


_______________________________________________
Portaudio mailing list
Portaudio at music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20100710/a1651599/attachment.html>
Loading...