39 #include <linux/slab.h>
70 if (! queue_list[i]) {
74 spin_unlock_irqrestore(&queue_list_lock, flags);
78 spin_unlock_irqrestore(&queue_list_lock, flags);
91 if (q->
owner == client) {
97 spin_unlock_irqrestore(&queue_list_lock, flags);
102 spin_unlock_irqrestore(&queue_list_lock, flags);
115 snd_printd(
"malloc failed for snd_seq_queue_new()\n");
180 queue_delete(queue_list[i]);
191 q = queue_new(client, locked);
195 if (queue_list_add(q) < 0) {
208 if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES)
210 q = queue_list_remove(queueid, client);
225 if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES)
228 q = queue_list[queueid];
231 spin_unlock_irqrestore(&queue_list_lock, flags);
266 spin_unlock_irqrestore(&q->
check_lock, flags);
270 spin_unlock_irqrestore(&q->
check_lock, flags);
275 if (snd_seq_compare_tick_time(&q->
timer->tick.cur_tick,
276 &cell->
event.time.tick)) {
289 if (snd_seq_compare_real_time(&q->
timer->cur_time,
290 &cell->
event.time.time)) {
304 spin_unlock_irqrestore(&q->
check_lock, flags);
308 spin_unlock_irqrestore(&q->
check_lock, flags);
320 dest = cell->
event.queue;
328 cell->
event.time.tick += q->
timer->tick.cur_tick;
332 snd_seq_inc_real_time(&cell->
event.time.time,
333 &q->
timer->cur_time);
367 static inline int check_access(
struct snd_seq_queue *q,
int client)
375 static int queue_access_lock(
struct snd_seq_queue *q,
int client)
381 access_ok = check_access(q, client);
384 spin_unlock_irqrestore(&q->
owner_lock, flags);
389 static inline void queue_access_unlock(
struct snd_seq_queue *q)
395 spin_unlock_irqrestore(&q->
owner_lock, flags);
408 access_ok = check_access(q, client);
409 spin_unlock_irqrestore(&q->
owner_lock, flags);
426 if (! queue_access_lock(q, client)) {
431 q->
locked = locked ? 1 : 0;
433 queue_access_unlock(q);
489 if (! queue_access_lock(q, client)) {
500 queue_access_unlock(q);
526 if (use && queue->
clients == 1)
550 result =
test_bit(client, q->clients_bitmap) ? 1 : 0;
571 if (q->
owner == client)
573 spin_unlock_irqrestore(&q->
owner_lock, flags);
574 if (q->
owner == client) {
575 if (q->
timer->running)
594 if ((q = queue_list_remove(i, client)) !=
NULL)
604 if (
test_bit(client, q->clients_bitmap)) {
641 if (
test_bit(client, q->clients_bitmap) &&
664 sev.time.tick = q->
timer->tick.cur_tick;
665 sev.queue = q->
queue;
666 sev.data.queue.queue = q->
queue;
679 static void snd_seq_queue_process_event(
struct snd_seq_queue *q,
688 queue_broadcast_event(q, ev, atomic, hop);
693 queue_broadcast_event(q, ev, atomic, hop);
698 queue_broadcast_event(q, ev, atomic, hop);
703 queue_broadcast_event(q, ev, atomic, hop);
708 queue_broadcast_event(q, ev, atomic, hop);
714 queue_broadcast_event(q, ev, atomic, hop);
721 queue_broadcast_event(q, ev, atomic, hop);
743 if (! queue_access_lock(q, ev->
source.client)) {
748 snd_seq_queue_process_event(q, ev, atomic, hop);
750 queue_access_unlock(q);
758 #ifdef CONFIG_PROC_FS
773 bpm = 60000000 / tmr->
tempo;
777 snd_iprintf(buffer,
"queue %d: [%s]\n", q->
queue, q->
name);
778 snd_iprintf(buffer,
"owned by client : %d\n", q->
owner);
779 snd_iprintf(buffer,
"lock status : %s\n", q->
locked ?
"Locked" :
"Free");
782 snd_iprintf(buffer,
"timer state : %s\n", tmr->
running ?
"Running" :
"Stopped");
783 snd_iprintf(buffer,
"timer PPQ : %d\n", tmr->
ppq);
784 snd_iprintf(buffer,
"current tempo : %d\n", tmr->
tempo);
785 snd_iprintf(buffer,
"current BPM : %d\n", bpm);
787 snd_iprintf(buffer,
"current tick : %d\n", tmr->
tick.cur_tick);
788 snd_iprintf(buffer,
"\n");