mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
Added support for auto mmap. Much improved version of pcm_share (without async signals)
This commit is contained in:
parent
8d3919707e
commit
9a435c2d93
14 changed files with 621 additions and 328 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue