Resolves #694. Address null pointer when no system audio devices are available. (#695)

Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
Denny Sheirer
2020-03-23 08:45:06 +00:00
committed by GitHub
parent 692ffabe82
commit 41df207bb9
3 changed files with 42 additions and 14 deletions

View File

@@ -81,15 +81,23 @@ public class AudioPlaybackManager implements Listener<AudioSegment>, IAudioContr
MyEventBus.getEventBus().register(this); MyEventBus.getEventBus().register(this);
MixerChannelConfiguration configuration = mUserPreferences.getPlaybackPreference().getMixerChannelConfiguration(); MixerChannelConfiguration configuration = mUserPreferences.getPlaybackPreference().getMixerChannelConfiguration();
try
if(configuration != null)
{ {
setMixerChannelConfiguration(configuration); try
{
setMixerChannelConfiguration(configuration);
}
catch(AudioException ae)
{
mLog.error("Error during setup of audio playback configuration. Attempted to use audio mixer [" +
(configuration != null ? configuration.getMixer().toString() : "null") + "] and channel [" +
(configuration != null ? configuration.getMixerChannel().name() : "null") + "]", ae);
}
} }
catch(AudioException ae) else
{ {
mLog.error("Error during setup of audio playback configuration. Attempted to use audio mixer [" + mLog.warn("No audio output devices available");
(configuration != null ? configuration.getMixer().toString() : "null") + "] and channel [" +
(configuration != null ? configuration.getMixerChannel().name() : "null") + "]", ae);
} }
} }

View File

@@ -350,19 +350,26 @@ public class PlaybackPreference extends Preference
{ {
MixerChannelConfiguration defaultConfig = MixerManager.getDefaultOutputMixer(); MixerChannelConfiguration defaultConfig = MixerManager.getDefaultOutputMixer();
String configName = mPreferences.get(PREFERENCE_KEY_MIXER_CHANNEL_CONFIG, defaultConfig.toString()); if(defaultConfig != null)
for(MixerChannelConfiguration config: MixerManager.getOutputMixers())
{ {
if(config.toString().contentEquals(configName)) String configName = mPreferences.get(PREFERENCE_KEY_MIXER_CHANNEL_CONFIG, defaultConfig.toString());
for(MixerChannelConfiguration config: MixerManager.getOutputMixers())
{ {
mMixerChannelConfiguration = config; if(config.toString().contentEquals(configName))
{
mMixerChannelConfiguration = config;
}
}
if(mMixerChannelConfiguration == null)
{
mMixerChannelConfiguration = defaultConfig;
} }
} }
else
if(mMixerChannelConfiguration == null)
{ {
mMixerChannelConfiguration = defaultConfig; mLog.error("Error - no system audio devices available");
} }
} }

View File

@@ -105,6 +105,19 @@ public class AudioRecordingManager implements Listener<AudioSegment>
*/ */
public void processCompletedAudioSegment(AudioSegment audioSegment) public void processCompletedAudioSegment(AudioSegment audioSegment)
{ {
//Debug
if(audioSegment.getAudioBufferCount() == 0)
{
mLog.debug("Audio Segment detected with 0 audio buffers");
}
List<Identifier> toIdentifiers = audioSegment.getIdentifierCollection().getIdentifiers(Role.TO);
if(toIdentifiers.isEmpty())
{
mLog.debug("Audio Segment detected with NO TO identifiers");
}
if(audioSegment.recordAudioProperty().get()) if(audioSegment.recordAudioProperty().get())
{ {
mCompletedAudioSegmentQueue.add(audioSegment); mCompletedAudioSegmentQueue.add(audioSegment);