summaryrefslogtreecommitdiff
path: root/sound/usb/pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/pcm.c')
-rw-r--r--sound/usb/pcm.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 19392117de9e..4dd7f1c9e2af 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -581,6 +581,22 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
return 0;
}
+/* check whether early start is needed for playback stream */
+static int lowlatency_playback_available(struct snd_usb_substream *subs)
+{
+ struct snd_usb_audio *chip = subs->stream->chip;
+
+ if (subs->direction == SNDRV_PCM_STREAM_CAPTURE)
+ return false;
+ /* disabled via module option? */
+ if (!chip->lowlatency)
+ return false;
+ /* too short periods? */
+ if (subs->data_endpoint->nominal_queue_size >= subs->buffer_bytes)
+ return false;
+ return true;
+}
+
/*
* prepare callback
*
@@ -614,13 +630,8 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
subs->period_elapsed_pending = 0;
runtime->delay = 0;
- /* check whether early start is needed for playback stream */
- subs->early_playback_start =
- subs->direction == SNDRV_PCM_STREAM_PLAYBACK &&
- (!chip->lowlatency ||
- (subs->data_endpoint->nominal_queue_size >= subs->buffer_bytes));
-
- if (subs->early_playback_start)
+ subs->lowlatency_playback = lowlatency_playback_available(subs);
+ if (!subs->lowlatency_playback)
ret = start_endpoints(subs);
unlock:
@@ -1412,7 +1423,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
subs->trigger_tstamp_pending_update = false;
}
- if (period_elapsed && !subs->running && !subs->early_playback_start) {
+ if (period_elapsed && !subs->running && subs->lowlatency_playback) {
subs->period_elapsed_pending = 1;
period_elapsed = 0;
}
@@ -1466,7 +1477,7 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
prepare_playback_urb,
retire_playback_urb,
subs);
- if (!subs->early_playback_start &&
+ if (subs->lowlatency_playback &&
cmd == SNDRV_PCM_TRIGGER_START) {
err = start_endpoints(subs);
if (err < 0) {