Date: Sat, 27 Jul 2024 11:56:31 GMT From: Christos Margiolis <christos@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 00172d20070a - main - sound: Simplify feeder_remove() Message-ID: <202407271156.46RBuVav040163@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=00172d20070a544e0514cce9f94475c5525fd15e commit 00172d20070a544e0514cce9f94475c5525fd15e Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-07-27 11:55:57 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-07-27 11:55:57 +0000 sound: Simplify feeder_remove() Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch, markj, emaste Differential Revision: https://reviews.freebsd.org/D46100 --- sys/dev/sound/pcm/channel.c | 6 ++---- sys/dev/sound/pcm/feeder.c | 14 ++++++-------- sys/dev/sound/pcm/feeder.h | 2 +- sys/dev/sound/pcm/feeder_chain.c | 3 +-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index ce4fb7222ddb..e0fd24805a21 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1324,8 +1324,7 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, return (c); fail: - while (feeder_remove(c) == 0) - ; + feeder_remove(c); if (c->devinfo && CHANNEL_FREE(c->methods, c->devinfo)) sndbuf_free(b); if (bs) @@ -1356,8 +1355,7 @@ chn_kill(struct pcm_channel *c) chn_trigger(c, PCMTRIG_ABORT); CHN_UNLOCK(c); } - while (feeder_remove(c) == 0) - ; + feeder_remove(c); if (CHANNEL_FREE(c->methods, c->devinfo)) sndbuf_free(b); sndbuf_destroy(bs); diff --git a/sys/dev/sound/pcm/feeder.c b/sys/dev/sound/pcm/feeder.c index ad6966331f02..716eb07feaae 100644 --- a/sys/dev/sound/pcm/feeder.c +++ b/sys/dev/sound/pcm/feeder.c @@ -248,18 +248,16 @@ feeder_add(struct pcm_channel *c, struct feeder_class *fc, struct pcm_feederdesc return 0; } -int +void feeder_remove(struct pcm_channel *c) { struct pcm_feeder *f; - if (c->feeder == NULL) - return -1; - f = c->feeder; - c->feeder = c->feeder->source; - feeder_destroy(f); - - return 0; + while (c->feeder != NULL) { + f = c->feeder; + c->feeder = c->feeder->source; + feeder_destroy(f); + } } struct pcm_feeder * diff --git a/sys/dev/sound/pcm/feeder.h b/sys/dev/sound/pcm/feeder.h index f2a865d3d2f9..1e240d934e94 100644 --- a/sys/dev/sound/pcm/feeder.h +++ b/sys/dev/sound/pcm/feeder.h @@ -60,7 +60,7 @@ u_int32_t snd_fmtbest(u_int32_t fmt, u_int32_t *fmts); int feeder_add(struct pcm_channel *c, struct feeder_class *fc, struct pcm_feederdesc *desc); -int feeder_remove(struct pcm_channel *c); +void feeder_remove(struct pcm_channel *c); struct pcm_feeder *feeder_find(struct pcm_channel *c, u_int32_t type); void feeder_printchain(struct pcm_feeder *head); int feeder_chain(struct pcm_channel *); diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c index 555cd86d60e5..588bae2ff281 100644 --- a/sys/dev/sound/pcm/feeder_chain.c +++ b/sys/dev/sound/pcm/feeder_chain.c @@ -588,8 +588,7 @@ feeder_chain(struct pcm_channel *c) CHN_LOCKASSERT(c); /* Remove everything first. */ - while (feeder_remove(c) == 0) - ; + feeder_remove(c); KASSERT(c->feeder == NULL, ("feeder chain not empty"));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407271156.46RBuVav040163>