Send event after source has been updated.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Mar 2013 18:53:15 +0000 (19:53 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Mar 2013 18:53:15 +0000 (19:53 +0100)
src/main/java/net/pterodactylus/sonitus/data/filter/MultiSourceFilter.java

index a505c92..fb52c9d 100644 (file)
@@ -144,10 +144,11 @@ public class MultiSourceFilter implements Filter, ReusableSink {
                 */
                public Connection source(Source source) throws IOException {
                        synchronized (syncObject) {
-                               if (this.source != null) {
-                                       eventBus.post(new SourceFinishedEvent(this.source));
-                               }
+                               Source oldSource = this.source;
                                this.source = source;
+                               if (oldSource != null) {
+                                       eventBus.post(new SourceFinishedEvent(oldSource));
+                               }
                                pipedInputStream = new PipedInputStream();
                                pipedOutputStream = new PipedOutputStream(pipedInputStream);
                                syncObject.notifyAll();