Simplify the audio output processing.

This commit is contained in:
Jonathan Naylor 2019-02-05 10:20:44 +00:00
parent 69a7c557dc
commit 27f8434286

View File

@ -264,7 +264,9 @@ unsigned int CVoice::read(unsigned char* data)
if (m_status != VS_SENDING)
return 0U;
if ((m_sent * IMBE_LENGTH) >= m_voiceLength) {
unsigned int offset = m_sent * IMBE_LENGTH;
if (offset >= m_voiceLength) {
::memcpy(data, REC80, 17U);
m_timer.stop();
m_voiceLength = 0U;
@ -280,19 +282,19 @@ unsigned int CVoice::read(unsigned char* data)
switch (m_n) {
case 0x62U:
::memcpy(data, REC62, 22U);
::memcpy(data + 10U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 10U, m_voiceData + offset, IMBE_LENGTH);
length = 22U;
m_n = 0x63U;
break;
case 0x63U:
::memcpy(data, REC63, 14U);
::memcpy(data + 1U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 1U, m_voiceData + offset, IMBE_LENGTH);
length = 14U;
m_n = 0x64U;
break;
case 0x64U:
::memcpy(data, REC64, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x65U;
break;
@ -301,7 +303,7 @@ unsigned int CVoice::read(unsigned char* data)
data[1U] = (m_dstId >> 16) & 0xFFU;
data[2U] = (m_dstId >> 8) & 0xFFU;
data[3U] = (m_dstId >> 0) & 0xFFU;
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x66U;
break;
@ -310,85 +312,85 @@ unsigned int CVoice::read(unsigned char* data)
data[1U] = (m_srcId >> 16) & 0xFFU;
data[2U] = (m_srcId >> 8) & 0xFFU;
data[3U] = (m_srcId >> 0) & 0xFFU;
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x67U;
break;
case 0x67U:
::memcpy(data, REC67, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x68U;
break;
case 0x68U:
::memcpy(data, REC68, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x69U;
break;
case 0x69U:
::memcpy(data, REC69, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x6AU;
break;
case 0x6AU:
::memcpy(data, REC6A, 16U);
::memcpy(data + 4U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 4U, m_voiceData + offset, IMBE_LENGTH);
length = 16U;
m_n = 0x6BU;
break;
case 0x6BU:
::memcpy(data, REC6B, 22U);
::memcpy(data + 10U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 10U, m_voiceData + offset, IMBE_LENGTH);
length = 22U;
m_n = 0x6CU;
break;
case 0x6CU:
::memcpy(data, REC6C, 14U);
::memcpy(data + 1U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 1U, m_voiceData + offset, IMBE_LENGTH);
length = 14U;
m_n = 0x6DU;
break;
case 0x6DU:
::memcpy(data, REC6D, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x6EU;
break;
case 0x6EU:
::memcpy(data, REC6E, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x6FU;
break;
case 0x6FU:
::memcpy(data, REC6F, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x70U;
break;
case 0x70U:
::memcpy(data, REC70, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x71U;
break;
case 0x71U:
::memcpy(data, REC71, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x72U;
break;
case 0x72U:
::memcpy(data, REC72, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 5U, m_voiceData + offset, IMBE_LENGTH);
length = 17U;
m_n = 0x73U;
break;
default:
::memcpy(data, REC73, 16U);
::memcpy(data + 4U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
::memcpy(data + 4U, m_voiceData + offset, IMBE_LENGTH);
length = 16U;
m_n = 0x62U;
break;