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)
Sun, Mar 9, 8:53 AM
Unknown Object (File)
Feb 22 2025, 2:28 PM
Unknown Object (File)
Feb 22 2025, 2:01 PM
Unknown Object (File)
Feb 22 2025, 1:28 PM
Unknown Object (File)
Feb 10 2025, 6:45 PM
Unknown Object (File)
Feb 10 2025, 11:07 AM
Unknown Object (File)
Feb 10 2025, 3:37 AM
Unknown Object (File)
Feb 9 2025, 7:47 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.