From b1229b69713ab2d963ca79134107ad8f2ccfc235 Mon Sep 17 00:00:00 2001 From: Denny Sheirer Date: Thu, 19 Sep 2024 15:23:31 -0400 Subject: [PATCH] #1915 P25 audio playback can stop playing audio despite everything else appears to be normal. (#1986) Co-authored-by: Dennis Sheirer --- .../dsheirer/audio/playback/AudioOutput.java | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) 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)