From: drowe67 Date: Thu, 3 May 2018 01:43:15 +0000 (+0000) Subject: adding audio fifo counters, but audio messed up X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=f09f0624af6bb3c628eb1bb6c58fdc8ff2228c2b;p=freetel-svn-tracking.git adding audio fifo counters, but audio messed up git-svn-id: https://svn.code.sf.net/p/freetel/code@3559 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-dev/src/fdmdv2_main.cpp b/freedv-dev/src/fdmdv2_main.cpp index d744622f..7c937745 100644 --- a/freedv-dev/src/fdmdv2_main.cpp +++ b/freedv-dev/src/fdmdv2_main.cpp @@ -90,6 +90,13 @@ int g_soundCard2InDeviceNum; int g_soundCard2OutDeviceNum; int g_soundCard2SampleRate; +// PortAudio over/underflow counters + +int g_infifo1_full; +int g_outfifo1_empty; +int g_infifo2_full; +int g_outfifo2_empty; + // playing and recording from sound files SNDFILE *g_sfPlayFile; @@ -1245,6 +1252,13 @@ void MainFrame::OnTimer(wxTimerEvent &evt) } } } + + /* FIFO under/overflow debug counters */ + + char fifo_counters[80]; + sprintf(fifo_counters, "%d %d %d %d", g_infifo1_full, g_outfifo1_empty, g_infifo2_full, g_outfifo2_empty); + //wxString fifo_counters_string(fifo_counters); m_textFifos->SetLabel(fifo_counters_string); + } // command from UDP thread that is best processed in main thread to avoid seg faults @@ -2768,8 +2782,9 @@ void MainFrame::startRxStream() g_rxUserdata->outfifo1 = fifo_create(10*N48); g_rxUserdata->outfifo2 = fifo_create(10*N48); g_rxUserdata->infifo2 = fifo_create(10*N48); - fprintf(stderr, "N48: %d 10*N48: %d\n", N48, 10*N48); - + //fprintf(stderr, "N48: %d 10*N48: %d\n", N48, 10*N48); + g_infifo1_full = g_outfifo1_empty = g_infifo2_full = g_outfifo2_empty = 0; + /* TODO: might be able to tune these on a per waveform basis */ g_rxUserdata->rxinfifo = fifo_create(20 * N8); @@ -3668,6 +3683,7 @@ void per_frame_rx_processing( // + In dual sound card mode outfifo1 is the "to radio" modulator signal to the SSB tx. // //------------------------------------------------------------------------- + int MainFrame::rxCallback( const void *inputBuffer, void *outputBuffer, @@ -3691,9 +3707,6 @@ int MainFrame::rxCallback( wxMutexLocker lock(g_mutexProtectingCallbackData); - //fprintf(g_logfile, "cb1 statusFlags: 0x%x framesPerBuffer: %d rptr: 0x%x wptr: 0x%x \n", (int)statusFlags, - // framesPerBuffer, rptr, wptr); - // // RX side processing -------------------------------------------- // @@ -3702,22 +3715,18 @@ int MainFrame::rxCallback( assert(framesPerBuffer < MAX_FPB); - if(rptr) { - //fprintf(g_logfile,"in %ld %d\n", framesPerBuffer, g_in++); - //g_indata += framesPerBuffer; + if (rptr) { for(i = 0; i < framesPerBuffer; i++, rptr += cbData->inputChannels1) indata[i] = rptr[0]; if (fifo_write(cbData->infifo1, indata, framesPerBuffer)) { - //fprintf(g_logfile, "infifo1 full\n"); + g_infifo1_full++; } - //fifo_write(cbData->outfifo1, indata, framesPerBuffer); } // OK now set up output samples for this callback - if(wptr) { - //fprintf(g_logfile,"out %ld %d\n", framesPerBuffer, g_out++); - if (fifo_read(cbData->outfifo1, outdata, framesPerBuffer) == 0) { + if (wptr) { + if (fifo_read(cbData->outfifo1, outdata, framesPerBuffer) == 0) { // write signal to both channels @@ -3726,7 +3735,6 @@ int MainFrame::rxCallback( cbData->voxTonePhase += 2.0*M_PI*VOX_TONE_FREQ/g_soundCard1SampleRate; cbData->voxTonePhase -= 2.0*M_PI*floor(cbData->voxTonePhase/(2.0*M_PI)); wptr[0] = VOX_TONE_AMP*cos(cbData->voxTonePhase); - //printf("%f %d\n", cbData->voxTonePhase, wptr[0]); } else wptr[0] = outdata[i]; @@ -3735,7 +3743,7 @@ int MainFrame::rxCallback( } } else { - //fprintf(g_logfile, "outfifo1 empty\n"); + g_outfifo1_empty++; // zero output if no data available for(i = 0; i < framesPerBuffer; i++, wptr += 2) { wptr[0] = 0; @@ -3769,39 +3777,21 @@ int MainFrame::txCallback( wxMutexLocker lock(g_mutexProtectingCallbackData); - // if (statusFlags) - // printf("cb2 statusFlags: 0x%x\n", (int)statusFlags); - // assemble a mono buffer and write to FIFO assert(framesPerBuffer < MAX_FPB); - if(rptr) { + if (rptr) { for(i = 0; i < framesPerBuffer; i++, rptr += cbData->inputChannels2) indata[i] = rptr[0]; - } - - //#define SC2_LOOPBACK -#ifdef SC2_LOOPBACK - //TODO: This doesn't work unless using the same soundcard! - - if(wptr) { - for(i = 0; i < framesPerBuffer; i++, wptr += 2) { - wptr[0] = indata[i]; - wptr[1] = indata[i]; - } - } - -#else - if(rptr) { if (fifo_write(cbData->infifo2, indata, framesPerBuffer)) { - //fprintf(g_logfile, "infifo2 full\n"); + g_infifo2_full++; } } // OK now set up output samples for this callback - if(wptr) { + if (wptr) { if (fifo_read(cbData->outfifo2, outdata, framesPerBuffer) == 0) { // write signal to both channels */ @@ -3811,7 +3801,7 @@ int MainFrame::txCallback( } } else { - //fprintf(g_logfile, "outfifo2 empty\n"); + g_outfifo2_empty++; // zero output if no data available for(i = 0; i < framesPerBuffer; i++, wptr += 2) { wptr[0] = 0; @@ -3819,7 +3809,7 @@ int MainFrame::txCallback( } } } -#endif + return paContinue; } diff --git a/freedv-dev/src/topFrame.cpp b/freedv-dev/src/topFrame.cpp index d7251314..ff991f30 100644 --- a/freedv-dev/src/topFrame.cpp +++ b/freedv-dev/src/topFrame.cpp @@ -169,6 +169,9 @@ TopFrame::TopFrame(wxString plugInName, wxWindow* parent, wxWindowID id, const w m_textResyncs = new wxStaticText(this, wxID_ANY, wxT("Resyncs: 0"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); sbSizer_ber->Add(m_textResyncs, 0, wxALIGN_LEFT, 1); + m_textFifos = new wxStaticText(this, wxID_ANY, wxT("0 0 0 0"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + sbSizer_ber->Add(m_textFifos, 0, wxALIGN_LEFT, 1); + leftSizer->Add(sbSizer_ber,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); //------------------------------ diff --git a/freedv-dev/src/topFrame.h b/freedv-dev/src/topFrame.h index fe97b0cc..c59e2dad 100644 --- a/freedv-dev/src/topFrame.h +++ b/freedv-dev/src/topFrame.h @@ -103,6 +103,7 @@ class TopFrame : public wxFrame wxStaticText *m_textErrors; wxStaticText *m_textBER; wxStaticText *m_textResyncs; + wxStaticText *m_textFifos; wxRadioButton *m_rbSync; wxRadioButton *m_rb1400old;