Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 37614
b: refs/heads/master
c: 9442e69
h: refs/heads/master
v: v3
  • Loading branch information
Takashi Iwai authored and Linus Torvalds committed Oct 1, 2006
1 parent 7814dee commit 4b13d3f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c87579e65ee4f419b2369407f82326d38b5d2d8
refs/heads/master: 9442e691e4aec85eba43ac60a3e77c77fd2e73a4
1 change: 1 addition & 0 deletions trunk/include/sound/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ struct snd_pcm_substream {
int number;
char name[32]; /* substream name */
int stream; /* stream (direction) */
char latency_id[20]; /* latency identifier */
size_t buffer_bytes_max; /* limit ring buffer size */
struct snd_dma_buffer dma_buffer;
unsigned int dma_buf_id;
Expand Down
3 changes: 3 additions & 0 deletions trunk/sound/core/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
substream->number = idx;
substream->stream = stream;
sprintf(substream->name, "subdevice #%i", idx);
snprintf(substream->latency_id, sizeof(substream->latency_id),
"ALSA-PCM%d-%d%c%d", pcm->card->number, pcm->device,
(stream ? 'c' : 'p'), idx);
substream->buffer_bytes_max = UINT_MAX;
if (prev == NULL)
pstr->substream = substream;
Expand Down
23 changes: 22 additions & 1 deletion trunk/sound/core/pcm_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/file.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/latency.h>
#include <linux/uio.h>
#include <sound/core.h>
#include <sound/control.h>
Expand Down Expand Up @@ -347,11 +348,26 @@ static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream,
return err;
}

static int period_to_usecs(struct snd_pcm_runtime *runtime)
{
int usecs;

if (! runtime->rate)
return -1; /* invalid */

/* take 75% of period time as the deadline */
usecs = (750000 / runtime->rate) * runtime->period_size;
usecs += ((750000 % runtime->rate) * runtime->period_size) /
runtime->rate;

return usecs;
}

static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_pcm_runtime *runtime;
int err;
int err, usecs;
unsigned int bits;
snd_pcm_uframes_t frames;

Expand Down Expand Up @@ -431,6 +447,10 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,

snd_pcm_timer_resolution_change(substream);
runtime->status->state = SNDRV_PCM_STATE_SETUP;

remove_acceptable_latency(substream->latency_id);
if ((usecs = period_to_usecs(runtime)) >= 0)
set_acceptable_latency(substream->latency_id, usecs);
return 0;
_error:
/* hardware might be unuseable from this time,
Expand Down Expand Up @@ -490,6 +510,7 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
if (substream->ops->hw_free)
result = substream->ops->hw_free(substream);
runtime->status->state = SNDRV_PCM_STATE_OPEN;
remove_acceptable_latency(substream->latency_id);
return result;
}

Expand Down

0 comments on commit 4b13d3f

Please sign in to comment.