Added support for auto mmap. Much improved version of pcm_share (without async signals)

This commit is contained in:
Abramo Bagnara 2000-10-20 09:18:13 +00:00
parent 8d3919707e
commit 9a435c2d93
14 changed files with 621 additions and 328 deletions

View file

@ -322,19 +322,10 @@ int snd_pcm_plugin_mmap(snd_pcm_t *pcm)
i = calloc(1, sizeof(*i));
if (!i)
return -ENOMEM;
i->type = SND_PCM_MMAP_USER;
i->size = snd_pcm_frames_to_bytes(pcm, pcm->setup.buffer_size);
i->u.user.shmid = shmget(IPC_PRIVATE, i->size, 0666);
if (i->u.user.shmid < 0) {
SYSERR("shmget failed");
err = snd_pcm_alloc_user_mmap(pcm, i);
if (err < 0) {
free(i);
return -errno;
}
i->addr = shmat(i->u.user.shmid, 0, 0);
if (i->addr == (void*) -1) {
SYSERR("shmat failed");
free(i);
return -errno;
return err;
}
pcm->mmap_info = i;
pcm->mmap_info_count = 1;
@ -348,14 +339,9 @@ int snd_pcm_plugin_munmap(snd_pcm_t *pcm)
int err = snd_pcm_munmap(slave);
if (err < 0)
return err;
if (shmdt(pcm->mmap_info->addr) < 0) {
SYSERR("shmdt failed");
return -errno;
}
if (shmctl(pcm->mmap_info->u.user.shmid, IPC_RMID, 0) < 0) {
SYSERR("shmctl IPC_RMID failed");
return -errno;
}
err = snd_pcm_free_mmap(pcm, pcm->mmap_info);
if (err < 0)
return err;
free(pcm->mmap_info);
pcm->mmap_info_count = 0;
pcm->mmap_info = 0;