Skip to content

Commit

Permalink
#2055 MultiFrequencyTunerChannelSource Null Pointer Error On Channel …
Browse files Browse the repository at this point in the history
…Source Shutdown - different solution to resolve possible memory leak with previous solution. Also fixes P25 issue where a traffic channel that doesn't get started is returned to the traffic channel pool.
  • Loading branch information
Dennis Sheirer committed Nov 1, 2024
1 parent 7509245 commit 6edab7d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,16 @@ private void stopChannelSource(PolyphaseChannelSource channelSource)
synchronized(mBufferDispatcher)
{
mChannelSources.remove(channelSource);
mPolyphaseChannelizer.removeChannel(channelSource);

if(mPolyphaseChannelizer != null)
{
mPolyphaseChannelizer.removeChannel(channelSource);
}

mSourceEventBroadcaster.broadcast(SourceEvent.channelCountChange(getTunerChannelCount()));

//If this is the last/only channel, deregister to stop the sample buffers
if(mPolyphaseChannelizer.getRegisteredChannelCount() == 0)
if(mPolyphaseChannelizer != null && mPolyphaseChannelizer.getRegisteredChannelCount() == 0)
{
mNativeBufferProvider.removeBufferListener(mBufferDispatcher);
mBufferDispatcher.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,18 @@ private void requestTrafficChannelStart(Channel trafficChannel, APCO25Channel ap
startChannelRequest.addPreloadDataContent(new P25FrequencyBandPreloadDataContent(mFrequencyBandMap.values()));
getInterModuleEventBus().post(startChannelRequest);
}
else
{
//Return the channel to the traffic channel pool since we didn't start it.
if(mManagedPhase1TrafficChannels.contains(trafficChannel))
{
mAvailablePhase1TrafficChannelQueue.add(trafficChannel);
}
else if(mManagedPhase2TrafficChannels.contains(trafficChannel))
{
mAvailablePhase2TrafficChannelQueue.add(trafficChannel);
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,13 @@ public void start()
@Override
public void stop()
{
//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)
{
mStarted = false;
mStarted = false;

if(mTunerChannelSource != null)
{
mTunerChannelSource.stop();
mTunerChannelSource.removeSourceEventListener();
mTunerChannelSource = null;
}
if(mTunerChannelSource != null)
{
mTunerChannelSource.stop();
mTunerChannelSource.removeSourceEventListener();
mTunerChannelSource = null;
}
}

Expand Down

0 comments on commit 6edab7d

Please sign in to comment.