class Jsapi10SynthesizedOutput implements SynthesizedOutput, SpeakableListener,
        StreamableSynthesizedOutput {

    @Override
    public void cancelOutput(final BargeInType type) throws NoresourceError {
        if (synthesizer == null) {
            throw new NoresourceError("No synthesizer: Cannot cancel output");
        }

        if (!bargein || (type != bargeInType)) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("bargein not active for current output");
            }
            return;
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("cancelling current output...");
        }
        outputCanceled = true;
        synchronized (queuedSpeakables) {
            try {
                synthesizer.cancelAll();
            } catch (EngineStateError ee) {
                throw new NoresourceError(ee);
            }

            final Collection<SpeakableText> skipped = new java.util.ArrayList<SpeakableText>();
            for (SpeakableText speakable : queuedSpeakables) {
                if (speakable.isBargeInEnabled(type)) {
                    skipped.add(speakable);
                } else {
                    // Stop iterating after the first non-bargein speakable
                    // has been detected
                    break;
                }
            }
            queuedSpeakables.removeAll(skipped);
            if (queuedSpeakables.isEmpty()) {
                fireQueueEmpty();
                synchronized (emptyLock) {
                    emptyLock.notifyAll();
                }
            } else {
                final Runnable runnable = new Runnable() {
                    /**
                     * {@inheritDoc}
                     */
                    @Override
                    public void run() {
                        try {
                            outputCanceled = false;
                            processNextSpeakable();
                        } catch (NoresourceError e) {
                            notifyError(e);
                        } catch (BadFetchError e) {
                            notifyError(e);
                        }
                    }
                };
                final Thread thread = new Thread(runnable);
                thread.start();
            }
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...output cancelled.");
        }
    }

    public  Jsapi10SynthesizedOutput(final SynthesizerModeDesc defaultDescriptor);

}