From: "Gyeongtaek Lee" <gt82.lee@samsung.com>
To: "'Takashi Iwai'" <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, khw0178.kim@samsung.com,
lgirdwood@gmail.com, kimty@samsung.com,
'Pierre-Louis Bossart' <pierre-louis.bossart@linux.intel.com>,
tiwai@suse.com, vkoul@kernel.org, hmseo@samsung.com,
tkjung@samsung.com, pilsun.jang@samsung.com,
s47.kang@samsung.com
Subject: RE: [PATCH] ALSA: compress: allow pause and resume during draining
Date: Tue, 29 Sep 2020 17:40:51 +0900 [thread overview]
Message-ID: <000001d6963c$3cc53690$b64fa3b0$@samsung.com> (raw)
In-Reply-To: CGME20200929084051epcas2p35fb2228ed1bdfce6a7ddf5b37c944823@epcas2p3.samsung.com
On 9/29/20 04:13 PM, Takashi Iwai wrote:
>On Tue, 29 Sep 2020 03:51:35 +0200,
>Gyeongtaek Lee wrote:
>>
>> On 9/28/20 11:35 PM, Pierre-Louis Bossart wrote:
>> >On 9/28/20 6:13 AM, Jaroslav Kysela wrote:
>> >> Dne 28. 09. 20 v 12:50 Gyeongtaek Lee napsal(a):
>> >>> With a stream with low bitrate, user can't pause or resume the stream
>> >>> near the end of the stream because current ALSA doesn't allow it.
>> >>> If the stream has very low bitrate enough to store whole stream into
>> >>> the buffer, user can't do anything except stop the stream and then
>> >>> restart it from the first.
>> >>> If pause and resume is allowed during draining, user experience can be
>> >>> enhanced.
>> >>
>> >> It seems that we need a new state to handle the pause + drain condition for
>> >> this case.
>> >>
>> >> With this proposed change, the pause state in drain is invisible.
>> >
>> >Indeed it's be much nicer to have a new state, e..g
>> >SNDRV_PCM_STATE_DRAINING_PAUSED.
>> Ok. I will add the new state.
>> >
>> >One concern is that states are defined in uapi/sound/asoc.h, so wouldn't
>> >this have impacts on userspace as well? We'd change the value of
>> >SNDRV_PCM_STATE_LAST.
>> >
>> I also agree that adding new state and increase LAST value in the header of uapi
>> could be dangerous. So, I added it to comress_offload.h for now.
>> It could be merged into snd_pcm_state_t in someday with big changes.
>> Could you review the fixed patch below?
>
>Hrm, this resulted in rather more complex changes than the original
>patch. It shows that introducing yet another state is no good idea
>for this particular case.
>
>Since the possible application's behavior after this pause is as same
>as the normal pause (i.e. either resuming pause or dropping), I find
>it OK to take the original approach.
Thank you for the review.
I think that I should resend the original patch.
Am I right?
>
>
>thanks,
>
>Takashi
>
>> With a stream with low bitrate, user can't pause or resume the stream
>> near the end of the stream because current ALSA doesn't allow it.
>> If the stream has very low bitrate enough to store whole stream into
>> the buffer, user can't do anything except stop the stream and then
>> restart it from first.
>> If pause, resume are allowed during draining, user experience can be
>> enhanced.
>>
>> New state for pause during draining is defined in compress_offload.h for
>> now. If PCM_STATEs in uapi/sound/asound.h is changed, pcm libraries and
>> userspace application will be affected.
>>
>> Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
>> Cc: stable@vger.kernel.org
>> ---
>> include/uapi/sound/compress_offload.h | 3 ++
>> sound/core/compress_offload.c | 47 ++++++++++++++++++++++-----
>> 2 files changed, 41 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
>> index 7184265c0b0d..f30b9851d1d7 100644
>> --- a/include/uapi/sound/compress_offload.h
>> +++ b/include/uapi/sound/compress_offload.h
>> @@ -189,4 +189,7 @@ struct snd_compr_metadata {
>> #define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */
>> #define SND_COMPR_TRIGGER_NEXT_TRACK 8
>> #define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9
>> +
>> +/* FIXME move this to asound.h */
>> +#define SNDRV_PCM_STATE_DRAINING_PAUSED (SNDRV_PCM_STATE_LAST + 1)
>> #endif
>> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
>> index 0e53f6f31916..58fbe0d99431 100644
>> --- a/sound/core/compress_offload.c
>> +++ b/sound/core/compress_offload.c
>> @@ -151,6 +151,7 @@ static int snd_compr_free(struct inode *inode, struct file *f)
>> case SNDRV_PCM_STATE_RUNNING:
>> case SNDRV_PCM_STATE_DRAINING:
>> case SNDRV_PCM_STATE_PAUSED:
>> + case SNDRV_PCM_STATE_DRAINING_PAUSED:
>> data->stream.ops->trigger(&data->stream, SNDRV_PCM_TRIGGER_STOP);
>> break;
>> default:
>> @@ -431,6 +432,7 @@ static __poll_t snd_compr_poll(struct file *f, poll_table *wait)
>> case SNDRV_PCM_STATE_RUNNING:
>> case SNDRV_PCM_STATE_PREPARED:
>> case SNDRV_PCM_STATE_PAUSED:
>> + case SNDRV_PCM_STATE_DRAINING_PAUSED:
>> if (avail >= stream->runtime->fragment_size)
>> retval = snd_compr_get_poll(stream);
>> break;
>> @@ -708,11 +710,23 @@ static int snd_compr_pause(struct snd_compr_stream *stream)
>> {
>> int retval;
>>
>> - if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
>> + switch (stream->runtime->state) {
>> + case SNDRV_PCM_STATE_RUNNING:
>> + retval = stream->ops->trigger(stream,
>> + SNDRV_PCM_TRIGGER_PAUSE_PUSH);
>> + if (!retval)
>> + stream->runtime->state = SNDRV_PCM_STATE_PAUSED;
>> + break;
>> + case SNDRV_PCM_STATE_DRAINING:
>> + retval = stream->ops->trigger(stream,
>> + SNDRV_PCM_TRIGGER_PAUSE_PUSH);
>> + if (!retval)
>> + stream->runtime->state =
>> + SNDRV_PCM_STATE_DRAINING_PAUSED;
>> + break;
>> + default:
>> return -EPERM;
>> - retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_PUSH);
>> - if (!retval)
>> - stream->runtime->state = SNDRV_PCM_STATE_PAUSED;
>> + }
>> return retval;
>> }
>>
>> @@ -720,11 +734,22 @@ static int snd_compr_resume(struct snd_compr_stream *stream)
>> {
>> int retval;
>>
>> - if (stream->runtime->state != SNDRV_PCM_STATE_PAUSED)
>> + switch (stream->runtime->state) {
>> + case SNDRV_PCM_STATE_PAUSED:
>> + retval = stream->ops->trigger(stream,
>> + SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
>> + if (!retval)
>> + stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
>> + break;
>> + case SNDRV_PCM_STATE_DRAINING_PAUSED:
>> + retval = stream->ops->trigger(stream,
>> + SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
>> + if (!retval)
>> + stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
>> + break;
>> + default:
>> return -EPERM;
>> - retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
>> - if (!retval)
>> - stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
>> + }
>> return retval;
>> }
>>
>> @@ -835,7 +860,9 @@ static int snd_compress_wait_for_drain(struct snd_compr_stream *stream)
>> */
>>
>> ret = wait_event_interruptible(stream->runtime->sleep,
>> - (stream->runtime->state != SNDRV_PCM_STATE_DRAINING));
>> + (stream->runtime->state != SNDRV_PCM_STATE_DRAINING) &&
>> + (stream->runtime->state !=
>> + SNDRV_PCM_STATE_DRAINING_PAUSED));
>> if (ret == -ERESTARTSYS)
>> pr_debug("wait aborted by a signal\n");
>> else if (ret)
>> @@ -857,6 +884,7 @@ static int snd_compr_drain(struct snd_compr_stream *stream)
>> case SNDRV_PCM_STATE_SETUP:
>> case SNDRV_PCM_STATE_PREPARED:
>> case SNDRV_PCM_STATE_PAUSED:
>> + case SNDRV_PCM_STATE_DRAINING_PAUSED:
>> return -EPERM;
>> case SNDRV_PCM_STATE_XRUN:
>> return -EPIPE;
>> @@ -909,6 +937,7 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
>> case SNDRV_PCM_STATE_SETUP:
>> case SNDRV_PCM_STATE_PREPARED:
>> case SNDRV_PCM_STATE_PAUSED:
>> + case SNDRV_PCM_STATE_DRAINING_PAUSED:
>> return -EPERM;
>> case SNDRV_PCM_STATE_XRUN:
>> return -EPIPE;
>>
>> base-commit: a1b8638ba1320e6684aa98233c15255eb803fac7
>> --
>> 2.21.0
>>
>>
>
next parent reply other threads:[~2020-09-29 8:42 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200929084051epcas2p35fb2228ed1bdfce6a7ddf5b37c944823@epcas2p3.samsung.com>
2020-09-29 8:40 ` Gyeongtaek Lee [this message]
2020-09-29 8:54 ` [PATCH] ALSA: compress: allow pause and resume during draining Takashi Iwai
2020-09-29 9:17 ` Gyeongtaek Lee
2020-09-29 14:00 ` Pierre-Louis Bossart
2020-10-01 10:29 ` Vinod Koul
2020-10-01 15:28 ` Pierre-Louis Bossart
2020-10-06 6:21 ` Vinod Koul
2020-10-06 14:57 ` Pierre-Louis Bossart
2020-10-08 9:49 ` Gyeongtaek Lee
2020-10-09 15:13 ` Takashi Iwai
2020-10-09 17:43 ` Jaroslav Kysela
2020-10-10 9:08 ` Takashi Iwai
2020-10-12 5:25 ` Vinod Koul
2020-10-12 7:01 ` Takashi Iwai
2020-10-12 12:24 ` Vinod Koul
2020-10-12 13:29 ` Jaroslav Kysela
2020-10-12 13:55 ` Vinod Koul
2020-10-12 14:10 ` Jaroslav Kysela
2020-10-12 14:21 ` Takashi Iwai
2020-10-12 14:46 ` Jaroslav Kysela
2020-10-12 14:59 ` Takashi Iwai
2020-10-15 10:47 ` Gyeongtaek Lee
2020-10-20 5:23 ` Gyeongtaek Lee
2020-10-26 9:18 ` Gyeongtaek Lee
2020-10-26 17:01 ` Takashi Iwai
2020-10-27 1:56 ` Gyeongtaek Lee
[not found] <CGME20200928105009epcas2p4a65d50d9d09800281395a490d1844ef3@epcas2p4.samsung.com>
2020-09-28 10:50 ` Gyeongtaek Lee
2020-09-28 11:13 ` Jaroslav Kysela
2020-09-28 14:34 ` Pierre-Louis Bossart
2020-09-29 1:51 ` Gyeongtaek Lee
2020-09-29 7:12 ` Takashi Iwai
2020-09-29 17:27 ` Jaroslav Kysela
2020-09-30 9:35 ` Takashi Iwai
2020-09-30 9:57 ` Jaroslav Kysela
2020-09-30 10:33 ` Takashi Iwai
2020-09-30 11:23 ` Jaroslav Kysela
2020-10-01 10:35 ` Vinod Koul
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='000001d6963c$3cc53690$b64fa3b0$@samsung.com' \
--to=gt82.lee@samsung.com \
--cc=alsa-devel@alsa-project.org \
--cc=hmseo@samsung.com \
--cc=khw0178.kim@samsung.com \
--cc=kimty@samsung.com \
--cc=lgirdwood@gmail.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=pilsun.jang@samsung.com \
--cc=s47.kang@samsung.com \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
--cc=tkjung@samsung.com \
--cc=vkoul@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).