Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and clean up #2 #100

Merged
merged 18 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set(FREEDV_SOURCES
dlg_filter.cpp
dlg_options.cpp
dlg_ptt.cpp
dlg_plugin.cpp
main.cpp
pa_wrapper.cpp
plot.cpp
Expand Down Expand Up @@ -52,6 +51,12 @@ set(FREEDV_SOURCES
pskreporter.h
callsign_encoder.cpp
callsign_encoder.h
udp.cpp
util.cpp
eq.cpp
voicekeyer.cpp
playrec.cpp
ongui.cpp
)

set(FREEDV_SOURCES_OSX
Expand Down
117 changes: 0 additions & 117 deletions src/afreedvplugin.c

This file was deleted.

6 changes: 3 additions & 3 deletions src/callsign_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CallsignEncoder::setCallsign(const char* callsign)
convertDigitToASCII_(&translatedCallsign_[1], crcDigit2);

int truncIndex = 0;
for(int index = 0; index < strlen(translatedCallsign_); index += 2, truncIndex += 4)
for(size_t index = 0; index < strlen(translatedCallsign_); index += 2, truncIndex += 4)
{
// Encode the character as four bytes with parity bits.
int inputRaw = ((translatedCallsign_[index] & 0x3F) << 6) | (translatedCallsign_[index+1] & 0x3F);
Expand Down Expand Up @@ -200,7 +200,7 @@ bool CallsignEncoder::isCallsignValid() const
void CallsignEncoder::convert_callsign_to_ota_string_(const char* input, char* output) const
{
int outidx = 0;
for (int index = 0; index < strlen(input); index++)
for (size_t index = 0; index < strlen(input); index++)
{
bool addSync = false;
if (input[index] >= 38 && input[index] <= 47)
Expand Down Expand Up @@ -248,7 +248,7 @@ void CallsignEncoder::convert_callsign_to_ota_string_(const char* input, char* o
void CallsignEncoder::convert_ota_string_to_callsign_(const char* input, char* output)
{
int outidx = 0;
for (int index = 0; index < strlen(input); index++)
for (size_t index = 0; index < strlen(input); index++)
{
if (input[index] >= 1 && input[index] <= 9)
{
Expand Down
58 changes: 29 additions & 29 deletions src/dlg_audiooptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void AudioOptsDialog::buildTestControls(PlotScalar **plotScalar, wxButton **btnT
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
AudioOptsDialog::AudioOptsDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)
{
fprintf(stderr, "pos %d %d\n", pos.x, pos.y);
if (g_verbose) fprintf(stderr, "pos %d %d\n", pos.x, pos.y);
Pa_Init();

wxBoxSizer* mainSizer;
Expand Down Expand Up @@ -413,7 +413,7 @@ int AudioOptsDialog::setTextCtrlIfDevNumValid(wxTextCtrl *textCtrl, wxListCtrl *
if (aDevNum == devNum) {
found_devNum = 1;
textCtrl->SetValue(listCtrl->GetItemText(i, 0) + " (" + wxString::Format(wxT("%i"),devNum) + ")");
printf("setting focus of %d\n", i);
if (g_verbose) fprintf(stderr,"setting focus of %d\n", i);
listCtrl->SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
}
}
Expand All @@ -436,14 +436,14 @@ int AudioOptsDialog::ExchangeData(int inout)
// Map sound card device numbers to tx/rx device numbers depending
// on number of sound cards in use

printf("EXCHANGE_DATA_IN:\n");
printf(" g_nSoundCards: %d\n", g_nSoundCards);
printf(" g_soundCard1InDeviceNum: %d\n", g_soundCard1InDeviceNum);
printf(" g_soundCard1OutDeviceNum: %d\n", g_soundCard1OutDeviceNum);
printf(" g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate);
printf(" g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum);
printf(" g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum);
printf(" g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate);
if (g_verbose) fprintf(stderr,"EXCHANGE_DATA_IN:\n");
if (g_verbose) fprintf(stderr," g_nSoundCards: %d\n", g_nSoundCards);
if (g_verbose) fprintf(stderr," g_soundCard1InDeviceNum: %d\n", g_soundCard1InDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard1OutDeviceNum: %d\n", g_soundCard1OutDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate);
if (g_verbose) fprintf(stderr," g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate);

if (g_nSoundCards == 0) {
m_textCtrlRxIn ->SetValue("none"); rxInAudioDeviceNum = -1;
Expand Down Expand Up @@ -498,7 +498,7 @@ int AudioOptsDialog::ExchangeData(int inout)
m_cbSampleRateRxOut->SetValue(wxString::Format(wxT("%i"),g_soundCard2SampleRate));
}
}
printf(" rxInAudioDeviceNum: %d\n rxOutAudioDeviceNum: %d\n txInAudioDeviceNum: %d\n txOutAudioDeviceNum: %d\n",
if (g_verbose) fprintf(stderr," rxInAudioDeviceNum: %d\n rxOutAudioDeviceNum: %d\n txInAudioDeviceNum: %d\n txOutAudioDeviceNum: %d\n",
rxInAudioDeviceNum, rxOutAudioDeviceNum, txInAudioDeviceNum, txOutAudioDeviceNum);
}

Expand All @@ -508,8 +508,8 @@ int AudioOptsDialog::ExchangeData(int inout)
int valid_two_card_config = 0;
wxString sampleRate1, sampleRate2;

printf("EXCHANGE_DATA_OUT:\n");
printf(" rxInAudioDeviceNum: %d\n rxOutAudioDeviceNum: %d\n txInAudioDeviceNum: %d\n txOutAudioDeviceNum: %d\n",
if (g_verbose) fprintf(stderr,"EXCHANGE_DATA_OUT:\n");
if (g_verbose) fprintf(stderr," rxInAudioDeviceNum: %d\n rxOutAudioDeviceNum: %d\n txInAudioDeviceNum: %d\n txOutAudioDeviceNum: %d\n",
rxInAudioDeviceNum, rxOutAudioDeviceNum, txInAudioDeviceNum, txOutAudioDeviceNum);

// ---------------------------------------------------------------
Expand Down Expand Up @@ -574,7 +574,7 @@ int AudioOptsDialog::ExchangeData(int inout)

}

printf(" valid_one_card_config: %d valid_two_card_config: %d\n", valid_one_card_config, valid_two_card_config);
if (g_verbose) fprintf(stderr," valid_one_card_config: %d valid_two_card_config: %d\n", valid_one_card_config, valid_two_card_config);

if (!valid_one_card_config && !valid_two_card_config) {
wxMessageBox(wxT("Invalid one or two sound card configuration"), wxT(""), wxOK);
Expand Down Expand Up @@ -610,13 +610,13 @@ int AudioOptsDialog::ExchangeData(int inout)
g_soundCard2SampleRate = wxAtoi(sampleRate2);
}

printf(" g_nSoundCards: %d\n", g_nSoundCards);
printf(" g_soundCard1InDeviceNum: %d\n", g_soundCard1InDeviceNum);
printf(" g_soundCard1OutDeviceNum: %d\n", g_soundCard1OutDeviceNum);
printf(" g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate);
printf(" g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum);
printf(" g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum);
printf(" g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate);
if (g_verbose) fprintf(stderr," g_nSoundCards: %d\n", g_nSoundCards);
if (g_verbose) fprintf(stderr," g_soundCard1InDeviceNum: %d\n", g_soundCard1InDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard1OutDeviceNum: %d\n", g_soundCard1OutDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate);
if (g_verbose) fprintf(stderr," g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum);
if (g_verbose) fprintf(stderr," g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate);

wxConfigBase *pConfig = wxConfigBase::Get();
if (pConfig != NULL) {
Expand Down Expand Up @@ -663,7 +663,7 @@ int AudioOptsDialog:: buildListOfSupportedSampleRates(wxComboBox *cbSampleRate,

deviceInfo = Pa_GetDeviceInfo(devNum);
if (deviceInfo == NULL) {
printf("Pa_GetDeviceInfo(%d) failed!\n", devNum);
if (g_verbose) fprintf(stderr,"Pa_GetDeviceInfo(%d) failed!\n", devNum);
cbSampleRate->Clear();
return 0;
}
Expand Down Expand Up @@ -693,11 +693,11 @@ int AudioOptsDialog:: buildListOfSupportedSampleRates(wxComboBox *cbSampleRate,
if( err == paFormatIsSupported ) {
str.Printf("%i", (int)standardSampleRates[i]);
cbSampleRate->AppendString(str);
printf("%i ", (int)standardSampleRates[i]);
if (g_verbose) fprintf(stderr,"%i ", (int)standardSampleRates[i]);
numSampleRates++;
}
}
printf("\n");
if (g_verbose) fprintf(stderr,"\n");

return numSampleRates;
}
Expand Down Expand Up @@ -958,7 +958,7 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca
return;
if (devNum < 0)
return;
printf("devNum %d\n", devNum);
if (g_verbose) fprintf(stderr,"devNum %d\n", devNum);

fifo = codec2_fifo_create((int)(DT*TEST_WAVEFORM_PLOT_FS*2)); assert(fifo != NULL);
src = src_new(SRC_SINC_FASTEST, 1, &src_error); assert(src != NULL);
Expand All @@ -985,7 +985,7 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca

sampleRate = wxAtoi(m_cbSampleRateRxIn->GetValue());
nBufs = TEST_WAVEFORM_PLOT_TIME*sampleRate/TEST_BUF_SIZE;
printf("inputChannels: %d nBufs %d\n", inputChannels, nBufs);
if (g_verbose) fprintf(stderr,"inputChannels: %d nBufs %d\n", inputChannels, nBufs);

err = Pa_OpenStream(
&stream,
Expand Down Expand Up @@ -1093,7 +1093,7 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotSc
else
outputChannels = 2;

printf("outputChannels: %d\n", outputChannels);
if (g_verbose) fprintf(stderr,"outputChannels: %d\n", outputChannels);

outputParameters.device = devNum;
outputParameters.channelCount = outputChannels;
Expand Down Expand Up @@ -1274,13 +1274,13 @@ void AudioOptsDialog::OnOkAudioParameters(wxCommandEvent& event)

// We only accept OK if config sucessful

printf("status: %d m_isPaInitialized: %d\n", status, m_isPaInitialized);
if (g_verbose) fprintf(stderr,"status: %d m_isPaInitialized: %d\n", status, m_isPaInitialized);
if (status == 0) {
if(m_isPaInitialized)
{
if((pa_err = Pa_Terminate()) == paNoError)
{
printf("terminated OK\n");
if (g_verbose) fprintf(stderr, "terminated OK\n");
m_isPaInitialized = false;
}
else
Expand Down
Loading