Page MenuHomeFreeBSD

sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c
ClosedPublic

Authored by christos on Apr 27 2024, 8:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 27, 6:53 PM
Unknown Object (File)
Dec 5 2024, 8:53 AM
Unknown Object (File)
Sep 18 2024, 4:38 PM
Unknown Object (File)
Sep 18 2024, 6:15 AM
Unknown Object (File)
Sep 17 2024, 6:38 PM
Unknown Object (File)
Sep 17 2024, 9:21 AM
Unknown Object (File)
Sep 11 2024, 6:01 PM
Unknown Object (File)
Sep 9 2024, 9:25 PM
Subscribers

Details

Summary

Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added inline comments.
sys/dev/sound/pcm/channel.c
1338

Since ref can be negative, it would be nice to assert against underflow while you're here. i.e., if ref < 0, then we'd better have c->refcount >= -ref.

This revision is now accepted and ready to land.Apr 27 2024, 11:17 PM
sys/dev/sound/pcm/channel.c
1338

Wouldn't it be better to just assert than c->refcount >= 0?

sys/dev/sound/pcm/channel.c
1338

It's generally better to assert before performing the operation, but yes that works too.

sys/dev/sound/pcm/channel.c
1338

Actually I think what we need to do is check if c->refcount + ref >= 0, not c->refcount >= 0:

	KASSERT((c->refcount + ref) >= 0,
	    ("%s(): new refcount will be negative", __func__));
sys/dev/sound/pcm/channel.c
1338

Seems ok to me.