Added use of native C result flags

resampler
Marcin Kondej 2022-01-14 15:11:23 +01:00
commit c41fa4e9ff
2 zmienionych plików z 8 dodań i 10 usunięć

Wyświetl plik

@ -83,14 +83,11 @@ int main(int argc, char** argv)
return 0;
}
int result = EXIT_SUCCESS;
std::signal(SIGINT, sigIntHandler);
std::signal(SIGTSTP, sigIntHandler);
auto finally = [&]() {
auto temp = transmitter;
transmitter = nullptr;
delete temp;
};
try {
transmitter = new Transmitter();
std::cout << "Broadcasting at " << frequency << " MHz with "
@ -110,10 +107,11 @@ int main(int argc, char** argv)
} while (!stop && (optind < argc));
} catch (std::exception &catched) {
std::cout << "Error: " << catched.what() << std::endl;
finally();
return EXIT_FAILURE;
result = EXIT_FAILURE;
}
finally();
auto temp = transmitter;
transmitter = nullptr;
delete temp;
return EXIT_SUCCESS;
return result;
}

Wyświetl plik

@ -522,7 +522,7 @@ void Transmitter::TransmitViaDma(WaveReader &reader, ClockOutput &output, unsign
for (i = 0; i < samples.size(); i++) {
float value = samples[i].GetMonoValue();
while (i == ((dma.GetControllBlockAddress() - allocated.GetPhysicalAddress(dmaCb)) / (2 * sizeof(DMAControllBlock)))) {
std::this_thread::sleep_for(std::chrono::microseconds(BUFFER_TIME / 10));
std::this_thread::sleep_for(std::chrono::microseconds(BUFFER_TIME / 10));
}
clkDiv[i] = CLK_PASSWORD | (0xffffff & (clockDivisor - static_cast<int>(round(value * divisorRange))));
cbOffset += 2;