Beispiel #1
0
static int prioq_remove_match(struct snd_seq_remove_events *info,
			      struct snd_seq_event *ev)
{
	int res;

	if (info->remove_mode & SNDRV_SEQ_REMOVE_DEST) {
		if (ev->dest.client != info->dest.client ||
				ev->dest.port != info->dest.port)
			return 0;
	}
	if (info->remove_mode & SNDRV_SEQ_REMOVE_DEST_CHANNEL) {
		if (! snd_seq_ev_is_channel_type(ev))
			return 0;
		/* data.note.channel and data.control.channel are identical */
		if (ev->data.note.channel != info->channel)
			return 0;
	}
	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)
			return 0;
	}
	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)
			return 0;
	}
	if (info->remove_mode & SNDRV_SEQ_REMOVE_EVENT_TYPE) {
		if (ev->type != info->type)
			return 0;
	}
	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: */
			return 0;
		default:
			break;
		}
	}
	if (info->remove_mode & SNDRV_SEQ_REMOVE_TAG_MATCH) {
		if (info->tag != ev->tag)
			return 0;
	}

	return 1;
}
Beispiel #2
0
void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop)
{
    unsigned long flags;
    struct snd_seq_event_cell *cell;

    if (q == NULL)
        return;

    /* make this function non-reentrant */
    spin_lock_irqsave(&q->check_lock, flags);
    if (q->check_blocked) {
        q->check_again = 1;
        spin_unlock_irqrestore(&q->check_lock, flags);
        return;        /* other thread is already checking queues */
    }
    q->check_blocked = 1;
    spin_unlock_irqrestore(&q->check_lock, flags);

      __again:
    /* Process tick queue... */
    while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) {
        if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick,
                          &cell->event.time.tick)) {
            cell = snd_seq_prioq_cell_out(q->tickq);
            if (cell)
                snd_seq_dispatch_event(cell, atomic, hop);
        } else {
            /* event remains in the queue */
            break;
        }
    }


    /* Process time queue... */
    while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) {
        if (snd_seq_compare_real_time(&q->timer->cur_time,
                          &cell->event.time.time)) {
            cell = snd_seq_prioq_cell_out(q->timeq);
            if (cell)
                snd_seq_dispatch_event(cell, atomic, hop);
        } else {
            /* event remains in the queue */
            break;
        }
    }

    /* free lock */
    spin_lock_irqsave(&q->check_lock, flags);
    if (q->check_again) {
        q->check_again = 0;
        spin_unlock_irqrestore(&q->check_lock, flags);
        goto __again;
    }
    q->check_blocked = 0;
    spin_unlock_irqrestore(&q->check_lock, flags);
}
Beispiel #3
0
/* return 1 if a >= b; 0 */
static inline int compare_timestamp(snd_seq_event_t * a, snd_seq_event_t * b)
{
	if ((a->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK) {
		/* compare ticks */
		return (snd_seq_compare_tick_time(&a->time.tick, &b->time.tick));
	} else {
		/* compare real time */
		return (snd_seq_compare_real_time(&a->time.time, &b->time.time));
	}
}