void buttons_process() { running = isrunning(); if(!running1 && running) { adc_timer_play(); } if(running1 && !running) { adc_timer_pause(); } if(menu_state == MENU_NONE) { if(right_pressed()) { decr_step(adc_period, ADC_PERIOD_MIN, ADC_PERIOD_MAX, (adc_period >> ADC_PERIOD_SCALE)); osd(); osd_delay(); } else if(left_pressed()) { incr_step(adc_period, ADC_PERIOD_MIN, ADC_PERIOD_MAX, (adc_period >> ADC_PERIOD_SCALE)); osd(); osd_delay(); } else if(up_pressed())
// translated to utf8_main int main(int argc, char *argv[]) { int res = 0; // disable I/O buffering setvbuf(stdout, (char *) nullptr, _IONBF, 0); setvbuf(stderr, (char *) nullptr, _IONBF, 0); // Initialize crash diagnostics diagnostics_module::get_instance()->init_crash_diagnostics(); #if defined(SDLMAME_ANDROID) /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE); #endif // FIXME: this should be done differently #ifdef SDLMAME_UNIX sdl_entered_debugger = 0; #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(SDLMAME_ANDROID)) FcInit(); #endif #endif { sdl_options options; sdl_osd_interface osd(options); osd.register_options(); res = emulator_info::start_frontend(options, osd, argc, argv); } #ifdef SDLMAME_UNIX #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(SDLMAME_ANDROID)) if (!sdl_entered_debugger) { FcFini(); } #endif #endif exit(res); }
// translated to utf8_main int main(int argc, char *argv[]) { int res = 0; // disable I/O buffering setvbuf(stdout, (char *) NULL, _IONBF, 0); setvbuf(stderr, (char *) NULL, _IONBF, 0); // FIXME: this should be done differently #ifdef SDLMAME_UNIX sdl_entered_debugger = 0; #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) FcInit(); #endif #endif { sdl_options options; sdl_osd_interface osd(options); osd.register_options(); cli_frontend frontend(options, osd); res = frontend.execute(argc, argv); } #ifdef SDLMAME_UNIX #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) if (!sdl_entered_debugger) { FcFini(); } #endif #endif exit(res); }
// translated to utf8_main int main(int argc, char *argv[]) { int res = 0; #if defined(SDLMAME_X11) && !(SDLMAME_SDL2) XInitThreads(); #endif #if defined(SDLMAME_WIN32) #if !(SDLMAME_SDL2) /* Load SDL dynamic link library */ if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { fprintf(stderr, "WinMain() error: %s", SDL_GetError()); return(FALSE); } SDL_SetModuleHandle(GetModuleHandle(NULL)); #endif #endif // disable I/O buffering setvbuf(stdout, (char *) NULL, _IONBF, 0); setvbuf(stderr, (char *) NULL, _IONBF, 0); // FIXME: this should be done differently #ifdef SDLMAME_UNIX sdl_entered_debugger = 0; #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) FcInit(); #endif #endif #ifdef SDLMAME_OS2 MorphToPM(); #endif #if defined(SDLMAME_X11) && (SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2) if (SDL_Linked_Version()->patch < 10) /* workaround for SDL choosing a 32-bit ARGB visual */ { Display *display; if ((display = XOpenDisplay(NULL)) && (DefaultDepth(display, DefaultScreen(display)) >= 24)) { XVisualInfo vi; char buf[130]; if (XMatchVisualInfo(display, DefaultScreen(display), 24, TrueColor, &vi)) { snprintf(buf, sizeof(buf), "0x%lx", vi.visualid); osd_setenv(SDLENV_VISUALID, buf, 0); } } if (display) XCloseDisplay(display); } #endif { sdl_options options; sdl_osd_interface osd(options); osd.register_options(); cli_frontend frontend(options, osd); res = frontend.execute(argc, argv); } #ifdef SDLMAME_UNIX #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) if (!sdl_entered_debugger) { FcFini(); } #endif #endif exit(res); }
int main(int argc, char* argv[]) { if (CrashReporting::SendCrashReport(argc, argv)) { return 0; } CrashReporting crash_reporting; #ifdef Q_OS_DARWIN // Do Mac specific startup to get media keys working. // This must go before QApplication initialisation. mac::MacMain(); if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) { // Work around 10.9 issue. // https://bugreports.qt.io/browse/QTBUG-32789 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); } #endif QCoreApplication::setApplicationName("Clementine"); QCoreApplication::setApplicationVersion(CLEMENTINE_VERSION_DISPLAY); QCoreApplication::setOrganizationName("Clementine"); QCoreApplication::setOrganizationDomain("clementine-player.org"); // This makes us show up nicely in gnome-volume-control #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init(); // Deprecated in glib 2.36.0 #endif g_set_application_name(QCoreApplication::applicationName().toLocal8Bit()); RegisterMetaTypes(); // Initialise logging. Log levels are set after the commandline options are // parsed below. logging::Init(); g_log_set_default_handler(reinterpret_cast<GLogFunc>(&logging::GLog), nullptr); CommandlineOptions options(argc, argv); { // Only start a core application now so we can check if there's another // Clementine running without needing an X server. // This MUST be done before parsing the commandline options so QTextCodec // gets the right system locale for filenames. QtSingleCoreApplication a(argc, argv); CheckPortable(); crash_reporting.SetApplicationPath(a.applicationFilePath()); // Parse commandline options - need to do this before starting the // full QApplication so it works without an X server if (!options.Parse()) return 1; logging::SetLevels(options.log_levels()); if (a.isRunning()) { if (options.is_empty()) { qLog(Info) << "Clementine is already running - activating existing window"; } QByteArray serializedOptions = options.Serialize(); if (a.sendMessage(serializedOptions, 5000)) { qLog(Info) << "Options found, sent message to running instance"; return 0; } // Couldn't send the message so start anyway } } #ifdef Q_OS_DARWIN // Must happen after QCoreApplication::setOrganizationName(). setenv( "XDG_CONFIG_HOME", Utilities::GetConfigPath(Utilities::Path_Root).toLocal8Bit().constData(), 1); #endif // Output the version, so when people attach log output to bug reports they // don't have to tell us which version they're using. qLog(Info) << "Clementine" << CLEMENTINE_VERSION_DISPLAY; // Seed the random number generators. time_t t = time(nullptr); srand(t); qsrand(t); IncreaseFDLimit(); QtSingleApplication a(argc, argv); #ifdef HAVE_LIBLASTFM lastfm::ws::ApiKey = LastFMService::kApiKey; lastfm::ws::SharedSecret = LastFMService::kSecret; lastfm::setNetworkAccessManager(new NetworkAccessManager); #endif // A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced // with the default value of 3 in QApplicationPrivate::initialize. { QSettings qt_settings(QSettings::UserScope, "Trolltech"); qt_settings.beginGroup("Qt"); QApplication::setWheelScrollLines( qt_settings.value("wheelScrollLines", QApplication::wheelScrollLines()) .toInt()); } #ifdef Q_OS_DARWIN QCoreApplication::setLibraryPaths( QStringList() << QCoreApplication::applicationDirPath() + "/../PlugIns"); #endif a.setQuitOnLastWindowClosed(false); // Do this check again because another instance might have started by now if (a.isRunning() && a.sendMessage(options.Serialize(), 5000)) { return 0; } #ifndef Q_OS_DARWIN // Gnome on Ubuntu has menu icons disabled by default. I think that's a bad // idea, and makes some menus in Clementine look confusing. QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false); #else QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, true); // Fixes focus issue with NSSearchField, see QTBUG-11401 QCoreApplication::setAttribute(Qt::AA_NativeWindows, true); #endif SetGstreamerEnvironment(); // Set the permissions on the config file on Unix - it can contain passwords // for internet services so it's important that other users can't read it. // On Windows these are stored in the registry instead. #ifdef Q_OS_UNIX { QSettings s; // Create the file if it doesn't exist already if (!QFile::exists(s.fileName())) { QFile file(s.fileName()); file.open(QIODevice::WriteOnly); } // Set -rw------- QFile::setPermissions(s.fileName(), QFile::ReadOwner | QFile::WriteOwner); } #endif // Resources Q_INIT_RESOURCE(data); Q_INIT_RESOURCE(translations); // Add root CA cert for SoundCloud, whose certificate is missing on OS X. QSslSocket::addDefaultCaCertificates( QSslCertificate::fromPath(":/soundcloud-ca.pem", QSsl::Pem)); QSslSocket::addDefaultCaCertificates(QSslCertificate::fromPath( ":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem)); // Has the user forced a different language? QString override_language = options.language(); if (override_language.isEmpty()) { QSettings s; s.beginGroup("General"); override_language = s.value("language").toString(); } const QString language = override_language.isEmpty() ? Utilities::SystemLanguageName() : override_language; // Translations LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language); LoadTranslation("clementine", ":/translations", language); LoadTranslation("clementine", a.applicationDirPath(), language); LoadTranslation("clementine", QDir::currentPath(), language); #ifdef Q_OS_WIN32 // Set the language for qtsparkle qtsparkle::LoadTranslations(language); #endif // Icons IconLoader::Init(); // This is a nasty hack to ensure that everything in libprotobuf is // initialised in the main thread. It fixes issue 3265 but nobody knows why. // Don't remove this unless you can reproduce the error that it fixes. ParseAProto(); QtConcurrent::run(&ParseAProto); Application app; app.set_language_name(language); // Network proxy QNetworkProxyFactory::setApplicationProxyFactory( NetworkProxyFactory::Instance()); #ifdef Q_OS_LINUX // In 11.04 Ubuntu decided that the system tray should be reserved for certain // whitelisted applications. Clementine will override this setting and insert // itself into the list of whitelisted apps. UbuntuUnityHack hack; #endif // Q_OS_LINUX // Create the tray icon and OSD std::unique_ptr<SystemTrayIcon> tray_icon( SystemTrayIcon::CreateSystemTrayIcon()); OSD osd(tray_icon.get(), &app); #ifdef HAVE_DBUS mpris::Mpris mpris(&app); #endif // Window MainWindow w(&app, tray_icon.get(), &osd, options); #ifdef Q_OS_DARWIN mac::EnableFullScreen(w); #endif // Q_OS_DARWIN #ifdef HAVE_GIO ScanGIOModulePath(); #endif #ifdef HAVE_DBUS QObject::connect(&mpris, SIGNAL(RaiseMainWindow()), &w, SLOT(Raise())); #endif QObject::connect(&a, SIGNAL(messageReceived(QByteArray)), &w, SLOT(CommandlineOptionsReceived(QByteArray))); int ret = a.exec(); #ifdef Q_OS_LINUX // The nvidia driver would cause Clementine (or any application that used // opengl) to use 100% cpu on shutdown. See: // http://code.google.com/p/clementine-player/issues/detail?id=2088 // https://bugs.gentoo.org/show_bug.cgi?id=375615 // Work around this problem by exiting immediately (and not running the buggy // nvidia atexit shutdown handler) if we're using one of the affected versions // of the nvidia driver. QFile self_maps("/proc/self/maps"); if (self_maps.open(QIODevice::ReadOnly)) { QByteArray data = self_maps.readAll(); if (data.contains("libnvidia-tls.so.")) { qLog(Warning) << "Exiting immediately to work around NVIDIA driver bug"; _exit(ret); } self_maps.close(); } #endif return ret; }
void Settings::writeSettings() { setValue(KEY_LANGUAGE, language()); setValue(KEY_SESSION_AUTOPLAY, sessionAutoplay()); setValue(KEY_SESSION_CHANNEL, sessionChannel()); setValue(KEY_SESSION_REMEMBER_VOLUME, sessionRememberVolume()); setValue(KEY_SESSION_VOLUME, sessionVolume()); if (globalConfig && globalConfig->disableSettings("channels")) { remove("channels"); } else { setValue(KEY_PLAYLIST, playlist()); setValue(KEY_PLAYLIST_UPDATE, playlistUpdate()); setValue(KEY_PLAYLIST_UPDATE_URL, playlistUpdateUrl()); setValue(KEY_RADIO_CATEGORY, radioCategory()); setValue(KEY_HD_CATEGORY, hdCategory()); setValue(KEY_UDPXY, udpxy()); setValue(KEY_UDPXY_URL, udpxyUrl()); setValue(KEY_UDPXY_PORT, udpxyPort()); } if (globalConfig && globalConfig->disableSettings("gui")) { remove("gui"); } else { setValue(KEY_WIDTH, width()); setValue(KEY_HEIGHT, height()); setValue(KEY_POS_X, posX()); setValue(KEY_POS_Y, posY()); setValue(KEY_OSD, osd()); setValue(KEY_TRAY_ENABLED, trayEnabled()); setValue(KEY_HIDE_TO_TRAY, hideToTray()); setValue(KEY_MOUSE_WHEEL, mouseWheel()); setValue(KEY_REMEMBER_GUI_SESSION, rememberGuiSession()); setValue(KEY_ICONS, icons()); } if (globalConfig && globalConfig->disableSettings("backend")) { remove("backend"); } else { setValue(KEY_VOUT, vout()); setValue(KEY_AOUT, aout()); setValue(KEY_YUV_TO_RGB, yuvToRgb()); setValue(KEY_SPDIF, spdif()); setValue(KEY_REMEMBER_VIDEO_SETTINGS, rememberVideoSettings()); setValue(KEY_REMEMBER_VIDEO_PER_CHANNEL, rememberVideoPerChannel()); setValue(KEY_ASPECT_RATIO, aspectRatio()); setValue(KEY_CROP_RATIO, cropRatio()); setValue(KEY_DEINTERLACING, deinterlacing()); setValue(KEY_AUDIO_LANGUAGE, audioLanguage()); setValue(KEY_SUBTITLE_LANGUAGE, subtitleLanguage()); setValue(KEY_MUTE_ON_MINIMIZE, muteOnMinimize()); setValue(KEY_TELETEXT, teletext()); } if (globalConfig && globalConfig->disableSettings("recorder")) { remove("recorder"); } else { setValue(KEY_RECORDER_DIRECTORY, recorderDirectory()); setValue(KEY_SNAPSHOTS_DIRECTORY, snapshotsDirectory()); } if (globalConfig && globalConfig->disableSettings("xmltv")) { remove("xmltv"); } else { setValue(KEY_XMLTV_UPDATE, xmltvUpdate()); setValue(KEY_XMLTV_UPDATE_LOCATION, xmltvUpdateLocation()); setValue(KEY_XMLTV_UPDATE_REMOTE, xmltvUpdateRemote()); } sync(); }
void TetrahedralityParam::writeOrderParameter() { int nSelected = 0; for (int i = 0; i < nBins_; ++i) { nSelected = nSelected + int(Q_histogram_[i]*deltaQ_); } std::ofstream osq((getOutputFileName() + "Q").c_str()); if (osq.is_open()) { osq << "# Tetrahedrality Parameters\n"; osq << "# selection: (" << selectionScript_ << ")\n"; osq << "# \n"; // Normalize by number of frames and write it out: for (int i = 0; i < nBins_; ++i) { RealType Qval = MinQ_ + (i + 0.5) * deltaQ_; osq << Qval; osq << "\t" << (RealType) (Q_histogram_[i]/deltaQ_)/nSelected; osq << "\n"; } osq.close(); }else { sprintf(painCave.errMsg, "TetrahedralityParam: unable to open %s\n", (getOutputFileName() + "q").c_str()); painCave.isFatal = 1; simError(); } DumpReader reader(info_, dumpFilename_); int nFrames = reader.getNFrames(); if (nFrames == 1) { std::vector<StuntDouble*>::iterator iter; std::ofstream osd((getOutputFileName() + "dxyz").c_str()); if (osd.is_open()) { osd << Distorted_.size() << "\n"; osd << "\n"; for (iter = Distorted_.begin(); iter != Distorted_.end(); ++iter) { Vector3d position; position = (*iter)->getPos(); osd << "O " << "\t"; for (unsigned int z = 0; z < position.size(); z++) { osd << position[z] << " " << "\t"; } osd << "\n"; } osd.close(); } std::ofstream ost((getOutputFileName() + "txyz").c_str()); if (ost.is_open()) { ost << Tetrahedral_.size() << "\n"; ost << "\n"; for (iter = Tetrahedral_.begin(); iter != Tetrahedral_.end(); ++iter) { Vector3d position; position = (*iter)->getPos(); ost << "O " << "\t"; for (unsigned int z = 0; z < position.size(); z++) { ost << position[z] << " " << "\t"; } ost << "\n"; } ost.close(); } } }