jdk/src/share/classes/com/sun/media/sound/DataPusher.java
author amenkov
Wed, 06 Apr 2011 15:12:33 +0400
changeset 9215 cab45ca6ab44
parent 5506 202f599c92aa
child 18215 b2afd66ce6db
permissions -rw-r--r--
6992523: FindBugs scan - Malicious code vulnerability Warnings in com.sun.media.sound.* Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.media.sound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.sound.sampled.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Class to write an AudioInputStream to a SourceDataLine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Was previously an inner class in various classes like JavaSoundAudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * and sun.audio.AudioDevice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * It auto-opens and closes the SourceDataLine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @author Kara Kytle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @author Florian Bomers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class DataPusher implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private static final int AUTO_CLOSE_TIME = 5000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static final boolean DEBUG = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private SourceDataLine source = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private AudioFormat format = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    // stream as source data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private AudioInputStream ais = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    // byte array as source data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private byte[] audioData = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private int audioDataByteLength = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private int pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private int newPos = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private boolean looping;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private Thread pushThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private int wantedState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private int threadState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private final int STATE_NONE = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private final int STATE_PLAYING = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private final int STATE_WAITING = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private final int STATE_STOPPING = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private final int STATE_STOPPED = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private final int BUFFER_SIZE = 16384;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        this.audioData = audioData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        this.audioDataByteLength = byteLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        this.format = format;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        this.source = sourceLine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        this.ais = ais;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        this.format = ais.getFormat();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        this.source = sourceLine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public synchronized void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        start(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public synchronized void start(boolean loop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (DEBUG || Printer.debug) Printer.debug("> DataPusher.start(loop="+loop+")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            if (threadState == STATE_STOPPING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                // wait that the thread has finished stopping
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                if (DEBUG || Printer.trace)Printer.trace("DataPusher.start(): calling stop()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            looping = loop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            newPos = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            wantedState = STATE_PLAYING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            if (!source.isOpen()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.open()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                source.open(format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.flush()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            source.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.start()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            source.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            if (pushThread == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                if (DEBUG || Printer.debug) Printer.debug("DataPusher.start(): Starting push");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                pushThread = JSSecurityManager.createThread(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                                            null,   // name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                                            false,  // daemon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                                                            -1,    // priority
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                                            true); // doStart
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            if (DEBUG || Printer.err) e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (DEBUG || Printer.debug) Printer.debug("< DataPusher.start(loop="+loop+")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public synchronized void stop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        if (DEBUG || Printer.debug) Printer.debug("> DataPusher.stop()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        if (threadState == STATE_STOPPING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            || threadState == STATE_STOPPED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            || pushThread == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            if (DEBUG || Printer.debug) Printer.debug("DataPusher.stop(): nothing to do");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (DEBUG || Printer.debug) Printer.debug("DataPusher.stop(): Stopping push");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        wantedState = STATE_WAITING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (source != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.flush()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            source.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        int maxWaitCount = 50; // 5 seconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        while ((maxWaitCount-- >= 0) && (threadState == STATE_PLAYING)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                wait(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            } catch (InterruptedException e) {  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        if (DEBUG || Printer.debug) Printer.debug("< DataPusher.stop()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    synchronized void close() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (source != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                if (DEBUG || Printer.trace)Printer.trace("DataPusher.close(): source.close()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                source.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Write data to the source data line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        byte[] buffer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        boolean useStream = (ais != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (useStream) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            buffer = new byte[BUFFER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            buffer = audioData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        while (wantedState != STATE_STOPPING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            //try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                if (wantedState == STATE_WAITING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    // wait for 5 seconds - maybe the clip is to be played again
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): waiting 5 seconds");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                                threadState = STATE_WAITING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                wantedState = STATE_STOPPING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                                wait(AUTO_CLOSE_TIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    } catch (InterruptedException ie) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): waiting finished");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                if (newPos >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                        pos = newPos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                        newPos = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                threadState = STATE_PLAYING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                int toWrite = BUFFER_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                if (useStream) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                        pos = 0; // always write from beginning of buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        // don't use read(byte[]), because some streams
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                        // may not override that method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                        toWrite = ais.read(buffer, 0, buffer.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    } catch (java.io.IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                        // end of stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        toWrite = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    if (toWrite > audioDataByteLength - pos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        toWrite = audioDataByteLength - pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    if (toWrite == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        toWrite = -1; // end of "stream"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                if (toWrite < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    if (DEBUG || Printer.debug) Printer.debug("DataPusher.run(): Found end of stream");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        if (!useStream && looping) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                            if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): setting pos back to 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                            pos = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): calling drain()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                    wantedState = STATE_WAITING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    source.drain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                if (DEBUG || Printer.debug) Printer.debug("> DataPusher.run(): Writing " + toWrite + " bytes");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    int bytesWritten = source.write(buffer, pos, toWrite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                    pos += bytesWritten;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                if (DEBUG || Printer.debug) Printer.debug("< DataPusher.run(): Wrote " + bytesWritten + " bytes");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        threadState = STATE_STOPPING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (DEBUG || Printer.debug)Printer.debug("DataPusher: closing device");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        if (Printer.trace)Printer.trace("DataPusher: source.flush()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        source.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.stop()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        source.stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.flush()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        source.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.close()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        source.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        threadState = STATE_STOPPED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                pushThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (DEBUG || Printer.debug)Printer.debug("DataPusher:end of thread");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
} // class DataPusher