Skip to content

Commit

Permalink
ALSA: firewire-lib: flush completed packets when reading PCM position
Browse files Browse the repository at this point in the history
By flushing all completed but not yet reported packets before reading
the PCM hardware position, the granularity of the pointer is improved
from the interrupt interval to the packet size.

Signed-off-by: Clemens Ladisch <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
cladisch authored and tiwai committed May 14, 2012
1 parent 76fb878 commit e9148dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
14 changes: 14 additions & 0 deletions sound/firewire/amdtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,20 @@ int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed)
}
EXPORT_SYMBOL(amdtp_out_stream_start);

/**
* amdtp_out_stream_pcm_pointer - get the PCM buffer position
* @s: the AMDTP output stream that transports the PCM data
*
* Returns the current buffer position, in frames.
*/
unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s)
{
fw_iso_context_flush_completions(s->context);

return ACCESS_ONCE(s->pcm_buffer_pointer);
}
EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);

/**
* amdtp_out_stream_update - update the stream after a bus reset
* @s: the AMDTP output stream
Expand Down
13 changes: 1 addition & 12 deletions sound/firewire/amdtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void amdtp_out_stream_stop(struct amdtp_out_stream *s);
void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s,
snd_pcm_format_t format);
void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s);
unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s);
void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s);

/**
Expand Down Expand Up @@ -140,18 +141,6 @@ static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
ACCESS_ONCE(s->pcm) = pcm;
}

/**
* amdtp_out_stream_pcm_pointer - get the PCM buffer position
* @s: the AMDTP output stream that transports the PCM data
*
* Returns the current buffer position, in frames.
*/
static inline unsigned long
amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s)
{
return ACCESS_ONCE(s->pcm_buffer_pointer);
}

static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
{
return sfc & 1;
Expand Down

0 comments on commit e9148dd

Please sign in to comment.