Clearly you have been given a problem with specific parameters that you don?t quite understand from your manager. Eventually I am able to discern that you (or your manager) wish to create a virtual audio device that will be compatible with arbitrary applications (ie Media Player etc.) that will transmit the audio samples via a UDP/IP connection to some remote device for playback ? if I have got any part of this wrong, please correct me before reading further
In theory this should work out okay since the playback application knows the data rate of the audio to be played and should send enough data down to prevent underruns and not so much to cause overruns. This is the theory. On modern machines, this generally works, but there are no specific guarantees as the OS has no hard realtime limits ? and as this is audio playback for music or speech and not the control rod actuator for a nuclear power plant this is generally deemed acceptable.
Adding a network component introduces two high level problems that you need to consider
-
The latency, jitter and packet loss inherent in any IP network (okay there are exceptions but they require specialized hardware); and
-
The clock skew between whichever clock source that your arbitrary UM app is using and the one used by your remote device
In your case the use of UDP is very appropriate since the loss of a single packet will not initiate meltdown and you will about the arbitrarily long delays associated with TCP retransmission for data whos ?time has passed?. The network quality will have a direct effect on the quality of audio output, but in exactly the same way as the quality of a speaker wire does.
Much has been made of the difference is clock sources, but I would expect that unless the PC and device in question have exceptionally bad clock sources, that this will not be a problem for you. You may be able to generate some statistics on ho well your driver / device behave, but you have already realized that there is no way to force an arbitrary application to send you data more slowly / quickly that it will do on its own and that the overhead of resampling for a tiny variance in frequency is probably not worth the effort or viable. I don?t know your situation, but unless you have extensive evidence that there is a real problem, I would opt for the simple solution that simply ignores any telemetry from the device about its buffer state.
Sent from Mailhttps: for Windows 10
From: Matthieu Collettemailto:xxxxx
Sent: April 27, 2016 8:34 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: Re:[ntdev] How to perform adaptative resampling
On 2016-04-27 10:19:07 +0000, Mike Kemp said:
> Well, now we know you are getting throttling info back from the target
> you can simulate a sound card by running a sort of software local clock
> frequency locked to the remote device. That will allow you to read
> audio from the OS just like a normal driver. No “resampling” is
> required, adaptive or otherwise.
So it’s not a resampling problem…
>
> To know how to write an audio card driver, I hand you back to the
> driver experts. I have written Windows drivers some time ago and I
> follow this forum mainly so I can knowledgeably advise people not to
> write drivers!
Tim told me to post my problem on the WDMAUDIODEV list, that’s what I
did, hope I’ll be able to get a good solution.
>
> Good luck, Mike
Thanks for your advice
> ----- Original Message ----- From: Matthieu Collette
> Newsgroups: ntdev
> To: Windows System Software Devs Interest List
> Sent: Wednesday, April 27, 2016 10:57 AM
> Subject: Re:[ntdev] How to perform adaptative resampling
>
>
> On 2016-04-27 09:46:30 +0000, Mike Kemp said:
>
>> I don’t understand why you need to be writing a driver at all. If you
>> have control over the streaming app which sends UDP packets (with your
>> own retry mechanism) and knows which sample the remote device is
>> playing, all you need to do is open the audio file as a data file and
>> send audio data directly from the file as fast as is needed to keep the
>> target buffer full.
> My application should act a sound card from the user point of view.
> The user should be able to use whatever audio player he wants on his
> computer, select the virtual sound card I’m trying to write a driver
> for as the audio output device, and everything should be streamed from
> the computer to the remote playback device.
>
>>
>> My advice on driver writing is don’t. Unless all other ways of doing
>> are exhausted.
> Thanks for your advice, but I have no other choice at the moment
>
>>
>> Mike
>>
>> ----- Original Message ----- From: Matthieu Collette
>> Newsgroups: ntdev
>> To: Windows System Software Devs Interest List
>> Sent: Wednesday, April 27, 2016 10:13 AM
>> Subject: Re:[ntdev] How to perform adaptative resampling
>>
>>
>> On 2016-04-27 08:39:22 +0000, Mike Kemp said:
>>
>> Hi Mike !
>>
>>> My guess is he means that if the file to be played is, say 96k, then
>>> the remote device is first switched to 96k using its own crystal, and
>>> will then run at its own crystal rate, expecting its play buffer to be
>>> kept from emptying by data being sent to it.
>> Yes, that’s true.
>>
>>> It sound like it does not have any feedback to the sending computer
>>> that can throttle the tx data, so the computer has to send at the
>>> average speed of 96k (determined by its own reference, though not clear
>>> that a PC has one that is easily used for audio unless it uses its own
>>> sound card for this) in the hope that the target has buffered enough,
>>> and has enough spare capacity, to handle variations on the actual data
>>> rate.
>> Actually, the streaming application that received audio data from the
>> driver and sends audio data to the remode hardware device has no way to
>> throttle the audio data being sent.
>>
>>>
>>> Oddly, he has said the data must be sent by UDP which can lose packets.
>>> Failing any feedback path there is no way these can be re-sent. If
>>> there is a feedback path I don’t understand why it can’t be used to
>>> throttle the sending computer’s data, which could then produce a
>>> reliable working system.
>> There is a feedback path from the remote hardware device and the
>> sending computer. This feedback tells me which sample number is
>> currently being played and how full the buffer is.
>> Packets are sent using UPD and the streaming application is able to
>> resent lost audio packets, but if for any reason I don’t receive
>> feedback packets, well, I can’t do anything.
>>
>> Assuming I could modify the streaming application source code and
>> throttle tx, I would be able to slow down tx. What if I need to
>> accelerate ? How could I go faster than without throtling ?
>>
>>>
>>> ----- Original Message ----- From: Maxim S. Shatskih
>>> Newsgroups: ntdev
>>> To: Windows System Software Devs Interest List
>>> Sent: Tuesday, April 26, 2016 11:20 PM
>>> Subject: Re:[ntdev] How to perform adaptative resampling
>>>
>>>
>>>> The sample rate of the hardware source is not fixed, it depends on the
>>>> current file being played.
>>>> Allowed value could be one of 44100, 48000, 88200, 96000, 176400 or 192000 Hz.
>>>
>>> File being played? then it is software source, not hardware. It has no
>>> clock of its own, and trivially adapts to the sink clock.
>>>
>>> Usually, RTP is used for audio over network, it is based on UDP.
>>>
>>> You can do deep buffering like DirectShow does, this will ensure the
>>> Hi-Fi quality, but will cause time lag from start to first audible
>>> sound. Unacceptable (as is DirectShow, at least was 10 years ago) for
>>> communication apps.
>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list online at: http:
>>
>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>> software drivers!
>> Details at http:
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
—
NTDEV is sponsored by OSR
Visit the list online at: http:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:
To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></http:></http:></http:></http:></http:></mailto:xxxxx></mailto:xxxxx></https:>