diff options
Diffstat (limited to 'sound/core/compress_offload.c')
-rw-r--r-- | sound/core/compress_offload.c | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 99b882158705..41905afada63 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c | |||
@@ -574,10 +574,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) | |||
574 | stream->metadata_set = false; | 574 | stream->metadata_set = false; |
575 | stream->next_track = false; | 575 | stream->next_track = false; |
576 | 576 | ||
577 | if (stream->direction == SND_COMPRESS_PLAYBACK) | 577 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; |
578 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | ||
579 | else | ||
580 | stream->runtime->state = SNDRV_PCM_STATE_PREPARED; | ||
581 | } else { | 578 | } else { |
582 | return -EPERM; | 579 | return -EPERM; |
583 | } | 580 | } |
@@ -693,8 +690,17 @@ static int snd_compr_start(struct snd_compr_stream *stream) | |||
693 | { | 690 | { |
694 | int retval; | 691 | int retval; |
695 | 692 | ||
696 | if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED) | 693 | switch (stream->runtime->state) { |
694 | case SNDRV_PCM_STATE_SETUP: | ||
695 | if (stream->direction != SND_COMPRESS_CAPTURE) | ||
696 | return -EPERM; | ||
697 | break; | ||
698 | case SNDRV_PCM_STATE_PREPARED: | ||
699 | break; | ||
700 | default: | ||
697 | return -EPERM; | 701 | return -EPERM; |
702 | } | ||
703 | |||
698 | retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START); | 704 | retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START); |
699 | if (!retval) | 705 | if (!retval) |
700 | stream->runtime->state = SNDRV_PCM_STATE_RUNNING; | 706 | stream->runtime->state = SNDRV_PCM_STATE_RUNNING; |
@@ -705,9 +711,15 @@ static int snd_compr_stop(struct snd_compr_stream *stream) | |||
705 | { | 711 | { |
706 | int retval; | 712 | int retval; |
707 | 713 | ||
708 | if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || | 714 | switch (stream->runtime->state) { |
709 | stream->runtime->state == SNDRV_PCM_STATE_SETUP) | 715 | case SNDRV_PCM_STATE_OPEN: |
716 | case SNDRV_PCM_STATE_SETUP: | ||
717 | case SNDRV_PCM_STATE_PREPARED: | ||
710 | return -EPERM; | 718 | return -EPERM; |
719 | default: | ||
720 | break; | ||
721 | } | ||
722 | |||
711 | retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); | 723 | retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); |
712 | if (!retval) { | 724 | if (!retval) { |
713 | snd_compr_drain_notify(stream); | 725 | snd_compr_drain_notify(stream); |
@@ -795,9 +807,17 @@ static int snd_compr_drain(struct snd_compr_stream *stream) | |||
795 | { | 807 | { |
796 | int retval; | 808 | int retval; |
797 | 809 | ||
798 | if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || | 810 | switch (stream->runtime->state) { |
799 | stream->runtime->state == SNDRV_PCM_STATE_SETUP) | 811 | case SNDRV_PCM_STATE_OPEN: |
812 | case SNDRV_PCM_STATE_SETUP: | ||
813 | case SNDRV_PCM_STATE_PREPARED: | ||
814 | case SNDRV_PCM_STATE_PAUSED: | ||
800 | return -EPERM; | 815 | return -EPERM; |
816 | case SNDRV_PCM_STATE_XRUN: | ||
817 | return -EPIPE; | ||
818 | default: | ||
819 | break; | ||
820 | } | ||
801 | 821 | ||
802 | retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); | 822 | retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); |
803 | if (retval) { | 823 | if (retval) { |
@@ -817,6 +837,10 @@ static int snd_compr_next_track(struct snd_compr_stream *stream) | |||
817 | if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) | 837 | if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) |
818 | return -EPERM; | 838 | return -EPERM; |
819 | 839 | ||
840 | /* next track doesn't have any meaning for capture streams */ | ||
841 | if (stream->direction == SND_COMPRESS_CAPTURE) | ||
842 | return -EPERM; | ||
843 | |||
820 | /* you can signal next track if this is intended to be a gapless stream | 844 | /* you can signal next track if this is intended to be a gapless stream |
821 | * and current track metadata is set | 845 | * and current track metadata is set |
822 | */ | 846 | */ |
@@ -834,9 +858,23 @@ static int snd_compr_next_track(struct snd_compr_stream *stream) | |||
834 | static int snd_compr_partial_drain(struct snd_compr_stream *stream) | 858 | static int snd_compr_partial_drain(struct snd_compr_stream *stream) |
835 | { | 859 | { |
836 | int retval; | 860 | int retval; |
837 | if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || | 861 | |
838 | stream->runtime->state == SNDRV_PCM_STATE_SETUP) | 862 | switch (stream->runtime->state) { |
863 | case SNDRV_PCM_STATE_OPEN: | ||
864 | case SNDRV_PCM_STATE_SETUP: | ||
865 | case SNDRV_PCM_STATE_PREPARED: | ||
866 | case SNDRV_PCM_STATE_PAUSED: | ||
867 | return -EPERM; | ||
868 | case SNDRV_PCM_STATE_XRUN: | ||
869 | return -EPIPE; | ||
870 | default: | ||
871 | break; | ||
872 | } | ||
873 | |||
874 | /* partial drain doesn't have any meaning for capture streams */ | ||
875 | if (stream->direction == SND_COMPRESS_CAPTURE) | ||
839 | return -EPERM; | 876 | return -EPERM; |
877 | |||
840 | /* stream can be drained only when next track has been signalled */ | 878 | /* stream can be drained only when next track has been signalled */ |
841 | if (stream->next_track == false) | 879 | if (stream->next_track == false) |
842 | return -EPERM; | 880 | return -EPERM; |