-static int snd_pcm_shm_drain(snd_pcm_t *pcm)
-{
- snd_pcm_shm_t *shm = pcm->private;
- snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
- int err;
- ctrl->cmd = SND_PCM_IOCTL_DRAIN;
- err = snd_pcm_shm_action(pcm);
- if (err < 0)
- return err;
- if (!(pcm->mode & SND_PCM_NONBLOCK))
- snd_pcm_wait(pcm, -1);
- return err;
-}
-
-static int snd_pcm_shm_close(snd_pcm_t *pcm)
-{
- snd_pcm_shm_t *shm = pcm->private;
- snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
- int result;
- if (!(pcm->mode & SND_PCM_NONBLOCK))
- snd_pcm_shm_drain(pcm);
- ctrl->cmd = SND_PCM_IOCTL_CLOSE;
- result = snd_pcm_shm_action(pcm);
- shmdt((void *)ctrl);
- close(shm->socket);
- close(pcm->poll_fd);
- free(shm);
- return result;
-}
-