Page MenuHomeFreeBSD

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

Authored by christos on Sat, Apr 27, 8:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 7, 11:56 AM
Unknown Object (File)
Thu, May 2, 2:08 AM
Unknown Object (File)
Tue, Apr 30, 6:01 PM
Unknown Object (File)
Mon, Apr 29, 10:13 PM
Unknown Object (File)
Mon, Apr 29, 6:44 PM
Unknown Object (File)
Mon, Apr 29, 6:01 PM
Unknown Object (File)
Mon, Apr 29, 1:39 AM
Unknown Object (File)
Sun, Apr 28, 9:52 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.Sat, Apr 27, 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.