diff --git a/src/main/java/io/github/dsheirer/audio/playback/AudioOutput.java b/src/main/java/io/github/dsheirer/audio/playback/AudioOutput.java index 34ce747c..7772fee6 100644 --- a/src/main/java/io/github/dsheirer/audio/playback/AudioOutput.java +++ b/src/main/java/io/github/dsheirer/audio/playback/AudioOutput.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2023 Dennis Sheirer + * Copyright (C) 2014-2024 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,6 +82,8 @@ public abstract class AudioOutput implements LineListener, Listener 0) + { + mOutput.close(); + + try + { + mOutput.open(mAudioFormat, mRequestedBufferSize); + + //Start threshold: buffer is full with 10% or less of capacity remaining + mBufferStartThreshold = (int) (mOutput.getBufferSize() * 0.10); + + //Stop threshold: buffer is empty with 90% or more capacity available + mBufferStopThreshold = (int) (mOutput.getBufferSize() * 0.90); + + try + { + Control gain = mOutput.getControl(FloatControl.Type.MASTER_GAIN); + mGainControl = (FloatControl) gain; + } + catch(IllegalArgumentException iae) + { + mLog.warn("Couldn't obtain MASTER GAIN control for stereo line [" + getChannelName() + "]"); + } + + try + { + Control mute = mOutput.getControl(BooleanControl.Type.MUTE); + mMuteControl = (BooleanControl) mute; + } + catch(IllegalArgumentException iae) + { + mLog.warn("Couldn't obtain MUTE control for stereo line [" + getChannelName() + "]"); + } + + mAudioStartEvent = new AudioEvent(AudioEvent.Type.AUDIO_STARTED, getChannelName()); + mAudioStopEvent = new AudioEvent(AudioEvent.Type.AUDIO_STOPPED, getChannelName()); + mCanProcessAudio = true; + } + catch(LineUnavailableException e) + { + mLog.error("Couldn't obtain audio source data line for audio output - mixer [" + + mMixer.getMixerInfo().getName() + "]"); + } + } } if(mOutput.isRunning() && wrote < buffer.array().length)