Changeset 4848:0b3d312d4253 in roaraudio
- Timestamp:
- 04/08/11 19:53:31 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/roard.c
r4846 r4848 982 982 int ret; 983 983 int _alive; 984 char * _opts; 984 985 985 986 if ( drv != NULL ) … … 994 995 _alive = alive; // save global alive setting 995 996 996 ret = add_output(drvs[i], dev, opts, prim, count); 997 if ( opts == NULL ) { 998 _opts = NULL; 999 } else { 1000 _opts = roar_mm_strdup(opts); 1001 } 1002 1003 ret = add_output(drvs[i], dev, _opts, prim, count); 1004 1005 if ( _opts != NULL ) 1006 roar_mm_free(_opts); 1007 997 1008 if ( ret != -1 ) 998 1009 return ret; … … 1005 1016 } 1006 1017 #endif 1018 1019 #define _CKPARAM(n) if ( n (v == NULL) ) { \ 1020 ROAR_WARN("add_output(drv='%s', dev='%s', opts=..., prim=%i, count=%i): " \ 1021 "Parameter '%s' expects %s parameter.", \ 1022 drv, dev, prim, count, k, (n 1) ? "a" : "no"); \ 1023 error++; \ 1024 } else 1007 1025 1008 1026 int add_output (char * drv, char * dev, char * opts, int prim, int count) { … … 1092 1110 ROAR_DBG("add_output(*): opts: k='%s', v='%s'", k, v); 1093 1111 if ( strcmp(k, "rate") == 0 ) { 1094 s->info.rate = atoi(v); 1112 _CKPARAM() 1113 s->info.rate = atoi(v); 1095 1114 } else if ( strcmp(k, "channels") == 0 ) { 1096 s->info.channels = atoi(v); 1115 _CKPARAM() 1116 s->info.channels = atoi(v); 1097 1117 } else if ( strcmp(k, "bits") == 0 ) { 1098 s->info.bits = atoi(v); 1118 _CKPARAM() 1119 s->info.bits = atoi(v); 1099 1120 } else if ( strcmp(k, "codec") == 0 ) { 1100 if ( (s->info.codec = roar_str2codec(v)) == -1 ) { 1101 ROAR_ERR("add_output(*): unknown codec '%s'", v); 1102 error++; 1103 } 1121 _CKPARAM() 1122 if ( (s->info.codec = roar_str2codec(v)) == -1 ) { 1123 ROAR_ERR("add_output(*): unknown codec '%s'", v); 1124 error++; 1125 } 1104 1126 } else if ( strcmp(k, "q") == 0 ) { 1105 q = atof(v); 1127 _CKPARAM() 1128 q = atof(v); 1106 1129 } else if ( strcmp(k, "blocks") == 0 ) { 1107 blocks = atoi(v); 1130 _CKPARAM() 1131 blocks = atoi(v); 1108 1132 } else if ( strcmp(k, "blocksize") == 0 ) { 1109 blocksize = atoi(v); 1133 _CKPARAM() 1134 blocksize = atoi(v); 1110 1135 } else if ( strcmp(k, "mmap") == 0 ) { 1111 f_mmap = 1; 1136 _CKPARAM(!) 1137 f_mmap = 1; 1112 1138 } else if ( strcmp(k, "subsystem") == 0 ) { 1113 if ( !strcasecmp(v, "wave") || !strcasecmp(v, "waveform") ) { 1114 dir = ROAR_DIR_OUTPUT; 1139 _CKPARAM() { 1140 if ( !strcasecmp(v, "wave") || !strcasecmp(v, "waveform") ) { 1141 dir = ROAR_DIR_OUTPUT; 1115 1142 #ifndef ROAR_WITHOUT_DCOMP_MIDI 1116 } else if ( !strcasecmp(v, "midi") ) {1117 dir = ROAR_DIR_MIDI_OUT;1143 } else if ( !strcasecmp(v, "midi") ) { 1144 dir = ROAR_DIR_MIDI_OUT; 1118 1145 #endif 1119 1146 #ifndef ROAR_WITHOUT_DCOMP_LIGHT 1120 } else if ( !strcasecmp(v, "light") ) {1121 dir = ROAR_DIR_LIGHT_OUT;1147 } else if ( !strcasecmp(v, "light") ) { 1148 dir = ROAR_DIR_LIGHT_OUT; 1122 1149 #endif 1123 1150 #ifndef ROAR_WITHOUT_DCOMP_RAW 1124 } else if ( !strcasecmp(v, "raw") ) { 1125 dir = ROAR_DIR_RAW_OUT; 1126 #endif 1127 } else if ( !strcasecmp(v, "complex") ) { 1128 dir = ROAR_DIR_COMPLEX_OUT; 1129 } else { 1130 ROAR_ERR("add_output(*): unknown/unsupported subsystem '%s'", k); 1131 error++; 1151 } else if ( !strcasecmp(v, "raw") ) { 1152 dir = ROAR_DIR_RAW_OUT; 1153 #endif 1154 } else if ( !strcasecmp(v, "complex") ) { 1155 dir = ROAR_DIR_COMPLEX_OUT; 1156 } else { 1157 ROAR_ERR("add_output(*): unknown/unsupported subsystem '%s'", k); 1158 error++; 1159 } 1132 1160 } 1133 1161 // DMX: 1134 1162 } else if ( strcmp(k, "channel") == 0 ) { 1135 channel = atoi(v); 1136 if ( channel < 0 || channel > 65535 ) { 1137 ROAR_ERR("add_output(*): Invalide channel (not within 0..65535): %i", channel); 1138 channel = -1; 1139 error++; 1163 _CKPARAM() { 1164 channel = atoi(v); 1165 if ( channel < 0 || channel > 65535 ) { 1166 ROAR_ERR("add_output(*): Invalide channel (not within 0..65535): %i", channel); 1167 channel = -1; 1168 error++; 1169 } 1140 1170 } 1141 1171 } else if ( strcmp(k, "universe") == 0 ) { 1142 universe = atoi(v); 1143 if ( universe < 0 || universe > 255 ) { 1144 ROAR_ERR("add_output(*): Invalide universe (not within 0..255): %i", universe); 1145 universe = -1; 1146 error++; 1172 _CKPARAM() { 1173 universe = atoi(v); 1174 if ( universe < 0 || universe > 255 ) { 1175 ROAR_ERR("add_output(*): Invalide universe (not within 0..255): %i", universe); 1176 universe = -1; 1177 error++; 1178 } 1147 1179 } 1148 1180 1149 1181 } else if ( strcmp(k, "name") == 0 ) { 1150 if ( streams_set_name(stream, v) == -1 ) { 1151 ROAR_ERR("add_output(*): Can not set Stream name"); 1152 error++; 1182 _CKPARAM() { 1183 if ( streams_set_name(stream, v) == -1 ) { 1184 ROAR_ERR("add_output(*): Can not set Stream name"); 1185 error++; 1186 } 1153 1187 } 1154 1188 1155 1189 } else if ( strcmp(k, "meta") == 0 ) { 1156 streams_set_flag(stream, ROAR_FLAG_META); 1190 _CKPARAM(!) 1191 streams_set_flag(stream, ROAR_FLAG_META); 1157 1192 } else if ( strcmp(k, "sync") == 0 ) { 1158 sync = 1; 1193 _CKPARAM(!) 1194 sync = 1; 1159 1195 } else if ( strcmp(k, "primary") == 0 ) { 1160 prim = 1; 1196 _CKPARAM(!) 1197 prim = 1; 1161 1198 1162 1199 } else if ( strcmp(k, "cleanmeta") == 0 ) { 1163 streams_set_flag(stream, ROAR_FLAG_CLEANMETA); 1200 _CKPARAM(!) 1201 streams_set_flag(stream, ROAR_FLAG_CLEANMETA); 1164 1202 } else if ( strcmp(k, "autoconf") == 0 ) { 1165 streams_set_flag(stream, ROAR_FLAG_AUTOCONF); 1203 _CKPARAM(!) 1204 streams_set_flag(stream, ROAR_FLAG_AUTOCONF); 1166 1205 } else if ( strcmp(k, "recsource") == 0 ) { 1167 streams_set_flag(stream, ROAR_FLAG_RECSOURCE); 1206 _CKPARAM(!) 1207 streams_set_flag(stream, ROAR_FLAG_RECSOURCE); 1168 1208 } else if ( strcmp(k, "passmixer") == 0 ) { 1169 streams_set_flag(stream, ROAR_FLAG_PASSMIXER); 1209 _CKPARAM(!) 1210 streams_set_flag(stream, ROAR_FLAG_PASSMIXER); 1170 1211 } else if ( strcmp(k, "recsource") == 0 ) { 1171 streams_set_flag(stream, ROAR_FLAG_RECSOURCE); 1212 _CKPARAM(!) 1213 streams_set_flag(stream, ROAR_FLAG_RECSOURCE); 1172 1214 } else { 1173 1215 ROAR_ERR("add_output(*): unknown option '%s'", k); … … 2609 2651 #endif 2610 2652 2611 add_default_output(o_drv, o_dev, o_opts, o_prim, o_count); 2653 if ( add_default_output(o_drv, o_dev, o_opts, o_prim, o_count) == -1 ) { 2654 ROAR_ERR("Can not initialize default driver"); 2655 return 1; 2656 } 2612 2657 2613 2658 ROAR_INFO("Server config: rate=%i, bits=%i, chans=%i", ROAR_DBG_INFO_NOTICE, sa.rate, sa.bits, sa.channels);
Note: See TracChangeset
for help on using the changeset viewer.