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
F86148090: D44985.id137796.diff
Sun, Jun 16, 3:47 AM
Unknown Object (File)
Thu, May 23, 1:38 PM
Unknown Object (File)
Thu, May 23, 12:16 PM
Unknown Object (File)
May 16 2024, 4:58 PM
Unknown Object (File)
May 13 2024, 12:51 PM
Unknown Object (File)
May 7 2024, 11:56 AM
Unknown Object (File)
May 2 2024, 2:08 AM
Unknown Object (File)
Apr 30 2024, 6:01 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 57419
Build 54307: arc lint + arc unit

Event Timeline

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

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
1329

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

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

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

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

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
1329

Seems ok to me.