User Details
- User Since
- Aug 19 2019, 8:59 AM (347 w, 5 d)
Jan 10 2026
I rebased this patch, but the problem is that I don't have the hardware to test it. I'll try to find cheap PCIe card to test this patch.
Jan 2 2026
Oh, it works on 15.0-RELEASE, so no wonder I wrote this patch so easily: it doesn't do anything 😄
Dec 27 2025
As midi_destroy will be removed, adapt this patch for that.
Dec 26 2025
Use lock instead of qlock which will be removed in the future.
Dec 25 2025
Dec 18 2025
The official example at http://manuals.opensound.com/developer/mmap_test.c.html uses 50ms but that proved to be too much, probably because oss_init() sets low sized buffer. I'm not sure how to derive the number of microseconds to sleep, I just used the value that worked for me. I even tried experimenting with different values, but I have no idea how to get to a value that is based on some facts or measurement.
Dec 17 2025
Reverting to a version which just waits for 0.4ms between iterations. I ran this program for ~100 times on my desktop and it didn't produce any glitches. Should I remove verbose or leave it as it is?
Dec 16 2025
Calculate the amount of microseconds to sleep, but keep it in the range between 400 and 800 microseconds. Position is not updated continuously, but at some frequency. That means that value we get from ioctl can not be trusted to be accurate, which is the reason to limit the maximum duration of the sleep. The minimal duration of sleep is put in place so the code doesn't call ioctl too often.
Dec 15 2025
Check if input and output config are the same by checking number of bytes and number of input/output channels. I had cases where input and output channel numbers are different, as well as difference in buffer_info.bytes when the number of input and output channels is the same. I'm afraid that handling all possible cases would make this example complicated, so I chose to write the code that insists that input and output configs are the same.
Dec 11 2025
Dec 8 2025
Warn only if sample format/rate/channels were not set to desired values, but fail only in simple.c if the format is not the requested one.
Dec 6 2025
Lowering usleep time and checking if ci.ptr is zero made all the glitches in the sound go away. I do need to run it for quite a few times to validate that, but in the worst case I significantly lowered the probability of gibberish on the output. Next, I need to calculate the usleep time based on ci.ptr.
Dec 5 2025
The usleep based mmap example based on official OSS example. There are three big things about it right now that make it not-so-perfect:
I think I'll try my luck with http://manuals.opensound.com/developer/mmap_test.c.html first and fit it into our example and once the usleep version works, see what are the values of ptr compared to the ones in kqueue scenario. My thinking is "if I can't fix it, move to simpler example", which I'm hoping the official docs are. Anyway, I didn't give up on this code, I just need to approach it from the different angle, for now.
Dec 4 2025
Give more info on failed set attempt
Fix copy/paste typo.
Check sample format, rate and channels after they are set.
Dec 3 2025
Check sample rate and format after ioctl call. While here, print sample size and number of channels of configured device.
Dec 2 2025
I am looking into the code in general and I want to figure out how to display information so it makes more sense, not just dump printf.
Nov 28 2025
Rebase after oss.h fix
Nov 26 2025
Remove needless include
Nov 20 2025
Map or allocate buffer in oss_init. For some reason with this patch probability of producing proper sound is way higher. I still have to add GETIPTR/GETOPTR checks and usleep based on the position.
Let me try to compensate the drift by reading SNDCTL_DSP_GETIPTR and SNDCTL_DSP_GETOPTR and experiment with that for a bit.
Nov 19 2025
I forgot to edit Makefile. Fixed now.
Remove extra functions as they are very simple
That's the strange thing. If I run it 20-30 times, I would get roughly half of the times distorted sound, half of the times normal sound. Also, I tried having one config and two events for read and write, but I couldn't produce any sound like that. Anyway, let me fix this example to conform to the comments and lets go from there.
Nov 14 2025
Nov 12 2025
I tested simple, select and poll on the real hardware. As that machine is not running CURRENT, I can't test kqueue. @christos, do you have any means on testing it on real hardware? I tried to test it in bhyve with -s 6,hda,play=/dev/dsp,rec=/dev/dsp but none of the examples work properly that way.
Reword comments and fix Makefile
I already fixed those as well as share/examples/Makefile, I just want to check if everything is working, and that has to wait for my day job to finish.
Nov 11 2025
I just realized I copy/pasted the same first license comment everywhere. Can you tell me what should I put in the "Copyright" lines, please?
Nov 10 2025
Improve comment regarding usage of interleaved format and channels.
I tested all examples with real hardware. Well, all except kqueue, as the machine with the actual hardware is 14.3 based.
Fix to_channels and to_interleaved and address other comments.
Nov 9 2025
Move contents of README into comments, mostly in oss.h
Nov 8 2025
More cleanup from old example
I just remembered one more comment I can't find. It is about setting fragments. I'd like to leave it there and in the comments mention that setting fragments is optional. I'd like to have a full examples so people interested in sound don't have to wonder how things are done. To be honest, official OSS documentation could use some improvement. At least I found it hard to understand what exactly I need to do.
Nov 7 2025
I hope I found all comments. It was not obvious I would have to click on a line number beside comment to get old comments.
Nov 6 2025
I missed old comments as I moved files from oss directory. It took me a while to realize how to read them. Sorry for the noise.
Nov 3 2025
I really hope this is OK way to handle 24 bits.
Nov 2 2025
The directory where these files live is "oss". As everything is about OSS in "sound" directory, should I perhaps rename oss to audio? My reasoning is that there are audio and MIDI examples that we can show, so "oss" is a bit missleading. Or maybe have share/examples/oss and audio and midi under it? Anyway, when I started writing the examples I only wrote audio part, so "sound" was appropriate, which probably isn't the case any more.
Use per-config buffer.
Nov 1 2025
Address the rest of the comments (without moving README to comments).
I hope I addressed all the comments except showing example for both polling directions and readme. I think if a person understands polling in one direction, it is easy to extrapolate how to work with two directions. As these are examples, not complete guides, I would argue that this is good enough, especially in kqueue case where both directions would create two events and example would become more complicated. As I do plan to add mmap example once this is merged, that example will have input device and output device so even that configuration will be shown, I just don't think that all examples should split the sound card into two directions. As for the readme, good catch, I didn't think of that, but let's make the code in the examples good and I'll change the readme to correspond to those changes.
Oct 31 2025
Add triggering.
Oct 25 2025
One more wrong device fixed
Use default DSP device
Oct 22 2025
Oct 21 2025
New sentences on new lines
Oct 20 2025
So, if I understand right, I should move oss_init into the test file and simplify it. What does it mean "simplify"? I guess mmap parts can be removed, but what else do you want gone? The thing is that I don't know what is the minimum that we can work with. Maybe just set sample format and remove all the rest? Also, what should I do with oss.h then? I mean, everything in that file is made just so the oss_init would work.
Oct 19 2025
Running polling:poll_select for the first time in VM exposes LOR while polling:poll_kqueue panics the kernel. The reason I added oss.h is to be able to use those common functions and structures in mmap based test that I have yet to write.
Oct 18 2025
Fixed typos
Oct 17 2025
Most notable change is removal of example, I'll add it in a new revision.
Oct 12 2025
I was wrong about what SNDCTL_DSP_GETOSPACE and SNDCTL_DSP_GETISPACE do, hence the update.
While at it, I decided to add all polling/events into one example.
I changed the code based on the comments, but I didn't add test program, yet. Give me some more time.
Oct 10 2025
Oct 2 2024
Sep 9 2024
Aug 20 2024
Apr 28 2024
I had to remove dev/sound/unit.c optional sound from sys/conf/files but otherwise it works.
Apr 11 2024
Works here, too. I did only the short test, but no EBUSY.
Jan 29 2024
Interesting. I just tested, and if I boot my machine while interface is on, kld_list and buffer_ms together do the trick. I mean, jack_iodelay reports exactly same latency as if I loaded the module, set buffer_ms and then turned on the interface. Maybe my interface is slow to respond initially, so sysctl has time to kick in? Anyway, if I were to do it differently, what should I do? Load module and set buffer_ms in loader.conf?
Jan 28 2024
A misunderstanding. I though you wanted me to make sure there are no reconnects. Anyway, loading the driver first, then setting buffer_ms and then turning on the interface yields the following results
period = 192 buffer_ms = 1 690.921 frames 14.394 ms total roundtrip latency extra loopback latency: 306 frames use 153 for the backend arguments -I and -O
Now this is a great improvement! Can we document it somewhere? Suggesting, for example, to put kld_list+=snd_uaudio and then set buffer_ms as any other sysctl? In my oppinion, if we spent so much time figuring out how to properly do the measurement, I'm sure other people will need help with their setup, too, so why not make it easier for them and put this into snd_uaudio(4).
Jan 27 2024
I didn't answer about re-plugging. No, the interface is always connected and I don't touch the cables.
I see what you mean. I tested with buffer_ms of 1 and 8 and I get almost exact numbers:
period = 192
Jan 22 2024
Main branch ----------- hw.usb.uaudio.buffer_ms = 8 period = 768 2563.934 frames 53.415 ms total roundtrip latency extra loopback latency: 1027 frames use 513 for the backend arguments -I and -O
Jan 21 2024
I missed 4ms request from you, so here are those measurements
Main branch ----------- hw.usb.uaudio.buffer_ms = 4 period = 768 3337.952 frames 69.541 ms total roundtrip latency extra loopback latency: 1033 frames use 516 for the backend arguments -I and -O
Thank you for the explanation. I took the measurement and I tried to get the lowest latency without jitters, so here is the complete measurement.
Main branch ----------- hw.usb.uaudio.buffer_ms = 2
Jan 19 2024
Sorry for the delay, I got sick (again). Anyway, it took me a while to figure out what's going on. As I didn't have speakers on, I didn't notice there are jitters, that's why the numbers don't match. I took similar measurements with higher period size in jack and these are the results
Main branch ----------- hw.usb.uaudio.buffer_ms = 2
Jan 17 2024
Jan 16 2024
An example
Ah, so, single argument with quotes. If broken into multiple lines with "\" it makes fwget's output weird, hence one huge line.
It would be better if addpkg supported multiple arguments, but with current implementation we have to use multiple invocations.