summaryrefslogtreecommitdiff
path: root/songdbj/org/tritonus/share/TNotifier.java
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
committerBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
commit7039a05147b8bbfc829babea1c65bd436450b505 (patch)
tree4ba555eb84ed97b72b0575034d5b0530a393713e /songdbj/org/tritonus/share/TNotifier.java
parent6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff)
downloadrockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.gz
rockbox-7039a05147b8bbfc829babea1c65bd436450b505.zip
Splitting out songdbj
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11953 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'songdbj/org/tritonus/share/TNotifier.java')
-rw-r--r--songdbj/org/tritonus/share/TNotifier.java140
1 files changed, 0 insertions, 140 deletions
diff --git a/songdbj/org/tritonus/share/TNotifier.java b/songdbj/org/tritonus/share/TNotifier.java
deleted file mode 100644
index 822b30c305..0000000000
--- a/songdbj/org/tritonus/share/TNotifier.java
+++ /dev/null
@@ -1,140 +0,0 @@
1/*
2 * TNotifier.java
3 *
4 * This file is part of Tritonus: http://www.tritonus.org/
5 */
6
7/*
8 * Copyright (c) 1999 by Matthias Pfisterer
9 *
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Library General Public License as published
13 * by the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 */
26
27/*
28|<--- this code is formatted to fit into 80 columns --->|
29*/
30
31package org.tritonus.share;
32
33import java.util.EventObject;
34import java.util.Collection;
35import java.util.ArrayList;
36import java.util.List;
37import java.util.Iterator;
38
39import javax.sound.sampled.LineListener;
40import javax.sound.sampled.LineEvent;
41
42
43
44public class TNotifier
45extends Thread
46{
47 public static class NotifyEntry
48 {
49 private EventObject m_event;
50 private List<LineListener> m_listeners;
51
52
53
54 public NotifyEntry(EventObject event, Collection<LineListener> listeners)
55 {
56 m_event = event;
57 m_listeners = new ArrayList<LineListener>(listeners);
58 }
59
60
61 public void deliver()
62 {
63 // TDebug.out("%% TNotifier.NotifyEntry.deliver(): called.");
64 Iterator<LineListener> iterator = m_listeners.iterator();
65 while (iterator.hasNext())
66 {
67 LineListener listener = iterator.next();
68 listener.update((LineEvent) m_event);
69 }
70 }
71 }
72
73
74 public static TNotifier notifier = null;
75
76 static
77 {
78 notifier = new TNotifier();
79 notifier.setDaemon(true);
80 notifier.start();
81 }
82
83
84
85 /** The queue of events to deliver.
86 * The entries are of class NotifyEntry.
87 */
88 private List<NotifyEntry> m_entries;
89
90
91 public TNotifier()
92 {
93 super("Tritonus Notifier");
94 m_entries = new ArrayList<NotifyEntry>();
95 }
96
97
98
99 public void addEntry(EventObject event, Collection<LineListener> listeners)
100 {
101 // TDebug.out("%% TNotifier.addEntry(): called.");
102 synchronized (m_entries)
103 {
104 m_entries.add(new NotifyEntry(event, listeners));
105 m_entries.notifyAll();
106 }
107 // TDebug.out("%% TNotifier.addEntry(): completed.");
108 }
109
110
111 public void run()
112 {
113 while (true)
114 {
115 NotifyEntry entry = null;
116 synchronized (m_entries)
117 {
118 while (m_entries.size() == 0)
119 {
120 try
121 {
122 m_entries.wait();
123 }
124 catch (InterruptedException e)
125 {
126 if (TDebug.TraceAllExceptions)
127 {
128 TDebug.out(e);
129 }
130 }
131 }
132 entry = m_entries.remove(0);
133 }
134 entry.deliver();
135 }
136 }
137}
138
139
140/*** TNotifier.java ***/