Commit 875be091 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: simplify function to calculate the number of data blocks

This function is called according to conditions between the value of
syt and streaming mode(blocking or non-blocking).

To simplify caller's work, this commit push these conditions to the
function.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent a2064710
......@@ -321,13 +321,21 @@ void amdtp_stream_pcm_prepare(struct amdtp_stream *s)
}
EXPORT_SYMBOL(amdtp_stream_pcm_prepare);
static unsigned int calculate_data_blocks(struct amdtp_stream *s)
static unsigned int calculate_data_blocks(struct amdtp_stream *s,
unsigned int syt)
{
unsigned int phase, data_blocks;
if (s->flags & CIP_BLOCKING)
/* Blocking mode. */
if (s->flags & CIP_BLOCKING) {
/* This module generate empty packet for 'no data'. */
if (syt == CIP_SYT_NO_INFO)
data_blocks = 0;
else
data_blocks = s->syt_interval;
else if (!cip_sfc_is_base_44100(s->sfc)) {
/* Non-blocking mode. */
} else {
if (!cip_sfc_is_base_44100(s->sfc)) {
/* Sample_rate / 8000 is an integer, and precomputed. */
data_blocks = s->data_block_state;
} else {
......@@ -352,6 +360,7 @@ static unsigned int calculate_data_blocks(struct amdtp_stream *s)
phase = 0;
s->data_block_state = phase;
}
}
return data_blocks;
}
......@@ -647,11 +656,7 @@ static void handle_out_packet(struct amdtp_stream *s, unsigned int syt)
if (s->packet_index < 0)
return;
/* this module generate empty packet for 'no data' */
if (!(s->flags & CIP_BLOCKING) || (syt != CIP_SYT_NO_INFO))
data_blocks = calculate_data_blocks(s);
else
data_blocks = 0;
data_blocks = calculate_data_blocks(s, syt);
buffer = s->buffer.packets[s->packet_index].buffer;
buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment