mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
sound: Merge pcm_chn_destroy() and chn_kill()
pcm_chn_destroy() acts like a wrapper around chn_kill(), and additionally calls a few more functions that should in fact be part of chn_kill()'s logic. Merge pcm_chn_destroy()'s functionality in chn_kill() to improve readability, as well as code layering. While here, convert chn_kill() to void as it currently always returns 0. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44984
This commit is contained in:
parent
25723d6636
commit
b3ea087c05
|
@ -1279,11 +1279,13 @@ chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
chn_kill(struct pcm_channel *c)
|
||||
{
|
||||
struct snd_dbuf *b = c->bufhard;
|
||||
struct snd_dbuf *bs = c->bufsoft;
|
||||
struct snd_dbuf *b = c->bufhard;
|
||||
struct snd_dbuf *bs = c->bufsoft;
|
||||
|
||||
PCM_BUSYASSERT(c->parentsnddev);
|
||||
|
||||
if (CHN_STARTED(c)) {
|
||||
CHN_LOCK(c);
|
||||
|
@ -1299,8 +1301,8 @@ chn_kill(struct pcm_channel *c)
|
|||
CHN_LOCK(c);
|
||||
c->flags |= CHN_F_DEAD;
|
||||
chn_lockdestroy(c);
|
||||
|
||||
return (0);
|
||||
kobj_delete(c->methods, M_DEVBUF);
|
||||
free(c, M_DEVBUF);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -260,7 +260,7 @@ int chn_flush(struct pcm_channel *c);
|
|||
int chn_poll(struct pcm_channel *c, int ev, struct thread *td);
|
||||
|
||||
int chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction);
|
||||
int chn_kill(struct pcm_channel *c);
|
||||
void chn_kill(struct pcm_channel *c);
|
||||
void chn_shutdown(struct pcm_channel *c);
|
||||
int chn_reset(struct pcm_channel *c, u_int32_t fmt, u_int32_t spd);
|
||||
int chn_setvolume_multi(struct pcm_channel *c, int vc, int left, int right,
|
||||
|
|
|
@ -515,28 +515,6 @@ pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t c
|
|||
return (ch);
|
||||
}
|
||||
|
||||
int
|
||||
pcm_chn_destroy(struct pcm_channel *ch)
|
||||
{
|
||||
struct snddev_info *d __diagused;
|
||||
int err;
|
||||
|
||||
d = ch->parentsnddev;
|
||||
PCM_BUSYASSERT(d);
|
||||
|
||||
err = chn_kill(ch);
|
||||
if (err) {
|
||||
device_printf(ch->dev, "chn_kill(%s) failed, err = %d\n",
|
||||
ch->name, err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
kobj_delete(ch->methods, M_DEVBUF);
|
||||
free(ch, M_DEVBUF);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch)
|
||||
{
|
||||
|
@ -630,7 +608,7 @@ pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
|
|||
if (err) {
|
||||
device_printf(d->dev, "pcm_chn_add(%s) failed, err=%d\n",
|
||||
ch->name, err);
|
||||
pcm_chn_destroy(ch);
|
||||
chn_kill(ch);
|
||||
}
|
||||
|
||||
return (err);
|
||||
|
@ -678,7 +656,7 @@ pcm_killchans(struct snddev_info *d)
|
|||
error = pcm_chn_remove(d, ch);
|
||||
PCM_UNLOCK(d);
|
||||
if (error == 0)
|
||||
pcm_chn_destroy(ch);
|
||||
chn_kill(ch);
|
||||
} while (!CHN_EMPTY(d, channels.pcm));
|
||||
}
|
||||
|
||||
|
|
|
@ -300,7 +300,6 @@ int pcm_chnrelease(struct pcm_channel *c);
|
|||
int pcm_chnref(struct pcm_channel *c, int ref);
|
||||
|
||||
struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, int num, void *devinfo);
|
||||
int pcm_chn_destroy(struct pcm_channel *ch);
|
||||
int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch);
|
||||
int pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch);
|
||||
|
||||
|
|
|
@ -709,7 +709,7 @@ vchan_create(struct pcm_channel *parent, int num)
|
|||
ret = pcm_chn_add(d, ch);
|
||||
PCM_UNLOCK(d);
|
||||
if (ret != 0) {
|
||||
pcm_chn_destroy(ch);
|
||||
chn_kill(ch);
|
||||
CHN_LOCK(parent);
|
||||
return (ret);
|
||||
}
|
||||
|
@ -837,7 +837,7 @@ vchan_create(struct pcm_channel *parent, int num)
|
|||
PCM_LOCK(d);
|
||||
if (pcm_chn_remove(d, ch) == 0) {
|
||||
PCM_UNLOCK(d);
|
||||
pcm_chn_destroy(ch);
|
||||
chn_kill(ch);
|
||||
} else
|
||||
PCM_UNLOCK(d);
|
||||
CHN_LOCK(parent);
|
||||
|
@ -890,7 +890,7 @@ vchan_destroy(struct pcm_channel *c)
|
|||
|
||||
/* destroy ourselves */
|
||||
if (ret == 0)
|
||||
ret = pcm_chn_destroy(c);
|
||||
chn_kill(c);
|
||||
|
||||
CHN_LOCK(parent);
|
||||
|
||||
|
|
Loading…
Reference in a new issue