Skip to content

Commit

Permalink
#2055 Multi-Frequency channel source with channel rotation monitor st…
Browse files Browse the repository at this point in the history
…artup can get ahead of the tuner channel source and cause an NPE.
  • Loading branch information
Dennis Sheirer committed Oct 28, 2024
1 parent 486ac01 commit b095b9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,19 @@ public void start()
@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;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public ChannelRotationMonitor(Collection<State> activeStates, long rotationDelay
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;
}
}

Expand Down Expand Up @@ -184,7 +188,7 @@ public void start()
}
};

mScheduledFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(runnable, mRotationDelay,
mScheduledFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(runnable, mRotationDelay * 2,
mRotationDelay / 2, TimeUnit.MILLISECONDS);
}
}
Expand Down

0 comments on commit b095b9a

Please sign in to comment.