⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.cc

📁 Linux下比较早的基于命令行的DVD播放器
💻 CC
📖 第 1 页 / 共 2 页
字号:
                    fprintf(stderr, "Invalid subpicture language code/stream number!\n");                    usage(true);                    return false;                }            } else {                forcedSPULanguage = u;            }            break;          case 'D':            if (strcmp(optarg, "pcm")==0) {                audioMode = AM_DIGITAL_PCM;            } else if (strcmp(optarg, "ac3")==0) {                audioMode = AM_DIGITAL_AC3;            } else {                fprintf(stderr, "Invalid digital audio mode: %s\n", optarg);                usage(true);                return false;            }            break;          case 'V':            verboseLogging = true;            break;          case 'L':            logFileName = strdup(optarg);            break;          case 'i':            dataDirectory = strdup(optarg);            break;          case 'o':            audioOffset = atol(optarg);            break;          case 'r':            region = static_cast<unsigned>(atoi(optarg));            break;#ifdef USE_JOYSTICK          case 'j':            js = strdup(optarg);            break;#endif          case 'x':            quitOnExit = true;            break;          case 'O':            useOSSSoundcard = true;            break;          case ':':            fprintf(stderr, "Missing argument!\n");            usage(true);            return false;          case '?':            fprintf(stderr, "Unknown option!\n");            usage(true);            return false;          default:            usage(true);            return false;        }    }    return true;}//------------------------------------------------------------------------------bool Config::setupFromFile(){    char* configFileName = get_path("config");        FILE* configFile = fopen(configFileName, "rt");        free(configFileName);    if (configFile!=0) {        Config& config = getInstance();        char lineBuffer[256];        while(fgets(lineBuffer, sizeof(lineBuffer), configFile)==lineBuffer) {            char* commentStarts = strchr(lineBuffer, '#');            if (commentStarts!=0) *commentStarts = '\0';            char* equalitySign = strchr(lineBuffer, '=');            if (equalitySign==0) continue;            *equalitySign = '\0';            char* key = trimstr(lineBuffer);            char* value = trimstr(equalitySign+1);    //         printf("key='%s', value='%s'\n", key, value);            if (strcmp(key, "keepStandard")==0) {                str2bool(value, config.keepStandard);            } else if (strcmp(key, "keepAspectRatio")==0) {                str2bool(value, config.keepAspectRatio);            } else if (strcmp(key, "dvdPath")==0) {                if (*value!='\0') config.dvdPath = strdup(value);            } else if (strcmp(key, "ejectDVD")==0) {                str2bool(value, config.ejectDVD);            } else if (strcmp(key, "microcode")==0) {                if (*value!='\0') {                    config.uploadMicrocode = true;                    config.microcodeFileName = strdup(value);                }            } else if (strcmp(key, "scrFrequency")==0) {                if (*value!='\0') {                    config.scrFrequency = static_cast<unsigned>(atoi(value));                }            } else if (strcmp(key, "readerBufferSize")==0) {                if (*value!='\0') {                    config.readerBufferSize = static_cast<unsigned>(atoi(value));                }            } else if (strcmp(key, "defaultLanguageCode")==0) {                unsigned u = Util::getLanguageCode(value);                if (u!=0xffff) {                    config.defaultLanguageCode = u;                }            } else if (strcmp(key, "audioMode")==0) {                if (strcmp(value, "analogue")==0) {                    config.audioMode = AM_ANALOGUE;                } else if (strcmp(value, "pcm")==0) {                    config.audioMode = AM_DIGITAL_PCM;                } else if (strcmp(value, "ac3")==0) {                    config.audioMode = AM_DIGITAL_AC3;                }            } else if (strcmp(key, "verboseLogging")==0) {                str2bool(value, config.verboseLogging);            } else if (strcmp(key, "logFileName")==0) {                if (*value!='\0') config.logFileName = strdup(value);            } else if (strcmp(key, "dataDirectory")==0) {                if (*value!='\0') config.dataDirectory = strdup(value);            } else if (strcmp(key, "audioOffset")==0) {                if (*value!='\0') config.audioOffset = atol(value);#ifdef USE_JOYSTICK            } else if (strcmp(key, "joystick")==0) {                if (*value!='\0') config.js = strdup(value);            } else if (strncmp(key, JoystickConfig::jsPrefix, 3)==0) {                joystick.process(key, value);#endif            } else if (strcmp(key, "forcedAudioStream")==0) {                config.forcedAudioStream=static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "forcedAudioLanguage")==0) {                unsigned u = Util::getLanguageCode(value);                if (u!=0xffff) {                    config.forcedAudioLanguage = u;                }            } else if (strcmp(key, "forcedSPUStream")==0) {                config.forcedSPUStream=static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "forcedSPULanguage")==0) {                unsigned u = Util::getLanguageCode(value);                if (u!=0xffff) {                    config.forcedSPULanguage = u;                }            } else if (strcmp(key, "region")==0) {                region = static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "quitOnExit")==0) {                str2bool(value, config.quitOnExit);            } else if (strcmp(key, "defaultVolume")==0) {                defaultVolume = static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "defaultBrightness")==0) {                defaultBrightness = static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "defaultContrast")==0) {                defaultContrast = static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "defaultSaturation")==0) {                defaultSaturation = static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "initialWindowWidth")==0) {                initialWindowWidth = static_cast<size_t>(atoi(value));            } else if (strcmp(key, "initialWindowHeight")==0) {                initialWindowHeight = static_cast<size_t>(atoi(value));            } else if (strcmp(key, "useOSSSoundcard")==0) {                str2bool(value, config.useOSSSoundcard);            } else if (strcmp(key, "repeatProgramThreshold")==0) {                repeatProgramThreshold = static_cast<unsigned>(atoi(value));            } else if (strcmp(key, "fast2Offset")==0) {                fast2Offset = str2timeOffset(value, fast2Offset);            } else if (strcmp(key, "fast3Offset")==0) {                fast3Offset = str2timeOffset(value, fast3Offset);            }        }    }    if (initialWindowHeight==0) {        initialWindowHeight = initialWindowWidth * 3 / 4;    }    return true;}//------------------------------------------------------------------------------void Config::print() const{    printf("Configuration:\n\n");        printf(keepStandard ?            "Keeping TV standard set in driver.\n" :            "Overriding TV standard as necessary.\n");    printf(keepAspectRatio ?            "Keeping aspect ratio set in driver.\n" :            "Overriding aspect ratio as necessary.\n");    if (dvdPath==0) {        printf("Searching for DVD drive at the default locations.\n");    } else {        printf("Using DVD device or dump file: '%s'\n", dvdPath);    }    if (ejectDVD) {        printf("Ejecting DVD on startup.\n");    }    if (uploadMicrocode) {        printf("Uploading microcode from '%s'\n", microcodeFileName);    }    printf("SCR frequency: %u mHz\n", scrFrequency);    printf("Reader buffer size: %u sectors\n", readerBufferSize);    printf("Default language code: %c%c\n",            (char)(defaultLanguageCode>>8), (char)defaultLanguageCode);        printf("Audio mode: ");    switch(audioMode) {      case AM_ANALOGUE:        printf("analogue\n");        break;      case AM_DIGITAL_PCM:        printf("digital PCM\n");        break;      case AM_DIGITAL_AC3:        printf("digital AC-3\n");        break;      default:        printf("unknown!!!\n");        break;    }    if (verboseLogging) {        printf("Logging is verbose.\n");    }    if (logFileName) {        printf("Logging to file '%s'\n", logFileName);    }    printf("Data files are in '%s'\n", dataDirectory);    printf("Audio PTS offset: %lld\n", audioOffset);#ifdef USE_JOYSTICK    printf("Joystick device: '%s'\n", js);#endif    if (forcedAudioStream<8) {        printf("Forcing audio stream #%u\n", forcedAudioStream);    }    if (forcedAudioLanguage!=0xffff) {        printf("Forcing audio language to: %c%c\n",                (char)(forcedAudioLanguage>>8),               (char)(forcedAudioLanguage));    }    if (forcedSPUStream<32) {        printf("Forcing SPU stream #%u\n", forcedSPUStream);    }    if (forcedSPULanguage!=0xffff) {        printf("Forcing SPU language to: %c%c\n",                (char)(forcedSPULanguage>>8),               (char)(forcedSPULanguage));    }    if (region!=0) {        printf("Region: %u\n", region);    }    if (quitOnExit) {        printf("Quitting when an EXIT instruction is hit.\n");    }    if (useOSSSoundcard) {        printf("Using an OSS soundcard for audio even when outputting\n");        printf("via a DXR3 board. Synchronization is not guarenteed!\n");    }    printf("\n");}//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -