1810 P25 Voice frame list concurrent modification error. Added synchronized to method to deconflict when the audio module or the binary frame recorder can access the message and not step on each other. Issue was noted in the phase 2 module, but update the phase 1 module as well to protect against the issue. (#1833)

Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
Denny Sheirer
2024-02-10 03:40:57 -05:00
committed by GitHub
parent d019388034
commit f6c4cc8a5f
3 changed files with 64 additions and 65 deletions

View File

@@ -1,7 +1,6 @@
/* /*
* ****************************************************************************** * *****************************************************************************
* sdrtrunk * Copyright (C) 2014-2024 Dennis Sheirer
* Copyright (C) 2014-2019 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -15,23 +14,21 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* ***************************************************************************** * ****************************************************************************
*/ */
package io.github.dsheirer.module.decode.p25.phase1.message.ldu; package io.github.dsheirer.module.decode.p25.phase1.message.ldu;
import io.github.dsheirer.bits.CorrectedBinaryMessage; import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.P25Message; import io.github.dsheirer.module.decode.p25.phase1.message.P25Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* LDU voice frame
*/
public abstract class LDUMessage extends P25Message public abstract class LDUMessage extends P25Message
{ {
private final static Logger mLog = LoggerFactory.getLogger(LDUMessage.class);
public static final int IMBE_FRAME_1 = 0; public static final int IMBE_FRAME_1 = 0;
public static final int IMBE_FRAME_2 = 144; public static final int IMBE_FRAME_2 = 144;
public static final int IMBE_FRAME_3 = 328; public static final int IMBE_FRAME_3 = 328;
@@ -41,10 +38,16 @@ public abstract class LDUMessage extends P25Message
public static final int IMBE_FRAME_7 = 1064; public static final int IMBE_FRAME_7 = 1064;
public static final int IMBE_FRAME_8 = 1248; public static final int IMBE_FRAME_8 = 1248;
public static final int IMBE_FRAME_9 = 1424; public static final int IMBE_FRAME_9 = 1424;
public static final int[] LOW_SPEED_DATA = {1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1408, 1409, 1410, 1411,
1412, 1413, 1414, 1415};
private List<byte[]> mIMBIFrames;
public static final int[] LOW_SPEED_DATA = {1392, 1393, 1394, 1395, 1396, 1397, /**
1398, 1399, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415}; * Constructs an instance
* @param message with data
* @param nac code
* @param timestamp for the message
*/
public LDUMessage(CorrectedBinaryMessage message, int nac, long timestamp) public LDUMessage(CorrectedBinaryMessage message, int nac, long timestamp)
{ {
super(message, nac, timestamp); super(message, nac, timestamp);
@@ -58,6 +61,10 @@ public abstract class LDUMessage extends P25Message
return getMessage().getHex(LOW_SPEED_DATA, 4); return getMessage().getHex(LOW_SPEED_DATA, 4);
} }
/**
* Base message used by subclass implementations.
* @return base message
*/
public String getMessageStub() public String getMessageStub()
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -70,24 +77,25 @@ public abstract class LDUMessage extends P25Message
} }
/** /**
* Returns a 162 byte array containing 9 IMBE voice frames of 18-bytes * Returns a 162 byte array containing 9 IMBE voice frames of 18-bytes* (144-bits) each. Each frame is intact as
* (144-bits) each. Each frame is intact as transmitted and requires * transmitted and requires deinterleaving, error correction, derandomizing, etc.
* deinterleaving, error correction, derandomizing, etc.
*/ */
public List<byte[]> getIMBEFrames() public synchronized List<byte[]> getIMBEFrames()
{ {
List<byte[]> frames = new ArrayList<byte[]>(); if(mIMBIFrames == null)
{
mIMBIFrames = new ArrayList<>();
mIMBIFrames.add(getMessage().get(IMBE_FRAME_1, IMBE_FRAME_1 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_2, IMBE_FRAME_2 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_3, IMBE_FRAME_3 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_4, IMBE_FRAME_4 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_5, IMBE_FRAME_5 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_6, IMBE_FRAME_6 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_7, IMBE_FRAME_7 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_8, IMBE_FRAME_8 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_9, IMBE_FRAME_9 + 144).toByteArray());
}
frames.add(getMessage().get(IMBE_FRAME_1, IMBE_FRAME_1 + 144).toByteArray()); return mIMBIFrames;
frames.add(getMessage().get(IMBE_FRAME_2, IMBE_FRAME_2 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_3, IMBE_FRAME_3 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_4, IMBE_FRAME_4 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_5, IMBE_FRAME_5 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_6, IMBE_FRAME_6 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_7, IMBE_FRAME_7 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_8, IMBE_FRAME_8 + 144).toByteArray());
frames.add(getMessage().get(IMBE_FRAME_9, IMBE_FRAME_9 + 144).toByteArray());
return frames;
} }
} }

