summaryrefslogtreecommitdiff
path: root/sound/firewire/amdtp-stream.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-07-22 12:37:02 +0900
committerTakashi Iwai <tiwai@suse.de>2019-07-22 16:05:05 +0200
commit0f5cfcb24d9c931e4571e9995bbfc08cc76d5d4a (patch)
treeaccaab7d89b39bfaa84522db8d46f03bdd52cdd3 /sound/firewire/amdtp-stream.c
parent5e2ece0fdceb02f6c47f53bef309395701a65393 (diff)
ALSA: firewire-lib: code refactoring to process context payloads
This is code refactoring for common processing for payloads of ishocornous context. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/amdtp-stream.c')
-rw-r--r--sound/firewire/amdtp-stream.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index 99b89bd70bc5..573265113a6f 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -760,22 +760,14 @@ static inline void cancel_stream(struct amdtp_stream *s)
WRITE_ONCE(s->pcm_buffer_pointer, SNDRV_PCM_POS_XRUN);
}
-static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
- size_t header_length, void *header,
- void *private_data)
+static void process_ctx_payloads(struct amdtp_stream *s,
+ const struct pkt_desc *descs,
+ unsigned int packets)
{
- struct amdtp_stream *s = private_data;
- const __be32 *ctx_header = header;
- unsigned int packets = header_length / sizeof(*ctx_header);
int i;
- if (s->packet_index < 0)
- return;
-
- generate_ideal_pkt_descs(s, s->pkt_descs, ctx_header, packets);
-
for (i = 0; i < packets; ++i) {
- const struct pkt_desc *desc = s->pkt_descs + i;
+ const struct pkt_desc *desc = descs + i;
struct snd_pcm_substream *pcm;
unsigned int pcm_frames;
@@ -786,6 +778,23 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
if (pcm && pcm_frames > 0)
update_pcm_pointers(s, pcm, pcm_frames);
}
+}
+
+static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
+ size_t header_length, void *header,
+ void *private_data)
+{
+ struct amdtp_stream *s = private_data;
+ const __be32 *ctx_header = header;
+ unsigned int packets = header_length / sizeof(*ctx_header);
+ int i;
+
+ if (s->packet_index < 0)
+ return;
+
+ generate_ideal_pkt_descs(s, s->pkt_descs, ctx_header, packets);
+
+ process_ctx_payloads(s, s->pkt_descs, packets);
for (i = 0; i < packets; ++i) {
const struct pkt_desc *desc = s->pkt_descs + i;
@@ -836,19 +845,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
return;
}
} else {
- for (i = 0; i < packets; ++i) {
- const struct pkt_desc *desc = s->pkt_descs;
- struct snd_pcm_substream *pcm;
- unsigned int pcm_frames;
-
- pcm_frames = s->process_data_blocks(s,
- desc->ctx_payload, desc->data_blocks,
- desc->data_block_counter);
-
- pcm = READ_ONCE(s->pcm);
- if (pcm && pcm_frames > 0)
- update_pcm_pointers(s, pcm, pcm_frames);
- }
+ process_ctx_payloads(s, s->pkt_descs, packets);
}
for (i = 0; i < packets; ++i) {