From: Jaroslav Kysela Date: Fri, 8 Aug 2003 09:06:41 +0000 (+0000) Subject: Takashi: added shadow pcm to avoid problem with plug plugin and mmaped access X-Git-Tag: v1.0.3~113 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=63c19961b9d74dcbcd2d9186c75c86ad3da253a2;p=alsa-lib.git Takashi: added shadow pcm to avoid problem with plug plugin and mmaped access --- diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 48ba437a..3a66af6e 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -201,6 +201,7 @@ struct _snd_pcm { snd_pcm_rbptr_t hw; snd_pcm_uframes_t min_align; int mmap_rw; + int shadow_mmap; int donot_close; snd_pcm_channel_info_t *mmap_channels; snd_pcm_channel_area_t *running_areas; diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index b02115a5..6d525ebc 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -295,6 +295,8 @@ int snd_pcm_mmap(snd_pcm_t *pcm) err = pcm->ops->mmap(pcm); if (err < 0) return err; + if (pcm->shadow_mmap) + return 0; pcm->mmap_channels = calloc(pcm->channels, sizeof(pcm->mmap_channels[0])); if (!pcm->mmap_channels) return -ENOMEM; @@ -427,6 +429,8 @@ int snd_pcm_munmap(snd_pcm_t *pcm) unsigned int c; assert(pcm); assert(pcm->mmap_channels); + if (pcm->shadow_mmap) + return pcm->ops->munmap(pcm); for (c = 0; c < pcm->channels; ++c) { snd_pcm_channel_info_t *i = &pcm->mmap_channels[c]; unsigned int c1; diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index a3efda65..b3f43b9d 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -937,13 +937,23 @@ static int snd_pcm_plug_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *inf return snd_pcm_channel_info(plug->slave, info); } -static int snd_pcm_plug_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED) +static int snd_pcm_plug_mmap(snd_pcm_t *pcm) { + snd_pcm_plug_t *plug = pcm->private_data; + pcm->mmap_channels = plug->slave->mmap_channels; + pcm->running_areas = plug->slave->running_areas; + pcm->stopped_areas = plug->slave->stopped_areas; + pcm->shadow_mmap = 1; return 0; } -static int snd_pcm_plug_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED) +static int snd_pcm_plug_munmap(snd_pcm_t *pcm) { + // snd_pcm_plug_t *plug = pcm->private_data; + pcm->mmap_channels = NULL; + pcm->running_areas = NULL; + pcm->stopped_areas = NULL; + pcm->shadow_mmap = 0; return 0; }