Skip to content

Commit

Permalink
Debug messages clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
KejPi committed Apr 26, 2023
1 parent f7cf069 commit e6598e5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 46 deletions.
22 changes: 11 additions & 11 deletions gui/audiodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ AudioDecoder::AudioDecoder(QObject *parent) : QObject(parent)
m_rawOut = fopen("audio.raw", "wb");
if (!m_rawOut)
{
qDebug("Unable to open file: audio.raw");
qDebug("AudioDecoder: Unable to open file: audio.raw");
}
#endif
#ifdef AUDIO_DECODER_AAC_OUT
m_aacOut = fopen("audio.aac", "wb");
if (!m_aacOut)
{
qDebug("Unable to open file: audio.aac");
qDebug("AudioDecoder: Unable to open file: audio.aac");
}
#endif
#ifdef AUDIO_DECODER_MP2_OUT
m_mp2Out = fopen("audio.mp2", "wb");
if (!m_mp2Out)
{
qDebug("Unable to open file: audio.mp2");
qDebug("AudioDecoder: Unable to open file: audio.mp2");
}
#endif
}
Expand Down Expand Up @@ -105,7 +105,7 @@ AudioDecoder::~AudioDecoder()
int res = mpg123_close(m_mp2DecoderHandle);
if (MPG123_OK != res)
{
qDebug("%s: error while mpg123_close: %s\n", Q_FUNC_INFO, mpg123_plain_strerror(res));
qDebug("AudioDecoder: error while mpg123_close: %s\n", mpg123_plain_strerror(res));
}

mpg123_delete(m_mp2DecoderHandle);
Expand Down Expand Up @@ -216,7 +216,7 @@ void AudioDecoder::deinitMPG123()
int res = mpg123_close(m_mp2DecoderHandle);
if (MPG123_OK != res)
{
qDebug("%s: error while mpg123_close: %s\n", Q_FUNC_INFO, mpg123_plain_strerror(res));
qDebug("AudioDecoder: error while mpg123_close: %s\n", mpg123_plain_strerror(res));
}

mpg123_delete(m_mp2DecoderHandle);
Expand Down Expand Up @@ -257,7 +257,7 @@ void AudioDecoder::readAACHeader()

emit audioParametersInfo(m_audioParameters);

qDebug("%s %d kHz %s",
qDebug("AudioDecoder: %s %d kHz %s",
(m_aacHeader.bits.sbr_flag ? (m_aacHeader.bits.ps_flag ? "HE-AAC v2" : "HE-AAC") : "AAC-LC"),
(m_aacHeader.bits.dac_rate ? 48 : 32),
(m_aacHeader.bits.aac_channel_mode || m_aacHeader.bits.ps_flag ? "stereo" : "mono")
Expand Down Expand Up @@ -392,7 +392,7 @@ void AudioDecoder::initAACDecoder()
}
m_outputFrame = new uint8_t[m_outputFrameLen];

qDebug("Output SR = %d, channels = %d", m_aacHeader.bits.dac_rate ? 48000 : 32000, channels);
qDebug("AudioDecoder: Output sample rate %d Hz, channels: %d", m_aacHeader.bits.dac_rate ? 48000 : 32000, channels);

// m_outFifoPtr->numChannels = uint8_t(channels);
// m_outFifoPtr->sampleRate = uint32_t(m_aacHeader.bits.dac_rate ? 48000 : 32000);
Expand Down Expand Up @@ -458,7 +458,7 @@ void AudioDecoder::initAACDecoder()
m_muteRamp.push_back(g * g);
}

qDebug("Output SR = %lu, channels = %d", sampleRate, numChannels);
qDebug("AudioDecoder: Output sample rate %lu Hz, channels: %d", sampleRate, numChannels);

setOutput(sampleRate, numChannels);
}
Expand Down Expand Up @@ -582,7 +582,7 @@ void AudioDecoder::processMP2(RadioControlAudioData *inData)
int numChannels, enc;
mpg123_getformat(m_mp2DecoderHandle, &sampleRate, &numChannels, &enc);

qDebug("New MP2 format: %ld Hz, %d channels, encoding %d", sampleRate, numChannels, enc);
qDebug("AudioDecoder: New MP2 format: %ld Hz, %d channels, encoding %d", sampleRate, numChannels, enc);

setOutput(sampleRate, numChannels);

Expand Down Expand Up @@ -673,7 +673,7 @@ void AudioDecoder::getFormatMP2()

if (MPG123_OK != res)
{
qDebug("%s: error while mpg123_info: %s", Q_FUNC_INFO, mpg123_plain_strerror(res));
qDebug("AudioDecoder: error while mpg123_info: %s", mpg123_plain_strerror(res));
}

