diff options
author | Takashi Sakamoto | 2019-05-21 16:57:35 +0200 |
---|---|---|
committer | Takashi Iwai | 2019-05-22 12:28:16 +0200 |
commit | fce9b013fee94ded75624edebf28c8f3506b16cc (patch) | |
tree | fd2522f6bb7cabb610e71a50500923baf6925559 /sound/firewire/amdtp-stream.c | |
parent | ALSA: firewire-lib: use union for directional parameters (diff) | |
download | kernel-qcow2-linux-fce9b013fee94ded75624edebf28c8f3506b16cc.tar.gz kernel-qcow2-linux-fce9b013fee94ded75624edebf28c8f3506b16cc.tar.xz kernel-qcow2-linux-fce9b013fee94ded75624edebf28c8f3506b16cc.zip |
ALSA: firewire-lib: add helper function to cancel context inner callback handler
In callback handler of isochronous context for both direction, there're
common codes to cancel 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.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 6977fbbef755..ce39cb92a11e 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -707,6 +707,14 @@ static inline u32 increment_cycle_count(u32 cycle, unsigned int addend) return cycle; } +static inline void cancel_stream(struct amdtp_stream *s) +{ + s->packet_index = -1; + if (in_interrupt()) + amdtp_stream_pcm_abort(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) @@ -726,10 +734,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, for (i = 0; i < packets; ++i) { cycle = increment_cycle_count(cycle, 1); if (s->handle_packet(s, 0, cycle, i) < 0) { - s->packet_index = -1; - if (in_interrupt()) - amdtp_stream_pcm_abort(s); - WRITE_ONCE(s->pcm_buffer_pointer, SNDRV_PCM_POS_XRUN); + cancel_stream(s); return; } } @@ -779,10 +784,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp, /* Queueing error or detecting invalid payload. */ if (i < packets) { - s->packet_index = -1; - if (in_interrupt()) - amdtp_stream_pcm_abort(s); - WRITE_ONCE(s->pcm_buffer_pointer, SNDRV_PCM_POS_XRUN); + cancel_stream(s); return; } |