static int _find_config_bool(const void *start, node_lookup_fn find, const char *path, int fail) { const struct dm_config_node *n = find(start, path); const struct dm_config_value *v; int b; if (n) { v = n->v; switch (v->type) { case DM_CFG_INT: b = v->v.i ? 1 : 0; log_very_verbose("Setting %s to %d", path, b); return b; case DM_CFG_STRING: b = _str_to_bool(v->v.str, fail); log_very_verbose("Setting %s to %d", path, b); return b; default: ; } } log_very_verbose("%s not found in config: defaulting to %d", path, fail); return fail; }
int dm_config_value_is_bool(const struct dm_config_value *v) { if (!v) return 0; switch(v->type) { case DM_CFG_INT: return 1; case DM_CFG_STRING: return _str_to_bool(v->v.str, -1) != -1; default: return 0; } }
static int _find_config_bool(const struct config_node *cn1, const struct config_node *cn2, const char *path, int fail) { const struct config_node *n = _find_first_config_node(cn1, cn2, path); const struct config_value *v; if (!n) return fail; v = n->v; switch (v->type) { case CFG_INT: return v->v.i ? 1 : 0; case CFG_STRING: return _str_to_bool(v->v.str, fail); } return fail; }
//---------------------------------------------------- _set_key_value_option --- static int _set_key_value_option(const char *key, const char *sval, const bool rtsetparams_called) { int type = -1; for (int j = 0; j < _num_params; j++) { if (strcasecmp(_param_list[j].arg, key) == 0) { type = _param_list[j].type; break; } } if (type == -1) return -1; if (sval == NULL) return die("set_option", "No value for \"%s\"", key); int status = 0; bool bval = false; int ival = 0; double dval = 0.0; switch (type) { // bool options case AUDIO: status = _str_to_bool(sval, bval); Option::audio(bval); break; case PLAY: status = _str_to_bool(sval, bval); Option::play(bval); break; case RECORD: status = _str_to_bool(sval, bval); Option::record(bval); #ifndef MAXMSP if (Option::record() && rtsetparams_called) return die("set_option", "Turn on record BEFORE calling rtsetparams."); #endif break; case CLOBBER: status = _str_to_bool(sval, bval); Option::clobber(bval); break; case PRINT: status = _str_to_int(sval, ival); Option::print(ival); break; case REPORT_CLIPPING: status = _str_to_bool(sval, bval); Option::reportClipping(bval); break; case CHECK_PEAKS: status = _str_to_bool(sval, bval); Option::checkPeaks(bval); break; case EXIT_ON_ERROR: status = _str_to_bool(sval, bval); Option::exitOnError(bval); break; case AUTO_LOAD: status = _str_to_bool(sval, bval); Option::autoLoad(bval); break; case FAST_UPDATE: status = _str_to_bool(sval, bval); Option::fastUpdate(bval); if (bval) rtcmix_warn("set_option", "With \"%s\" on, certain instruments run " "faster at the expense of reduced capabilities.\n", key); break; // number options case BUFFER_FRAMES: status = _str_to_int(sval, ival); if (status == 0) { if (ival <= 0) return die("set_option", "\"%s\" value must be > 0", key); Option::bufferFrames(ival); } break; case BUFFER_COUNT: status = _str_to_int(sval, ival); if (status == 0) { if (ival <= 0) return die("set_option", "\"%s\" value must be > 0", key); Option::bufferCount(ival); } break; case OSC_INPORT: status = _str_to_int(sval, ival); if (status == 0) { if (ival <= 0) return die("set_option", "\"%s\" value must be > 0", key); Option::oscInPort(ival); } break; // string options case DEVICE: Option::device(sval); break; case INDEVICE: Option::inDevice(sval); break; case OUTDEVICE: Option::outDevice(sval); break; case MIDI_INDEVICE: Option::midiInDevice(sval); break; case MIDI_OUTDEVICE: Option::midiOutDevice(sval); break; case OSC_HOST: Option::oscHost(sval); break; case DSOPATH: Option::dsoPath(sval); break; case RCNAME: Option::rcName(sval); break; default: break; } if (status == -1) return die("set_option", "Trouble parsing value \"%s\"", sval); return status; }