Skip to content

Commit

Permalink
ALSA: compress: Don't allow paritial drain operations on capture streams
Browse files Browse the repository at this point in the history
Partial drain and next track are intended for gapless playback and
don't really have an obvious interpretation for a capture stream, so
makes sense to not allow those operations on capture streams.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Charles Keepax authored and Takashi Iwai committed Jul 23, 2019
1 parent 26c3f15 commit a70ab8a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ static int snd_compr_next_track(struct snd_compr_stream *stream)
if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
return -EPERM;

/* next track doesn't have any meaning for capture streams */
if (stream->direction == SND_COMPRESS_CAPTURE)
return -EPERM;

/* you can signal next track if this is intended to be a gapless stream
* and current track metadata is set
*/
Expand Down Expand Up @@ -861,6 +865,10 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
break;
}

/* partial drain doesn't have any meaning for capture streams */
if (stream->direction == SND_COMPRESS_CAPTURE)
return -EPERM;

/* stream can be drained only when next track has been signalled */
if (stream->next_track == false)
return -EPERM;
Expand Down

0 comments on commit a70ab8a

Please sign in to comment.