m_audioParameters.coding = AudioCoding::MP2;
Expand Down Expand Up @@ -788,7 +788,7 @@ void AudioDecoder::processAAC(RadioControlAudioData *inData)
result = aacDecoder_DecodeFrame(m_aacDecoderHandle, (INT_PCM *)m_outputFrame, m_outputFrameLen / sizeof(INT_PCM), AACDEC_CONCEAL * conceal);
if (AAC_DEC_OK != result)
{
qDebug() << "Error decoding AAC frame: " << result;
qDebug() << "AudioDecoder: Error decoding AAC frame: " << result;
}

//qDebug("error = %d | samples = %d", !IS_OUTPUT_VALID(result), m_outputFrameLen / sizeof(INT_PCM));
Expand Down
20 changes: 10 additions & 10 deletions gui/audiooutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ AudioOutput::AudioOutput( QObject *parent) : QObject(parent)
m_rawOut = fopen("audio.raw", "wb");
if (!m_rawOut)
{
qDebug("Unable to open file: audio.raw");
qDebug("AudioOutput: Unable to open file: audio.raw");
}
#endif

Expand All @@ -72,7 +72,7 @@ AudioOutput::~AudioOutput()
PaError err = Pa_Terminate();
if (paNoError != err)
{
qDebug("PortAudio Pa_Terminate() error: %s", Pa_GetErrorText(err));
qDebug("AudioOutput: PortAudio Pa_Terminate() error: %s", Pa_GetErrorText(err));
}

