]> git.alsa-project.org Git - alsa-lib.git/commitdiff
seq: Simplify snd_seq_extract_output()
authorTakashi Iwai <tiwai@suse.de>
Mon, 6 Nov 2023 15:33:59 +0000 (16:33 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 7 Nov 2023 11:16:47 +0000 (12:16 +0100)
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 <tiwai@suse.de>
src/seq/seq.c

index 643cf159f3ef02013abe6a63bc3a638d26181adb..5eac4848b9c79fba6ad6ded1027411b5662d9212 100644 (file)
@@ -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);
 }
 
 /**