]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm:mmap_emul: Fix sw_params and others in bypass mode
authorTakashi Iwai <tiwai@suse.de>
Mon, 14 Nov 2011 16:02:40 +0000 (17:02 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 15 Nov 2011 06:58:35 +0000 (07:58 +0100)
When the slave doesn't need any mmap-emulation, the plugin shouldn't do
anything special in sw_params and other callbacks but just pass to the
generic helpers and update hwptr and applptr.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_mmap_emul.c

index f6e7ae932ee96f64b313471a34a1adeccc73582e..664e9077dedba28f21d626067d5dd4378300533f 100644 (file)
@@ -212,6 +212,9 @@ static int snd_pcm_mmap_emul_sw_params(snd_pcm_t *pcm,
        mmap_emul_t *map = pcm->private_data;
        int err;
 
+       if (!map->mmap_emul)
+               return snd_pcm_generic_sw_params(pcm, params);
+
        map->start_threshold = params->start_threshold;
 
        /* HACK: don't auto-start in the slave PCM */
@@ -317,9 +320,9 @@ snd_pcm_mmap_emul_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset,
        mmap_emul_t *map = pcm->private_data;
        snd_pcm_t *slave = map->gen.slave;
 
+       snd_pcm_mmap_appl_forward(pcm, size);
        if (!map->mmap_emul)
                return snd_pcm_mmap_commit(slave, offset, size);
-       snd_pcm_mmap_appl_forward(pcm, size);
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
                sync_slave_write(pcm);
        return size;
@@ -332,10 +335,7 @@ static snd_pcm_sframes_t snd_pcm_mmap_emul_avail_update(snd_pcm_t *pcm)
        snd_pcm_sframes_t avail;
 
        avail = snd_pcm_avail_update(slave);
-       if (!map->mmap_emul)
-               return avail;
-
-       if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
+       if (!map->mmap_emul || pcm->stream == SND_PCM_STREAM_PLAYBACK)
                map->hw_ptr = *slave->hw.ptr;
        else
                sync_slave_read(pcm);