Calling prepare() on a stream which is already active shouldn't touch the sample pointer positions. This code belongs into the trigger callback, so move it there.
Signed-off-by: Daniel Mack daniel@caiaq.de --- sound/usb/caiaq/audio.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 4328cad..db85320 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -194,21 +194,11 @@ static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) { int bytes_per_sample, bpp, ret, i; - int index = substream->number; struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
debug("%s(%p)\n", __func__, substream);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; - dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; - } else { - int in_pos = (dev->spec.data_alignment == 2) ? 0 : 2; - dev->period_in_count[index] = BYTES_PER_SAMPLE + in_pos; - dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE + in_pos; - } - if (dev->streaming) return 0;
@@ -251,10 +241,21 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) { + int index = sub->number; struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
switch (cmd) { case SNDRV_PCM_TRIGGER_START: + if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) { + dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; + dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; + } else { + int in_pos = (dev->spec.data_alignment == 2) ? 0 : 2; + dev->period_in_count[index] = BYTES_PER_SAMPLE + in_pos; + dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE + in_pos; + } + + /* fall thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: activate_substream(dev, sub); break;