Page MenuHomeFreeBSD

Example of basic OSS audio application
ClosedPublic

Authored by meka_tilda.center on May 6 2021, 5:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 18, 3:42 PM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Unknown Object (File)
Mar 9 2024, 9:35 AM
Subscribers

Details

Summary

Few years back I decided to research audio and DSP. Being FreeBSD user, OSS came as natural choice, but finding good example to start with was really hard. Over time I wrote down what I use when starting any audio development and I think it's in a shape where I can share. I don't think it's even nearly perfect, but I'm sure that with community input on how to improve this example, I can make it shine :)

I would like to try and make it easier for the next person learning about FreeBSD OSS in areas of audio, midi and mixing, so hopefully this is first in the series of patches.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

meka_tilda.center created this revision.

C- and H- files should be styled (using ident for example) an carry the 2-clause BSD license.

indent -Toss_mixerinfo -TFILE -Tu_char -Tu_int -Tu_long \
 -TTAILQ_HEAD -TLIST_HEAD -TTAILQ_ENTRY -TLIST_ENTRY \
 -TSTAILQ_HEAD -TSTAILQ_ENTRY \
 -Tu_short -Tfd_set -ta -st -bad -bap -nbbb -nbc -br -nbs \
 -c41 -cd41 -cdb -ce -ci4 -cli0 -d0 -di8 -ndj -ei -nfc1 \
 -nfcb -i8 -ip8 -l79 -lc77 -ldi0 -nlp -npcs -psl -sc \
 -nsob -nv | 
 sed -e "s/_HEAD [(]/_HEAD(/g" |
 sed -e "s/_ENTRY [(]/_ENTRY(/g" |
 sed -e "s/	__packed/ __packed/g" | 
 sed -e "s/	__aligned/ __aligned/g" |
 sed -e "s/^#define /#define	/g"

I didn't even know indent exists. Thank you!

share/examples/sound/basic.c
26–27

A small question: Do we get used to VLA now?

pstef added inline comments.
share/examples/sound/basic.c
27

I don't mind VLAs, but they shouldn't be unbounded.

28

style nit: please don't cast malloc().

37

style nit: wrong indentation; should be better after indent run as suggested by hselasky.

40

style nit: as per style(9), "forever loops are done with for's, not while's"

share/examples/sound/ossinit.h
7

style nit: as per style(9), "Kernel include files (sys/*.h) come first"

I fixed all from previous comments, except printf formating. I tried to mimic pf.c: https://cgit.freebsd.org/src/tree/sys/netpfil/pf/pf.c#n646 where arguments are on the next line 4 spaces indented to the right relative to start of function name. I also read style(9) one more time and I can't find what I did wrong, so if it's still wrong, please advise.

share/examples/sound/ossinit.h
59

C-functions in header files should read:

static inline ....

meka_tilda.center marked 5 inline comments as done.

Make internal functions static

Please also add the inline keyword.

meka_tilda.center marked an inline comment as done.

My apologies, I missinterpreted the "inline" part.

share/examples/sound/README
2

Briefly summarised, a general audio application will:

51

accordingly

share/examples/sound/basic.c
2

Please add a standard 2-clause BSD license here.

41

Check the return code from read/write and break the loop if not all data was read/written.

53

return (0);

share/examples/sound/ossinit.h
2

Please add a regular 2-clause BSD license here.

You also need to patch some Makefile to install this.

bcr added a subscriber: bcr.

OK from manpages,

In addition to indent you can use clang-format (from e.g. installed llvm12). Something like clang-format12 share/examples/sound/basic.c > basic.c.formatted and then compare the file against the formatted one. It can also in-place edit with -i.

Is there anything I can improve? Did I miss something?

This revision is now accepted and ready to land.Jun 26 2021, 11:43 AM

Any updates here? Who is merging this?

Any updates here? Who is merging this?

Oops I missed that. I should have merged this few weeks ago.

This revision was automatically updated to reflect the committed changes.