[wdmaudiodev] Re: AVStream virtual audio driver: different sound quality dependently on the number of CPU cores.

  • From: Alexander Ivash <elderorb@xxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 21 Jul 2016 19:40:57 +0300

Ok... This is simple to check and I'll check later today.. What
worries me a bit more, could it be the case that for some reasons
multiple consumers of data could be working at the same time on
multi-core CPU system? If yes, what can I do to protect against such a
behaviour other than locking the whole ring buffer?

Regards, Alexander

2016-07-21 18:50 GMT+03:00 Matthew van Eerde <Matthew.van.Eerde@xxxxxxxxxxxxx>:

Ø  if pointer assignment is atomic



It’s not, which is why InterlockedExchangePointer exists.



From: Alexander Ivash
Sent: Thursday, July 21, 2016 8:47 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: AVStream virtual audio driver: different sound
quality dependently on the number of CPU cores.



Thank you for quick replies, guys!

若水 shlikewater@xxxxxxxxx: I wish I could sent you all the stuff, but
this is not mine. I can only add more details.

In short, this is modified avssamp (Filter-centric) with only audio
pin and ringbuffer instead of static wav file, populated from user
mode application via KSMETHOD.

Here is the PIN descriptor:

{

//
// Audio Capture Pin
//
&AudioCapturePinDispatch,
NULL,
{
SIZEOF_ARRAY(waveinterfaces), // Interfaces (NULL, 0 == default)
waveinterfaces,
SIZEOF_ARRAY(wavemediums),          // Mediums (NULL, 0 == default)
wavemediums,
SIZEOF_ARRAY(PinDataFormatRanges), // Range count (filled in later)
PinDataFormatRanges, // Ranges (filled in later)
KSPIN_DATAFLOW_OUT,                 // Dataflow
KSPIN_COMMUNICATION_BOTH,           // Communication
&KSCATEGORY_CAPTURE,                  // Category
&g_PINNAME_AUDIO_CAPTURE, // Name
0                                   // Reserved
},
// KSPIN_FLAG_SOME_FRAMES_REQUIRED_FOR_PROCESSING | // Flags
KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL |
// KSPIN_FLAG_HYPERCRITICAL_PROCESSING  |
KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY |
// KSPIN_FLAG_ASYNCHRONOUS_PROCESSING |
KSPIN_FLAG_FIXED_FORMAT,
1,                                      // Instances Possible
0,                                      // Instances Necessary
NULL,
// &AudioDefaultAllocatorFraming,          // Allocator Framing (filled
later)
reinterpret_cast <PFNKSINTERSECTHANDLEREX> // Intersect Handler
(CAudioCapturePin::IntersectHandler)
}

KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL is used because I've
dropped DPC / KsFilterAttemptProcessing due to another issues. As the
result as soon as PIN gets initialized it starts asking for data by
triggering 'CCaptureFiler::Process' function in which I read the data
from ringbuffer and always return STATUS_PENDING (not sure if this is
fully correct approach although). As for the reading data - I always
fill input buffer (if don't have enough data in the ringbuffer - just
fill it with a silence).

Not sure what else to add.. I have a strong feeling that combination
of PIN flags / return status / the way I'm feeding pin with the data
is suboptimal but it works just find on some environments and doens't
on other. After a lot of attempts I managed to identify the key
difference (at least one of them) - this is number of CPU cores.

Matthew van Eerde: Yes, I also thought so, but now sure where it can
came from. Ringbuffer is NOT using any kinds of lock, but if pointer
assignment is atomic then there should no be any issues, correct?
Anyway, thank you, I need to check if adding any kind of
synchronization will change the picture.

Just in case if this is not the race condition, what else could be
number-of-CPU-dependent? To be honest, CPU is the key factor only in
the case of Win7 and VM. Other environments (based on Win10) behave
much better independently on the number of CPUs.

Again thank you guys for your time!

Regards, Alexander

2016-07-21 13:36 GMT+03:00 若水 <shlikewater@xxxxxxxxx>:
Hello, Alexander:
There is not enough information to check the problem. Could you give us
the
inf file, filter descriptor, pin descriptor etc. You can send me your
project, if possible.

Best Regards,
Shang Jing

2016-07-21 18:29 GMT+08:00 Alexander Ivash <elderorb@xxxxxxxxx>:

What could be the reason for the following behaviour:

On one Windows 7 x64 VM (with 1 CPU) driver works fine (well, with
rare audio artifacts)
On the SAME VM but with 2 CPUs driver works awfully, sound is heavily
distorted.

Behaviour seems to not depend (or influence is very low) on using

KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL or
KSPIN_FLAG_ASYNCHRONOUS_PROCESSING

What other things can I check?

Regards, Alexander
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:
mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/


******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: