#2055 Multi-Frequency channel source with channel rotation monitor startup can get ahead of the tuner channel source and cause an NPE. (#2056)

Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
Denny Sheirer
2024-10-28 03:30:37 -04:00
committed by GitHub
parent 486ac01416
commit b7bbf10415
2 changed files with 19 additions and 9 deletions

View File

@@ -153,13 +153,19 @@ public class MultiFrequencyTunerChannelSource extends TunerChannelSource
@Override
public void stop()
{
mStarted = false;
if(mTunerChannelSource != null)
//Don't perform stop sequence if we haven't been started. There can be a small window on startup where the
//channel rotation monitor can get ahead of the channel source and cause it to try to stop and rotate before
//it has even started, causing an error in the polyphase channel source.
if(mStarted)
{
mTunerChannelSource.stop();
mTunerChannelSource.removeSourceEventListener();
mTunerChannelSource = null;
mStarted = false;
if(mTunerChannelSource != null)
{
mTunerChannelSource.stop();
mTunerChannelSource.removeSourceEventListener();
mTunerChannelSource = null;
}
}
}

View File

@@ -68,9 +68,13 @@ public class ChannelRotationMonitor extends Module implements ISourceEventProvid
mRotationDelay = rotationDelay;
mUserPreferences = userPreferences;
if(mRotationDelay == 0)
if(mRotationDelay < CHANNEL_ROTATION_DELAY_MINIMUM)
{
mRotationDelay = 200;
mRotationDelay = CHANNEL_ROTATION_DELAY_MINIMUM;
}
else if(mRotationDelay > CHANNEL_ROTATION_DELAY_MAXIMUM)
{
mRotationDelay = CHANNEL_ROTATION_DELAY_MAXIMUM;
}
}
@@ -184,7 +188,7 @@ public class ChannelRotationMonitor extends Module implements ISourceEventProvid
}
};
mScheduledFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(runnable, mRotationDelay,
mScheduledFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(runnable, mRotationDelay * 2,
mRotationDelay / 2, TimeUnit.MILLISECONDS);
}
}