From 94a5ddff9d5d85104755ee17b301c289a060cebf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 6 Nov 2023 16:33:59 +0100 Subject: [PATCH] seq: Simplify snd_seq_extract_output() Now that we never put UMP events on the output buffer in the legacy mode, the check and skip of UMP events are no longer necessary. It means that ump_allowed argument is meaningless in extract_output(), too. Let's drop the unnecessary check and move the code extract_output() into snd_seq_extract_output() again, and call this directly from snd_seq_ump_extract_output() for simplification. Signed-off-by: Takashi Iwai --- src/seq/seq.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/seq/seq.c b/src/seq/seq.c index 643cf159..5eac4848 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -4308,24 +4308,28 @@ int snd_seq_drain_output(snd_seq_t *seq) return 0; } -static int extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res, int ump_allowed) +/** + * \brief extract the first event in output buffer + * \param seq sequencer handle + * \param ev_res event pointer to be extracted + * \return 0 on success otherwise a negative error code + * + * Extracts the first event in output buffer. + * If ev_res is NULL, just remove the event. + * + * \sa snd_seq_event_output() + */ +int snd_seq_extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res) { size_t len, olen; assert(seq); if (ev_res) *ev_res = NULL; - repeat: if ((olen = seq->obufused) < sizeof(snd_seq_event_t)) return -ENOENT; len = snd_seq_event_length((snd_seq_event_t *)seq->obuf); if (olen < len) return -ENOENT; - /* skip invalid UMP events */ - if (snd_seq_ev_is_ump((snd_seq_event_t *)seq->obuf) && !ump_allowed) { - seq->obufused -= len; - memmove(seq->obuf, seq->obuf + len, seq->obufused); - goto repeat; - } if (ev_res) { /* extract the event */ if (alloc_tmpbuf(seq, len) < 0) @@ -4338,22 +4342,6 @@ static int extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res, int ump_allo return 0; } -/** - * \brief extract the first event in output buffer - * \param seq sequencer handle - * \param ev_res event pointer to be extracted - * \return 0 on success otherwise a negative error code - * - * Extracts the first event in output buffer. - * If ev_res is NULL, just remove the event. - * - * \sa snd_seq_event_output() - */ -int snd_seq_extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res) -{ - return extract_output(seq, ev_res, 0); -} - /*----------------------------------------------------------------*/ /* @@ -4547,7 +4535,7 @@ int snd_seq_ump_extract_output(snd_seq_t *seq, snd_seq_ump_event_t **ev_res) { if (!seq->midi_version) return -EBADFD; - return extract_output(seq, (snd_seq_event_t **)ev_res, 1); + return snd_seq_extract_output(seq, (snd_seq_event_t **)ev_res); } /** -- 2.47.1