pcm - fix the buffer allocation for NONINTERLEAVED mmap access

The previous code did not allocated a separate buffer for all channels
when a NONINTERLEAVED access was used. The result was that only one
"shared" buffer was incorrectly allocated.

Also, the code was a bit cleaned (cosmetic change only).
This commit is contained in:
Jaroslav Kysela 2006-01-02 12:16:59 +00:00
parent 2f65643c1c
commit b08e01ca9e

View file

@ -326,10 +326,16 @@ int snd_pcm_mmap(snd_pcm_t *pcm)
for (c = 0; c < pcm->channels; ++c) {
snd_pcm_channel_info_t *i = &pcm->mmap_channels[c];
snd_pcm_channel_area_t *a = &pcm->running_areas[c];
unsigned int c1;
if (!i->addr) {
char *ptr;
size_t size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits;
size_t size;
unsigned int c1;
if (i->addr) {
a->addr = i->addr;
a->first = i->first;
a->step = i->step;
continue;
}
size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits;
for (c1 = c + 1; c1 < pcm->channels; ++c1) {
snd_pcm_channel_info_t *i1 = &pcm->mmap_channels[c1];
size_t s;
@ -434,15 +440,17 @@ int snd_pcm_mmap(snd_pcm_t *pcm)
case SND_PCM_AREA_SHM:
if (i1->u.shm.shmid != i->u.shm.shmid)
continue;
break;
/* follow thru */
case SND_PCM_AREA_LOCAL:
if (pcm->access != SND_PCM_ACCESS_MMAP_INTERLEAVED &&
pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED)
continue;
break;
default:
assert(0);
}
i1->addr = i->addr;
}
}
a->addr = i->addr;
a->first = i->first;
a->step = i->step;