View File

@@ -1,23 +1,20 @@
/* /*
* *****************************************************************************
* Copyright (C) 2014-2024 Dennis Sheirer
* *
* * ****************************************************************************** * This program is free software: you can redistribute it and/or modify
* * Copyright (C) 2014-2019 Dennis Sheirer * it under the terms of the GNU General Public License as published by
* * * the Free Software Foundation, either version 3 of the License, or
* * This program is free software: you can redistribute it and/or modify * (at your option) any later version.
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>
* * *****************************************************************************
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/ */
package io.github.dsheirer.module.decode.p25.phase2.timeslot; package io.github.dsheirer.module.decode.p25.phase2.timeslot;
@@ -25,7 +22,6 @@ package io.github.dsheirer.module.decode.p25.phase2.timeslot;
import io.github.dsheirer.bits.BinaryMessage; import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.bits.CorrectedBinaryMessage; import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.module.decode.p25.phase2.enumeration.DataUnitID; import io.github.dsheirer.module.decode.p25.phase2.enumeration.DataUnitID;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -61,7 +57,7 @@ public class Voice2Timeslot extends AbstractVoiceTimeslot
/** /**
* Voice frames contained in this timeslot * Voice frames contained in this timeslot
*/ */
public List<BinaryMessage> getVoiceFrames() public synchronized List<BinaryMessage> getVoiceFrames()
{ {
if(mVoiceFrames == null) if(mVoiceFrames == null)
{ {

View File

@@ -1,23 +1,20 @@
/* /*
* *****************************************************************************
* Copyright (C) 2014-2024 Dennis Sheirer
* *
* * ****************************************************************************** * This program is free software: you can redistribute it and/or modify
* * Copyright (C) 2014-2019 Dennis Sheirer * it under the terms of the GNU General Public License as published by
* * * the Free Software Foundation, either version 3 of the License, or
* * This program is free software: you can redistribute it and/or modify * (at your option) any later version.
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>
* * *****************************************************************************
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/ */
package io.github.dsheirer.module.decode.p25.phase2.timeslot; package io.github.dsheirer.module.decode.p25.phase2.timeslot;
@@ -25,7 +22,6 @@ package io.github.dsheirer.module.decode.p25.phase2.timeslot;
import io.github.dsheirer.bits.BinaryMessage; import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.bits.CorrectedBinaryMessage; import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.module.decode.p25.phase2.enumeration.DataUnitID; import io.github.dsheirer.module.decode.p25.phase2.enumeration.DataUnitID;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -62,7 +58,7 @@ public class Voice4Timeslot extends AbstractVoiceTimeslot
/** /**
* Voice frames contained in this timeslot * Voice frames contained in this timeslot
*/ */
public List<BinaryMessage> getVoiceFrames() public synchronized List<BinaryMessage> getVoiceFrames()
{ {
if(mVoiceFrames == null) if(mVoiceFrames == null)
{ {
@@ -71,7 +67,6 @@ public class Voice4Timeslot extends AbstractVoiceTimeslot
mVoiceFrames.add(getMessage().getSubMessage(FRAME_2_START, FRAME_2_START + FRAME_LENGTH)); mVoiceFrames.add(getMessage().getSubMessage(FRAME_2_START, FRAME_2_START + FRAME_LENGTH));
mVoiceFrames.add(getMessage().getSubMessage(FRAME_3_START, FRAME_3_START + FRAME_LENGTH)); mVoiceFrames.add(getMessage().getSubMessage(FRAME_3_START, FRAME_3_START + FRAME_LENGTH));
mVoiceFrames.add(getMessage().getSubMessage(FRAME_4_START, FRAME_4_START + FRAME_LENGTH)); mVoiceFrames.add(getMessage().getSubMessage(FRAME_4_START, FRAME_4_START + FRAME_LENGTH));
return mVoiceFrames;
} }
return mVoiceFrames; return mVoiceFrames;