Skip to contentSkip to conversation

smix plugin available?

DISCUSSION tomasz motylewski 2 participants 2 messages Nov 27, 2002 – Nov 28, 2002 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Paul Davis
Quoted 4 lines

Please stop the complication of "available/delay" etc. Just the raw pointer. Each application knows where its application pointer is, so it can easily calculate delay/available and decide for itself whether there was an overrun or not.

actually, it can't. if the user space application is delayed for precisely 1 buffer's worth of data, it will see the pointer at what appears to the the right place and believe that no xrun has occured. the only way around this is to provide either:

Well, but if you combine it with the current time information, then you will know whether the buffer has wrapped around or not - if you have 1000 ms of buffer, but always run 20 ms from the front, then if you notice 1010 ms has passed since the last action - then you have an overrun, even if the HW pointer seems to be in the right place. So, configuration + mmaped buffer + gettimeoday
+ HW pointer and I am happy. And may be system call "mix data into buffer (start, n_frames,data)" for atomic add. This provides minimum interference between programs (if they will agree on frame rate, format, etc.).

Quoted 8 lines

for the record, i've used this approach (inspired by someone from poland whose name i forget) with an ISA card (no PCI burst size issues) to achieve <10 sample processing latency. i scribbled a special bit pattern into the hardware buffer, then looped over it watching to see where the audio interface was and writing/reading data directly ahead of it or behind it. it works, but of course it burns CPU cycles like crazy (there is no wait for the device or anything else, its just a continuous while loop).

Well, I use that method for reading data - I know how much samples I need to gather before I send them, so I may calculate how many ms to sleep. If I read few samples too much, I will just sleep less next time. Jitter about 300 microseconds in RTP data stream which I send, and quite CPU efficient.

But how did you do for writing data to the card? Are your read and write buffer HW synchronized?

Quoted 4 lines

this isn't a function of callbacks. its a function of the response of the callback system to the delay. if the system notices that its running late but goes ahead and executes anyway, the results are just the same as you suggest for your approach. however, since there is

well, no. Lets say I have got "write callback" in time and I should give some data to the card. But I do not have it - it may arrive in 1 ms, but then I can only through it away, because I will get next "write callback" in 9 ms from then.

I like callbacks for "read" direction.

Best regards,
--
Tomasz Motylewski

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en

#2 lore raw
Quoted 5 lines
Quoted 4 lines

actually, it can't. if the user space application is delayed for precisely 1 buffer's worth of data, it will see the pointer at what appears to the the right place and believe that no xrun has occured. the only way around this is to provide either:

Quoted 7 lines

Well, but if you combine it with the current time information, then you will know whether the buffer has wrapped around or not - if you have 1000 ms of buffer, but always run 20 ms from the front, then if you notice 1010 ms has passed since the last action - then you have an overrun, even if the HW pointe r seems to be in the right place. So, configuration + mmaped buffer + gettimeoda y + HW pointer and I am happy.

you should trying playing with a system driven by varispeed word clock. you'll soon find that gettimeofday(2) is completely useless to you. the sample clock is the only clock that counts. say it twice every morning when you get up :)

Quoted 3 lines

And may be system call "mix data into buffer (start,
n_frames,data)" for atomic add. This provides minimum interference between programs (if they will agree on frame rate, format, etc.).

that is quite a big "if". still, the plughw layer can help with that i suppose.

Quoted 2 lines

Well, I use that method for reading data - I know how much samples I need to gather before I send them, so I may calculate how many ms to sleep. If I

if you have a kernel that will reliably sleep for 1ms, i envy you :)

Quoted 2 lines

But how did you do for writing data to the card? Are your read and write buffer HW synchronized?

i used the same technique as for reading. the buffer gets scribbled with a bit pattern and we look for the "leading edge" location with two bytes containing the special pattern. this minimizes the problems caused by actual sample values that match that pattern. the chances of two in a row doing so are so small as to be mostly ignorable.

but note: this technique doesn't work so well for PCI cards because of the bus transfer block size.

--p

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en