diff options
-rw-r--r-- | sound/core/pcm_lib.c | 17 | ||||
-rw-r--r-- | sound/core/pcm_native.c | 13 |
2 files changed, 24 insertions, 6 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index abfeff1611ce..f1341308beda 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -1756,8 +1756,18 @@ static int wait_for_avail(struct snd_pcm_substream *substream, | |||
1756 | wait_queue_t wait; | 1756 | wait_queue_t wait; |
1757 | int err = 0; | 1757 | int err = 0; |
1758 | snd_pcm_uframes_t avail = 0; | 1758 | snd_pcm_uframes_t avail = 0; |
1759 | long tout; | 1759 | long wait_time, tout; |
1760 | 1760 | ||
1761 | if (runtime->no_period_wakeup) | ||
1762 | wait_time = MAX_SCHEDULE_TIMEOUT; | ||
1763 | else { | ||
1764 | wait_time = 10; | ||
1765 | if (runtime->rate) { | ||
1766 | long t = runtime->period_size * 2 / runtime->rate; | ||
1767 | wait_time = max(t, wait_time); | ||
1768 | } | ||
1769 | wait_time = msecs_to_jiffies(wait_time * 1000); | ||
1770 | } | ||
1761 | init_waitqueue_entry(&wait, current); | 1771 | init_waitqueue_entry(&wait, current); |
1762 | add_wait_queue(&runtime->tsleep, &wait); | 1772 | add_wait_queue(&runtime->tsleep, &wait); |
1763 | for (;;) { | 1773 | for (;;) { |
@@ -1765,9 +1775,8 @@ static int wait_for_avail(struct snd_pcm_substream *substream, | |||
1765 | err = -ERESTARTSYS; | 1775 | err = -ERESTARTSYS; |
1766 | break; | 1776 | break; |
1767 | } | 1777 | } |
1768 | set_current_state(TASK_INTERRUPTIBLE); | ||
1769 | snd_pcm_stream_unlock_irq(substream); | 1778 | snd_pcm_stream_unlock_irq(substream); |
1770 | tout = schedule_timeout(msecs_to_jiffies(10000)); | 1779 | tout = schedule_timeout_interruptible(wait_time); |
1771 | snd_pcm_stream_lock_irq(substream); | 1780 | snd_pcm_stream_lock_irq(substream); |
1772 | switch (runtime->status->state) { | 1781 | switch (runtime->status->state) { |
1773 | case SNDRV_PCM_STATE_SUSPENDED: | 1782 | case SNDRV_PCM_STATE_SUSPENDED: |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 1a07750f3836..b597408d5faa 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -1481,11 +1481,20 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream, | |||
1481 | break; /* all drained */ | 1481 | break; /* all drained */ |
1482 | init_waitqueue_entry(&wait, current); | 1482 | init_waitqueue_entry(&wait, current); |
1483 | add_wait_queue(&to_check->sleep, &wait); | 1483 | add_wait_queue(&to_check->sleep, &wait); |
1484 | set_current_state(TASK_INTERRUPTIBLE); | ||
1485 | snd_pcm_stream_unlock_irq(substream); | 1484 | snd_pcm_stream_unlock_irq(substream); |
1486 | up_read(&snd_pcm_link_rwsem); | 1485 | up_read(&snd_pcm_link_rwsem); |
1487 | snd_power_unlock(card); | 1486 | snd_power_unlock(card); |
1488 | tout = schedule_timeout(10 * HZ); | 1487 | if (runtime->no_period_wakeup) |
1488 | tout = MAX_SCHEDULE_TIMEOUT; | ||
1489 | else { | ||
1490 | tout = 10; | ||
1491 | if (runtime->rate) { | ||
1492 | long t = runtime->period_size * 2 / runtime->rate; | ||
1493 | tout = max(t, tout); | ||
1494 | } | ||
1495 | tout = msecs_to_jiffies(tout * 1000); | ||
1496 | } | ||
1497 | tout = schedule_timeout_interruptible(tout); | ||
1489 | snd_power_lock(card); | 1498 | snd_power_lock(card); |
1490 | down_read(&snd_pcm_link_rwsem); | 1499 | down_read(&snd_pcm_link_rwsem); |
1491 | snd_pcm_stream_lock_irq(substream); | 1500 | snd_pcm_stream_lock_irq(substream); |