[v2,2/8] ALSA: aloop: loopback_timer_start: Support return of error code
diff mbox series

Message ID 20191105143218.5948-3-andrew_gabbasov@mentor.com
State New
Headers show
Series
  • ALSA: aloop: Support sound timer as clock source instead of jiffies
Related show

Commit Message

Andrew Gabbasov Nov. 5, 2019, 2:32 p.m. UTC
From: Timo Wischer <twischer@de.adit-jv.com>

This is required for additional timer implementations which could detect
errors and want to throw them.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
---
 sound/drivers/aloop.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Takashi Iwai Nov. 6, 2019, 3:50 p.m. UTC | #1
On Tue, 05 Nov 2019 15:32:12 +0100,
Andrew Gabbasov wrote:
> 
> @@ -264,7 +266,7 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
>  		spin_lock(&cable->lock);	
>  		cable->running |= stream;
>  		cable->pause &= ~stream;
> -		loopback_timer_start(dpcm);
> +		err = loopback_timer_start(dpcm);
>  		spin_unlock(&cable->lock);
>  		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
>  			loopback_active_notify(dpcm);

Will we notify even if the start/stop fails?


thanks,

Takashi

Patch
diff mbox series

diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 1f5982e09025..b9ee5b72a996 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -155,7 +155,7 @@  static inline unsigned int get_rate_shift(struct loopback_pcm *dpcm)
 }
 
 /* call in cable->lock */
-static void loopback_timer_start(struct loopback_pcm *dpcm)
+static int loopback_timer_start(struct loopback_pcm *dpcm)
 {
 	unsigned long tick;
 	unsigned int rate_shift = get_rate_shift(dpcm);
@@ -171,6 +171,8 @@  static void loopback_timer_start(struct loopback_pcm *dpcm)
 	tick = dpcm->period_size_frac - dpcm->irq_pos;
 	tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps;
 	mod_timer(&dpcm->timer, jiffies + tick);
+
+	return 0;
 }
 
 /* call in cable->lock */
@@ -251,7 +253,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct loopback_pcm *dpcm = runtime->private_data;
 	struct loopback_cable *cable = dpcm->cable;
-	int err, stream = 1 << substream->stream;
+	int err = 0, stream = 1 << substream->stream;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -264,7 +266,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		spin_lock(&cable->lock);	
 		cable->running |= stream;
 		cable->pause &= ~stream;
-		loopback_timer_start(dpcm);
+		err = loopback_timer_start(dpcm);
 		spin_unlock(&cable->lock);
 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 			loopback_active_notify(dpcm);
@@ -292,7 +294,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		spin_lock(&cable->lock);
 		dpcm->last_jiffies = jiffies;
 		cable->pause &= ~stream;
-		loopback_timer_start(dpcm);
+		err = loopback_timer_start(dpcm);
 		spin_unlock(&cable->lock);
 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 			loopback_active_notify(dpcm);
@@ -300,7 +302,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 	default:
 		return -EINVAL;
 	}
-	return 0;
+	return err;
 }
 
 static void params_change(struct snd_pcm_substream *substream)