mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-23 06:45:39 +08:00
Add safety and logging code to the Voice unit.
This commit is contained in:
20
Voice.cpp
20
Voice.cpp
@@ -159,8 +159,12 @@ void CVoice::createVoice(const std::vector<std::string>& words)
|
|||||||
{
|
{
|
||||||
unsigned int ambeLength = 0U;
|
unsigned int ambeLength = 0U;
|
||||||
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
|
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
|
||||||
CPositions* position = m_positions.at(*it);
|
if (m_positions.count(*it) > 0U) {
|
||||||
ambeLength += position->m_length;
|
CPositions* position = m_positions.at(*it);
|
||||||
|
ambeLength += position->m_length;
|
||||||
|
} else {
|
||||||
|
LogWarning("Unable to find character/phrase \"%s\" in the index", (*it).c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the AMBE is an integer number of DMR frames
|
// Ensure that the AMBE is an integer number of DMR frames
|
||||||
@@ -178,11 +182,13 @@ void CVoice::createVoice(const std::vector<std::string>& words)
|
|||||||
|
|
||||||
unsigned int pos = 0U;
|
unsigned int pos = 0U;
|
||||||
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
|
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
|
||||||
CPositions* position = m_positions.at(*it);
|
if (m_positions.count(*it) > 0U) {
|
||||||
unsigned int start = position->m_start;
|
CPositions* position = m_positions.at(*it);
|
||||||
unsigned int length = position->m_length;
|
unsigned int start = position->m_start;
|
||||||
::memcpy(ambeData + pos, m_ambe + start, length);
|
unsigned int length = position->m_length;
|
||||||
pos += length;
|
::memcpy(ambeData + pos, m_ambe + start, length);
|
||||||
|
pos += length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<CDMRData*>::iterator it = m_data.begin(); it != m_data.end(); ++it)
|
for (std::vector<CDMRData*>::iterator it = m_data.begin(); it != m_data.end(); ++it)
|
||||||
|
|||||||
Reference in New Issue
Block a user