Skip to contentSkip to conversation

ALSA: aloop: Mark paused device as inactive

PATCH In review Robert Rosengren 2 participants 4 messages Mar 26, 2018 – Mar 27, 2018 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: aloop: Mark paused device as inactive

Show paused ALSA aloop device as inactive, i.e. the control "PCM Slave Active" set as false. Notification sent upon state change.

This makes it possible for client capturing from aloop device to know if data is expected. Without it the client expects data even if playback is paused.

---
 sound/drivers/aloop.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
sound/drivers/aloop.c +9 -3
index 0333143a1fa7..5404ab11132d 100644
@@ -291,6 +291,8 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		cable->pause |= stream;
 		loopback_timer_stop(dpcm);
 		spin_unlock(&cable->lock);
+		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+			loopback_active_notify(dpcm);
 		break;
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 	case SNDRV_PCM_TRIGGER_RESUME:
@@ -299,6 +301,8 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		cable->pause &= ~stream;
 		loopback_timer_start(dpcm);
 		spin_unlock(&cable->lock);
+		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+			loopback_active_notify(dpcm);
 		break;
 	default:
 		return -EINVAL;
@@ -879,9 +883,11 @@ static int loopback_active_get(struct snd_kcontrol *kcontrol,
 			[kcontrol->id.subdevice][kcontrol->id.device ^ 1];
 	unsigned int val = 0;
 
-	if (cable != NULL)
-		val = (cable->running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) ?
-									1 : 0;
+	if (cable != NULL) {
+		unsigned int running = cable->running ^ cable->pause;
+
+		val = (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) ? 1 : 0;
+	}
 	ucontrol->value.integer.value[0] = val;
 	return 0;
 }
Signature · 1 line
2.11.0
#1 lore raw
Quoted 9 lines · Robert Rosengren

Show paused ALSA aloop device as inactive, i.e. the control "PCM Slave Active" set as false. Notification sent upon state change.

This makes it possible for client capturing from aloop device to know if data is expected. Without it the client expects data even if playback is paused.

The code change looks good, but just to be sure:
you've submitted from the address [email protected] that is different from the sign-off [email protected]. Is this intentional? The former is recorded as the author in git history.

thanks,

Takashi

#2 lore raw
Quoted 18 lines · Takashi Iwai
Quoted 9 lines · Robert Rosengren

Show paused ALSA aloop device as inactive, i.e. the control "PCM Slave Active" set as false. Notification sent upon state change.

This makes it possible for client capturing from aloop device to know if data is expected. Without it the client expects data even if playback is paused.

The code change looks good, but just to be sure:
you've submitted from the address [email protected] that is different from the sign-off [email protected]. Is this intentional? The former is recorded as the author in git history.

Quoted 4 lines

thanks,

Takashi

Sorry for the confusion. It is not intentional to use different though both are valid, apparently I have used the longer one in earlier patches to kernel so please change:

Thanks for letting me know!
Robert

#3 lore raw
Quoted 20 lines · Robert Rosengren
Quoted 18 lines · Takashi Iwai
Quoted 9 lines · Robert Rosengren

Show paused ALSA aloop device as inactive, i.e. the control "PCM Slave Active" set as false. Notification sent upon state change.

This makes it possible for client capturing from aloop device to know if data is expected. Without it the client expects data even if playback is paused.

The code change looks good, but just to be sure:
you've submitted from the address [email protected] that is different from the sign-off [email protected]. Is this intentional? The former is recorded as the author in git history.

Quoted 7 lines
Quoted 4 lines

thanks,

Takashi

Sorry for the confusion. It is not intentional to use different though both are valid, apparently I have used the longer one in earlier patches to kernel so please change:

OK, applied now. Thanks.

Takashi