Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@caiaq.de>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de
Subject: [PATCH 2/3] ALSA: snd-usb-caiaq: set up internal sample pointer positions in trigger callback
Date: Fri, 10 Sep 2010 11:55:00 +0800	[thread overview]
Message-ID: <1284090901-4533-2-git-send-email-daniel@caiaq.de> (raw)
In-Reply-To: <1284090901-4533-1-git-send-email-daniel@caiaq.de>

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;
-- 
1.7.0.4

  reply	other threads:[~2010-09-10  3:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-10  3:54 [PATCH 1/3] ALSA: snd-usb-caiaq: drop version number Daniel Mack
2010-09-10  3:55 ` Daniel Mack [this message]
2010-09-10  7:27   ` [PATCH 2/3] ALSA: snd-usb-caiaq: set up internal sample pointer positions in trigger callback Clemens Ladisch
2010-09-10  8:10     ` Daniel Mack
2010-09-10  3:55 ` [PATCH 3/3] ALSA: snd-usb-caiaq: Add support for Traktor Kontrol S4 Daniel Mack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1284090901-4533-2-git-send-email-daniel@caiaq.de \
    --to=daniel@caiaq.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox