int main(int argc, char *argv[]) { QString cfg_file; std::string conf; bool clierr=false; bool edit_conf = false; #if QT_VERSION >= 0x040800 QCoreApplication::setAttribute(Qt::AA_X11InitThreads); #endif QApplication a(argc, argv); QCoreApplication::setOrganizationName(GQRX_ORG_NAME); QCoreApplication::setOrganizationDomain(GQRX_ORG_DOMAIN); QCoreApplication::setApplicationName(GQRX_APP_NAME); QCoreApplication::setApplicationVersion(VERSION); // setup controlport via environment variables // see http://lists.gnu.org/archive/html/discuss-gnuradio/2013-05/msg00270.html // Note: tried using gr::prefs().save() but that doesn't have effect until the next time if (qputenv("GR_CONF_CONTROLPORT_ON", "False")) qDebug() << "Controlport disabled"; else qDebug() << "Failed to disable controlport"; #if 0 //#ifdef WITH_PORTAUDIO // FIXME: This should be user configurable although for now // the audio-osx-source is useless and the only way to use the // Funcube Dongle Pro and Pro+ is via portaudio. if (qputenv("GR_CONF_AUDIO_AUDIO_MODULE", "portaudio")) qDebug() << "GR_CONF_AUDIO_AUDIO_MODULE set to portaudio"; else qDebug() << "Failed to set GR_CONF_AUDIO_AUDIO_MODULE=portaudio"; #endif // setup the program options po::options_description desc("Command line options"); desc.add_options() ("help,h", "This help message") ("list,l", "List existing configurations") ("conf,c", po::value<std::string>(&conf), "Start with this config file") ("edit,e", "Edit the config file before using it") ("reset,r", "Reset configuration file") ; po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); } catch(const boost::program_options::invalid_command_line_syntax& ex) { /* happens if e.g. -c without file name */ clierr = true; } catch(const boost::program_options::unknown_option& ex) { /* happens if e.g. -c without file name */ clierr = true; } po::notify(vm); // print the help message if (vm.count("help") || clierr) { std::cout << "Gqrx software defined radio receiver " << VERSION << std::endl; std::cout << desc << std::endl; return 1; } if (vm.count("list")) { list_conf(); return 0; } if (!conf.empty()) { cfg_file = QString::fromStdString(conf); qDebug() << "User specified config file:" << cfg_file; } else { cfg_file = "default.conf"; qDebug() << "No user supplied config file. Using" << cfg_file; } if (vm.count("reset")) reset_conf(cfg_file); else if (vm.count("edit")) edit_conf = true; // Mainwindow will check whether we have a configuration // and open the config dialog if there is none or the specified // file does not exist. MainWindow w(cfg_file, edit_conf); if (w.configOk) { w.show(); return a.exec(); } else { return 1; } }
int main(int argc, char *argv[]) { QString cfg_file; std::string conf; std::string style; bool clierr = false; bool edit_conf = false; int return_code; QApplication app(argc, argv); QCoreApplication::setOrganizationName(GQRX_ORG_NAME); QCoreApplication::setOrganizationDomain(GQRX_ORG_DOMAIN); QCoreApplication::setApplicationName(GQRX_APP_NAME); QCoreApplication::setApplicationVersion(VERSION); // setup controlport via environment variables // see http://lists.gnu.org/archive/html/discuss-gnuradio/2013-05/msg00270.html // Note: tried using gr::prefs().save() but that doesn't have effect until the next time if (qputenv("GR_CONF_CONTROLPORT_ON", "False")) qDebug() << "Controlport disabled"; else qDebug() << "Failed to disable controlport"; // setup the program options po::options_description desc("Command line options"); desc.add_options() ("help,h", "This help message") ("style,s", po::value<std::string>(&style), "Use the give style (fusion, windows)") ("list,l", "List existing configurations") ("conf,c", po::value<std::string>(&conf), "Start with this config file") ("edit,e", "Edit the config file before using it") ("reset,r", "Reset configuration file") ; po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); } catch(const boost::program_options::invalid_command_line_syntax& ex) { /* happens if e.g. -c without file name */ clierr = true; } catch(const boost::program_options::unknown_option& ex) { /* happens if e.g. -c without file name */ clierr = true; } po::notify(vm); // print the help message if (vm.count("help") || clierr) { std::cout << "Gqrx software defined radio receiver " << VERSION << std::endl; std::cout << desc << std::endl; return 1; } if (vm.count("style")) QApplication::setStyle(QString::fromStdString(style)); if (vm.count("list")) { list_conf(); return 0; } // check whether audio backend is functional #ifdef WITH_PORTAUDIO PaError err = Pa_Initialize(); if (err != paNoError) { QString message = QString("Portaudio error: %1").arg(Pa_GetErrorText(err)); qCritical() << message; QMessageBox::critical(0, "Audio Error", message, QMessageBox::Abort, QMessageBox::NoButton); return 1; } #endif #ifdef WITH_PULSEAUDIO int error = 0; pa_simple *test_sink; pa_sample_spec ss; ss.format = PA_SAMPLE_FLOAT32LE; ss.rate = 48000; ss.channels = 2; test_sink = pa_simple_new(NULL, "Gqrx Test", PA_STREAM_PLAYBACK, NULL, "Test stream", &ss, NULL, NULL, &error); if (!test_sink) { QString message = QString("Pulseaudio error: %1").arg(pa_strerror(error)); qCritical() << message; QMessageBox::critical(0, "Audio Error", message, QMessageBox::Abort, QMessageBox::NoButton); return 1; } pa_simple_free(test_sink); #endif if (!conf.empty()) { cfg_file = QString::fromStdString(conf); qDebug() << "User specified config file:" << cfg_file; } else { cfg_file = "default.conf"; qDebug() << "No user supplied config file. Using" << cfg_file; } if (vm.count("reset")) reset_conf(cfg_file); else if (vm.count("edit")) edit_conf = true; // Mainwindow will check whether we have a configuration // and open the config dialog if there is none or the specified // file does not exist. MainWindow w(cfg_file, edit_conf); if (w.configOk) { w.show(); return_code = app.exec(); } else { return_code = 1; } #ifdef WITH_PORTAUDIO Pa_Terminate(); #endif return return_code; }