#ifdef AUDIOOUTPUT_RAW_FILE_OUT
Expand Down Expand Up @@ -213,7 +213,7 @@ int AudioOutput::portAudioCb( const void *inputBuffer, void *outputBuffer, unsig
#else
if (statusFlags)
{
qDebug() << "Port Audio statusFlags =" << statusFlags;
qDebug() << "AudioOutput: Port Audio statusFlags =" << statusFlags;
}

return static_cast<AudioOutput*>(ctx)->portAudioCbPrivate(outputBuffer, nBufferFrames);
Expand Down Expand Up @@ -370,7 +370,7 @@ int AudioOutput::portAudioCbPrivate(void *outputBuffer, unsigned long nBufferFra
// minimum mute time is 1ms (m_sampleRate_kHz samples) , if less then hard mute
if (m_sampleRate_kHz*m_bytesPerFrame > count)
{ // nothing to play (cannot apply mute ramp)
qDebug("Hard mute [no samples available]");
qDebug("AudioOutput: Hard mute [no samples available]");
memset(outputBuffer, 0, bytesToRead);
m_playbackState = AudioOutputPlaybackState::Muted;
return paContinue;
Expand Down Expand Up @@ -570,7 +570,7 @@ int AudioOutput::portAudioCbPrivate(void *outputBuffer, unsigned long nBufferFra
// unmute
if (Request::None == request)
{ // unmute can be requested only when there is enough samples
qDebug() << "Unmuting audio";
qDebug() << "AudioOutput: Unmuting audio";

float coe = 2.0 - m_muteFactor;
float gain = AUDIOOUTPUT_FADE_MIN_LIN;
Expand All @@ -593,7 +593,7 @@ int AudioOutput::portAudioCbPrivate(void *outputBuffer, unsigned long nBufferFra
else
{ // there is so request => muting
// mute can be requested when there is not enough samples or from HMI
qDebug("Muting... [available %u samples]", availableSamples);
qDebug("AudioOutput: Muting... [available %u samples]", availableSamples);
float coe = m_muteFactor;
if (availableSamples < AUDIOOUTPUT_FADE_TIME_MS * m_sampleRate_kHz)
{ // less samples than expected available => need to calculate new coef
Expand Down Expand Up @@ -953,7 +953,7 @@ qint64 AudioIODevice::readData(char *data, qint64 len)
}
else
{ // not enough samples ==> inserting silence
//qDebug("Muted: Inserting silence [%lu ms]", nBufferFrames/m_sampleRate_kHz);
//qDebug("AudioOutput: Muted: Inserting silence [%lu ms]", nBufferFrames/m_sampleRate_kHz);
memset(data, 0, bytesToRead);

// done
Expand All @@ -970,7 +970,7 @@ qint64 AudioIODevice::readData(char *data, qint64 len)
// minimum mute time is 1ms (m_sampleRate_kHz samples) , if less then hard mute
if (m_sampleRate_kHz*m_bytesPerFrame > count)
{ // nothing to play
qDebug("Hard mute [no samples available]");
qDebug("AudioOutput: Hard mute [no samples available]");
memset(data, 0, bytesToRead);
m_playbackState = AudioOutputPlaybackState::Muted;
return bytesToRead;
Expand Down Expand Up @@ -1038,7 +1038,7 @@ qint64 AudioIODevice::readData(char *data, qint64 len)
// unmute
if (false == muteRequest)
{ // unmute can be requested only when there is enough samples
qDebug() << "Unmuting audio";
qDebug() << "AudioOutput: Unmuting audio";

float coe = 2.0 - m_muteFactor;
float gain = AUDIOOUTPUT_FADE_MIN_LIN;
Expand All @@ -1059,7 +1059,7 @@ qint64 AudioIODevice::readData(char *data, qint64 len)
}
else
{ // mute can be requested when there is not enough samples or from HMI
qDebug("Muting... [available %u samples]", availableSamples);
qDebug("AudioOutput: Muting... [available %u samples]", availableSamples);
float coe = m_muteFactor;
if (availableSamples < AUDIOOUTPUT_FADE_TIME_MS * m_sampleRate_kHz)
{ // less samples than expected available => need to calculate new coef
Expand Down
43 changes: 25 additions & 18 deletions gui/radiocontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool RadioControl::init()
}
else
{
qDebug() << "DAB processing init failed";
qDebug() << "RadioControl: DAB processing init failed";
m_dabsdrHandle = nullptr;

return false;
Expand Down Expand Up @@ -129,7 +129,7 @@ void RadioControl::onDabEvent(RadioControlEvent * pEvent)
case RadioControlEventType::SYNC_STATUS:
{
#if RADIO_CONTROL_VERBOSE
qDebug("Sync = %d", pEvent->syncStatus.syncLevel);
qDebug("RadioControl: Sync = %d", pEvent->syncStatus.syncLevel);
#endif

if ((DABSDR_SYNC_LEVEL_FIC == pEvent->syncStatus.syncLevel) && (RADIO_CONTROL_UEID_INVALID == m_ensemble.ueid))
Expand All @@ -144,7 +144,7 @@ void RadioControl::onDabEvent(RadioControlEvent * pEvent)
if (DABSDR_NSTAT_SUCCESS == pEvent->status)
{
#if RADIO_CONTROL_VERBOSE > 1
qDebug() << "Tune success" << pEvent->frequency;
qDebug() << "RadioControl: Tune success" << pEvent->frequency;
#endif
if ((pEvent->frequency != m_frequency) || (0 == m_frequency))
{ // in first step, DAB is tuned to 0 that is != desired frequency
Expand All @@ -159,11 +159,13 @@ void RadioControl::onDabEvent(RadioControlEvent * pEvent)

// this is to request autontf when EID changes
m_enaAutoNotification = false;

qDebug("RadioControl: Current frequency %.3f MHz", pEvent->frequency/1000.0);;
}
}
else
{
qDebug() << "Tune error" << pEvent->status;
qDebug() << "RadioControl: Tune error" << pEvent->status;
}
}
break;
Expand Down Expand Up @@ -195,7 +197,7 @@ void RadioControl::onDabEvent(RadioControlEvent * pEvent)
case RadioControlEventType::SERVICE_LIST:
{
#if RADIO_CONTROL_VERBOSE
qDebug() << "RadioControlEvent::SERVICE_LIST";
qDebug() << "RadioControlEventType::SERVICE_LIST";
#endif
eventHandler_serviceList(pEvent);
delete pEvent->pServiceList;
Expand Down Expand Up @@ -343,7 +345,7 @@ void RadioControl::onDabEvent(RadioControlEvent * pEvent)
emit mscCounter(pData->mscCrcOkCntr, pData->mscCrcErrorCntr);

#if RADIO_CONTROL_VERBOSE > 0
qDebug("AutoNotify: sync %d, freq offset = %.1f Hz, SNR = %.1f dB",
qDebug("RadioControl: AutoNotify: sync %d, freq offset = %.1f Hz, SNR = %.1f dB",
pData->syncLevel, pData->freqOffset*0.1, pData->snr10/10.0);
#endif

Expand Down Expand Up @@ -424,7 +426,7 @@ void RadioControl::onDabEvent(RadioControlEvent * pEvent)
break;

default:
qDebug() << Q_FUNC_INFO << "ERROR: Unsupported event" << int(pEvent->type);
qDebug() << "RadioControl: ERROR: Unsupported event" << int(pEvent->type);
}

delete pEvent;
Expand Down Expand Up @@ -508,7 +510,10 @@ void RadioControl::tuneService(uint32_t freq, uint32_t SId, uint8_t SCIdS)
}
}
else
{ // service selection will be done after tune
{
qDebug("RadioControl: Tuning %.3f -> %.3f MHz ...", m_frequency/1000.0, freq/1000.0);

// service selection will be done after tune
m_enaAutoNotification = false;
m_frequency = freq;

Expand Down Expand Up @@ -591,7 +596,7 @@ void RadioControl::startUserApplication(DabUserApplicationType uaType, bool star
QHash<DabUserApplicationType,RadioControlUserApp>::const_iterator uaIt = scIt->userApps.constFind(uaType);
if (scIt->userApps.cend() != uaIt)
{
qDebug() << "Found XPAD app" << int(uaType);
qDebug() << "RadioControl: Found XPAD app" << int(uaType);
dabXPadAppStart(uaIt->xpadData.xpadAppTy, 1, DABSDR_ID_AUDIO_PRIMARY);
return;
}
Expand Down Expand Up @@ -1232,7 +1237,7 @@ void RadioControl::eventHandler_serviceComponentList(RadioControlEvent *pEvent)
else
{ // SId not found
#if RADIO_CONTROL_VERBOSE > 0
qDebug("Service SID %8.8X not in service list", sid.value());
qDebug("RadioControl: Service SID %8.8X not in service list", sid.value());
#endif
}
}
Expand Down Expand Up @@ -1319,7 +1324,8 @@ void RadioControl::eventHandler_serviceSelection(RadioControlEvent *pEvent)
if (scIt != serviceIt->serviceComponents.end())
{ // service components exists in service
if (!scIt->autoEnabled)
{ // if not data service that is autoimatically enabled
{ // if not data service that is automatically enabled
qDebug("RadioControl: Playing: [%6.6X] %-18s %6.6X : %d", m_ensemble.ueid, scIt->label.toLocal8Bit().data(), pEvent->SId, pEvent->SCIdS);
// store current service
m_currentService.SId = pEvent->SId;
m_currentService.SCIdS = pEvent->SCIdS;
Expand Down Expand Up @@ -1429,7 +1435,7 @@ void RadioControl::eventHandler_announcementSwitching(RadioControlEvent * pEvent
else
{ // ignoring -> cluster not relevant for current service
#if RADIO_CONTROL_VERBOSE > 1
qDebug() << "Ignoring announcement cluster ID" << pAsw->clusterId;
qDebug() << "RadioControl: Ignoring announcement cluster ID" << pAsw->clusterId;
#endif
}
pAsw += 1;
Expand Down Expand Up @@ -1629,7 +1635,8 @@ void RadioControl::announcementHandler(dabsdrAsw_t *pAnnouncement)
if ((announcementId >= 0) && (pAnnouncement->ASwFlags & m_currentService.announcement.enaFlags))
{ // valid ASw
#if RADIO_CONTROL_VERBOSE > 0
qDebug() << DabTables::getAnnouncementNameEnglish(static_cast<DabAnnouncement>(announcementId))
qDebug() << "RadioControl:"
<< DabTables::getAnnouncementNameEnglish(static_cast<DabAnnouncement>(announcementId))
<< "announcement in subchannel" << pAnnouncement->subChId
<< "cluster ID" << pAnnouncement->clusterId;
#endif
Expand Down Expand Up @@ -1913,7 +1920,7 @@ void RadioControl::dabNotificationCb(dabsdrNotificationCBData_t * p, void * ctx)
else
{
#if RADIO_CONTROL_VERBOSE > 0
qDebug("SId %4.4X not found", pInfo->SId);
qDebug("RadioControl: SId %4.4X not found", pInfo->SId);
#endif
}
}
Expand Down Expand Up @@ -1954,7 +1961,7 @@ void RadioControl::dabNotificationCb(dabsdrNotificationCBData_t * p, void * ctx)
else
{
#if RADIO_CONTROL_VERBOSE > 0
qDebug("SId %4.4X, SCIdS %2.2X not found", pInfo->SId, pInfo->SCIdS);
qDebug("RadioControl: SId %4.4X, SCIdS %2.2X not found", pInfo->SId, pInfo->SCIdS);
#endif
}
}
Expand Down Expand Up @@ -2078,7 +2085,7 @@ void RadioControl::dabNotificationCb(dabsdrNotificationCBData_t * p, void * ctx)
}
break;
default:
qDebug("Unexpected notification %d", p->nid);
qDebug("RadioControl: Unexpected notification %d", p->nid);
}
}

Expand All @@ -2087,7 +2094,7 @@ void RadioControl::dynamicLabelCb(dabsdrDynamicLabelCBData_t * p, void * ctx)
if (0 == p->len)
{ // do nothing - empty data group
#if RADIO_CONTROL_VERBOSE > 0
qDebug("Empty DL data received\n");
qDebug("RadioControl: Empty DL data received\n");
#endif
return;
}
Expand All @@ -2108,7 +2115,7 @@ void RadioControl::dataGroupCb(dabsdrDataGroupCBData_t * p, void * ctx)
if (0 == p->dgLen)
{ // do nothing - empty data group
#if RADIO_CONTROL_VERBOSE > 0
qDebug("Empty data group type %d received\n", p->userAppType);
qDebug("RadioControl: Empty data group type %d received\n", p->userAppType);
#endif
return;
}
Expand Down
Loading

0 comments on commit e6598e5

Please sign in to comment.