// SPDX-License-Identifier: GPL-2.0-or-later /* * ALSA sequencer Priority Queue * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
*/
/* check if this element needs to inserted at the end (ie. ordered data is inserted) This will be very likeley if a sequencer
application or midi file player is feeding us (sequential) data */ if (f->tail && !prior) { if (compare_timestamp(&cell->event, &f->tail->event)) { /* add new cell to tail of the fifo */
f->tail->next = cell;
f->tail = cell;
cell->next = NULL;
f->cells++; return 0;
}
} /* traverse list of elements to find the place where the new cell is
to be inserted... Note that this is a order n process ! */
count = 10000; /* FIXME: enough big, isn't it? */ while (cur != NULL) { /* compare timestamps */ int rel = compare_timestamp_rel(&cell->event, &cur->event); if (rel < 0) /* new cell has earlier schedule time, */ break; elseif (rel == 0 && prior) /* equal schedule time and prior to others */ break; /* new cell has equal or larger schedule time, */ /* move cursor to next cell */
prev = cur;
cur = cur->next; if (! --count) {
pr_err("ALSA: seq: cannot find a pointer.. infinite loop?\n"); return -EINVAL;
}
}
/* insert it before cursor */ if (prev != NULL)
prev->next = cell;
cell->next = cur;
if (f->head == cur) /* this is the first cell, set head to it */
f->head = cell; if (cur == NULL) /* reached end of the list */
f->tail = cell;
f->cells++; return 0;
}
/* return 1 if the current time >= event timestamp */ staticint event_is_ready(struct snd_seq_event *ev, void *current_time)
{ if ((ev->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK) return snd_seq_compare_tick_time(current_time, &ev->time.tick); else return snd_seq_compare_real_time(current_time, &ev->time.time);
}
if (f == NULL) {
pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n"); return NULL;
}
guard(spinlock_irqsave)(&f->lock);
cell = f->head; if (cell && current_time && !event_is_ready(&cell->event, current_time))
cell = NULL; if (cell) {
f->head = cell->next;
/* reset tail if this was the last element */ if (f->tail == cell)
f->tail = NULL;
cell->next = NULL;
f->cells--;
}
return cell;
}
/* return number of events available in prioq */ int snd_seq_prioq_avail(struct snd_seq_prioq * f)
{ if (f == NULL) {
pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n"); return 0;
} return f->cells;
}
if (info->remove_mode & SNDRV_SEQ_REMOVE_DEST) { if (ev->dest.client != info->dest.client ||
ev->dest.port != info->dest.port) returnfalse;
} if (info->remove_mode & SNDRV_SEQ_REMOVE_DEST_CHANNEL) { if (! snd_seq_ev_is_channel_type(ev)) returnfalse; /* data.note.channel and data.control.channel are identical */ if (ev->data.note.channel != info->channel) returnfalse;
} if (info->remove_mode & SNDRV_SEQ_REMOVE_TIME_AFTER) { if (info->remove_mode & SNDRV_SEQ_REMOVE_TIME_TICK)
res = snd_seq_compare_tick_time(&ev->time.tick, &info->time.tick); else
res = snd_seq_compare_real_time(&ev->time.time, &info->time.time); if (!res) returnfalse;
} if (info->remove_mode & SNDRV_SEQ_REMOVE_TIME_BEFORE) { if (info->remove_mode & SNDRV_SEQ_REMOVE_TIME_TICK)
res = snd_seq_compare_tick_time(&ev->time.tick, &info->time.tick); else
res = snd_seq_compare_real_time(&ev->time.time, &info->time.time); if (res) returnfalse;
} if (info->remove_mode & SNDRV_SEQ_REMOVE_EVENT_TYPE) { if (ev->type != info->type) returnfalse;
} if (info->remove_mode & SNDRV_SEQ_REMOVE_IGNORE_OFF) { /* Do not remove off events */ switch (ev->type) { case SNDRV_SEQ_EVENT_NOTEOFF: /* case SNDRV_SEQ_EVENT_SAMPLE_STOP: */ returnfalse; default: break;
}
} if (info->remove_mode & SNDRV_SEQ_REMOVE_TAG_MATCH) { if (info->tag != ev->tag) returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.