@@ -134,12 +134,38 @@ public DMRTrafficChannelManager(Channel parentChannel)
134
134
/**
135
135
* Sets the current parent control channel frequency so that channel grants for the current frequency do not
136
136
* produce an additional traffic channel allocation.
137
- * @param currentControlFrequency for current control channel.
137
+ * @param previousControlFrequency for the current control channel (to remove from allocated channels)
138
+ * @param currentControlFrequency for current control channel (to add to allocated channels)
138
139
* @param channel for the current control channel
139
140
*/
140
- public void setCurrentControlFrequency (long currentControlFrequency , Channel channel )
141
+ public void setCurrentControlFrequency (long previousControlFrequency , long currentControlFrequency , Channel channel )
141
142
{
142
- mAllocatedChannelFrequencyMap .put (currentControlFrequency , channel );
143
+ if (previousControlFrequency == currentControlFrequency )
144
+ {
145
+ return ;
146
+ }
147
+
148
+ mLock .lock ();
149
+
150
+ try
151
+ {
152
+ Channel existing = mAllocatedChannelFrequencyMap .get (previousControlFrequency );
153
+
154
+ //Only remove the channel if it is non-null and it matches the current control channel.
155
+ if (channel .equals (existing ))
156
+ {
157
+ //Unlock the frequency in the channel rotation monitor
158
+ getInterModuleEventBus ().post (FrequencyLockChangeRequest .unlock (previousControlFrequency ));
159
+ mAllocatedChannelFrequencyMap .remove (previousControlFrequency );
160
+ }
161
+
162
+ mAllocatedChannelFrequencyMap .put (currentControlFrequency , channel );
163
+ getInterModuleEventBus ().post (FrequencyLockChangeRequest .lock (currentControlFrequency ));
164
+ }
165
+ finally
166
+ {
167
+ mLock .unlock ();
168
+ }
143
169
}
144
170
145
171
/**
@@ -197,6 +223,10 @@ public void convertToTrafficChannel(Channel channel, long currentFrequency, ICha
197
223
{
198
224
long rest = restChannel .getDownlinkFrequency ();
199
225
226
+ mLog .info ("CONVERT TO TRAFFIC - RESTFREQ:" + rest +
227
+ " ALLOCATED:" + (mAllocatedChannelFrequencyMap .containsKey (rest )) +
228
+ " CONFIG TYPE:" + channel .getSourceConfiguration ().getSourceType ());
229
+
200
230
//Only do the conversion of the original channel has multiple frequencies defined and the rest channel is
201
231
//one of those frequencies
202
232
if (rest > 0 && !mAllocatedChannelFrequencyMap .containsKey (rest ) &&
0 commit comments