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)
Thu, Oct 1, 6:02 PM
Unknown Object (File)
Fri, Sep 18, 11:45 PM
Unknown Object (File)
Fri, Sep 18, 11:40 PM
Unknown Object (File)
Fri, Sep 18, 11:32 PM
Unknown Object (File)
Thu, Sep 17, 3:56 PM
Unknown Object (File)
Fri, Sep 11, 6:56 AM
Unknown Object (File)
Thu, Sep 10, 10:15 PM
Unknown Object (File)
Mon, Sep 7, 3:41 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.