[alsa-devel] [PATCH 2/2] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
Lars-Peter Clausen
lars at metafoo.de
Mon Jan 8 16:35:49 CET 2018
On 01/08/2018 03:25 PM, Takashi Iwai wrote:
> @@ -1438,8 +1441,11 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
>
> if ((tmp = snd_pcm_oss_make_ready(substream)) < 0)
> return tmp;
> - mutex_lock(&runtime->oss.params_lock);
> while (bytes > 0) {
> + if (mutex_lock_interruptible(&runtime->oss.params_lock)) {
> + tmp = -EINTR;
For consistency ERESTARTSYS I guess? In the end this is the same as
signal_pending().
> + break;
> + }
> if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) {
> if (runtime->oss.buffer_used == 0) {
> tmp = snd_pcm_oss_read2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1);
> @@ -1470,16 +1476,16 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
> bytes -= tmp;
> xfer += tmp;
> }
> + err:
> + mutex_unlock(&runtime->oss.params_lock);
> + if (tmp < 0)
> + break;
> if (signal_pending(current)) {
> tmp = -ERESTARTSYS;
> - goto err;
> + break;
> }
> + tmp = 0;
> }
> - mutex_unlock(&runtime->oss.params_lock);
> - return xfer;
> -
> - err:
> - mutex_unlock(&runtime->oss.params_lock);
> return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
> }
>
>
More information about the Alsa-devel
mailing list