#include <asterisk/lock.h>Go to the source code of this file.
Functions | |
| int | ast_set_indication_country (const char *country) |
| tone_zone * | ast_get_indication_zone (const char *country) |
| tone_zone_sound * | ast_get_indication_tone (const struct tone_zone *zone, const char *indication) |
| int | ast_register_indication_country (struct tone_zone *country) |
| int | ast_unregister_indication_country (const char *country) |
| int | ast_register_indication (struct tone_zone *zone, const char *indication, const char *tonelist) |
| int | ast_unregister_indication (struct tone_zone *zone, const char *indication) |
| int | ast_playtones_start (struct ast_channel *chan, int vol, const char *tonelist, int interruptible) |
| void | ast_playtones_stop (struct ast_channel *chan) |
Variables | |
| tone_zone * | tone_zones |
| ast_mutex_t | tzlock |
|
||||||||||||
|
Definition at line 289 of file indications.c. References ast_log(), ast_mutex_lock, ast_mutex_unlock, LOG_WARNING, tone_zone_sound::name, tone_zone_sound::next, tone_zone::tones, and tzlock. Referenced by ast_indicate(). 00290 {
00291 struct tone_zone_sound *ts;
00292
00293 /* we need some tonezone, pick the first */
00294 if (zone == NULL && current_tonezone)
00295 zone = current_tonezone; /* default country? */
00296 if (zone == NULL && tone_zones)
00297 zone = tone_zones; /* any country? */
00298 if (zone == NULL)
00299 return 0; /* not a single country insight */
00300
00301 if (ast_mutex_lock(&tzlock)) {
00302 ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
00303 return 0;
00304 }
00305 for (ts=zone->tones; ts; ts=ts->next) {
00306 if (strcasecmp(indication,ts->name)==0) {
00307 /* found indication! */
00308 ast_mutex_unlock(&tzlock);
00309 return ts;
00310 }
00311 }
00312 /* nothing found, sorry */
00313 ast_mutex_unlock(&tzlock);
00314 return 0;
00315 }
|
|
|
Definition at line 251 of file indications.c. References tone_zone::alias, ast_log(), ast_mutex_lock, ast_mutex_unlock, tone_zone::country, LOG_NOTICE, LOG_WARNING, tone_zone::next, and tzlock. Referenced by ast_set_indication_country(). 00252 {
00253 struct tone_zone *tz;
00254 int alias_loop = 0;
00255
00256 /* we need some tonezone, pick the first */
00257 if (country == NULL && current_tonezone)
00258 return current_tonezone; /* default country? */
00259 if (country == NULL && tone_zones)
00260 return tone_zones; /* any country? */
00261 if (country == NULL)
00262 return 0; /* not a single country insight */
00263
00264 if (ast_mutex_lock(&tzlock)) {
00265 ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
00266 return 0;
00267 }
00268 do {
00269 for (tz=tone_zones; tz; tz=tz->next) {
00270 if (strcasecmp(country,tz->country)==0) {
00271 /* tone_zone found */
00272 if (tz->alias && tz->alias[0]) {
00273 country = tz->alias;
00274 break;
00275 }
00276 ast_mutex_unlock(&tzlock);
00277 return tz;
00278 }
00279 }
00280 } while (++alias_loop<20 && tz);
00281 ast_mutex_unlock(&tzlock);
00282 if (alias_loop==20)
00283 ast_log(LOG_NOTICE,"Alias loop for '%s' forcefull broken\n",country);
00284 /* nothing found, sorry */
00285 return 0;
00286 }
|
|
||||||||||||||||||||
|
Definition at line 150 of file indications.c. References ast_activate_generator(), ast_log(), playtones_item::duration, free, playtones_item::freq1, playtones_item::freq2, playtones_def::interruptible, playtones_def::items, LOG_WARNING, playtones_item::modulate, ast_channel::name, playtones_def::nitems, realloc, playtones_def::reppos, s, and playtones_def::vol. Referenced by ast_indicate(). 00151 {
00152 char *s, *data = ast_strdupa(playlst); /* cute */
00153 struct playtones_def d = { vol, -1, 0, 1, NULL};
00154 char *stringp=NULL;
00155 char *separator;
00156 if (!data)
00157 return -1;
00158 if (vol < 1)
00159 d.vol = 8192;
00160
00161 d.interruptible = interruptible;
00162
00163 stringp=data;
00164 /* the stringp/data is not null here */
00165 /* check if the data is separated with '|' or with ',' by default */
00166 if (strchr(stringp,'|'))
00167 separator = "|";
00168 else
00169 separator = ",";
00170 s = strsep(&stringp,separator);
00171 while (s && *s) {
00172 int freq1, freq2, time, modulate=0;
00173
00174 if (s[0]=='!')
00175 s++;
00176 else if (d.reppos == -1)
00177 d.reppos = d.nitems;
00178 if (sscanf(s, "%d+%d/%d", &freq1, &freq2, &time) == 3) {
00179 /* f1+f2/time format */
00180 } else if (sscanf(s, "%d+%d", &freq1, &freq2) == 2) {
00181 /* f1+f2 format */
00182 time = 0;
00183 } else if (sscanf(s, "%d*%d/%d", &freq1, &freq2, &time) == 3) {
00184 /* f1*f2/time format */
00185 modulate = 1;
00186 } else if (sscanf(s, "%d*%d", &freq1, &freq2) == 2) {
00187 /* f1*f2 format */
00188 time = 0;
00189 modulate = 1;
00190 } else if (sscanf(s, "%d/%d", &freq1, &time) == 2) {
00191 /* f1/time format */
00192 freq2 = 0;
00193 } else if (sscanf(s, "%d", &freq1) == 1) {
00194 /* f1 format */
00195 freq2 = 0;
00196 time = 0;
00197 } else {
00198 ast_log(LOG_WARNING,"%s: tone component '%s' of '%s' is no good\n",chan->name,s,playlst);
00199 return -1;
00200 }
00201
00202 d.items = realloc(d.items,(d.nitems+1)*sizeof(struct playtones_item));
00203 if (d.items == NULL)
00204 return -1;
00205 d.items[d.nitems].freq1 = freq1;
00206 d.items[d.nitems].freq2 = freq2;
00207 d.items[d.nitems].duration = time;
00208 d.items[d.nitems].modulate = modulate;
00209 d.nitems++;
00210
00211 s = strsep(&stringp,separator);
00212 }
00213
00214 if (ast_activate_generator(chan, &playtones, &d)) {
00215 free(d.items);
00216 return -1;
00217 }
00218 return 0;
00219 }
|
|
|
Stop the tones from playing Definition at line 221 of file indications.c. References ast_deactivate_generator(). Referenced by ast_indicate(). 00222 {
00223 ast_deactivate_generator(chan);
00224 }
|
|
||||||||||||||||
|
Definition at line 420 of file indications.c. References tone_zone::alias, ast_log(), ast_mutex_lock, ast_mutex_unlock, tone_zone_sound::data, free, LOG_WARNING, malloc, tone_zone_sound::name, tone_zone_sound::next, strdup, tone_zone::tones, and tzlock. 00421 {
00422 struct tone_zone_sound *ts,*ps;
00423
00424 /* is it an alias? stop */
00425 if (zone->alias[0])
00426 return -1;
00427
00428 if (ast_mutex_lock(&tzlock)) {
00429 ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
00430 return -2;
00431 }
00432 for (ps=NULL,ts=zone->tones; ts; ps=ts,ts=ts->next) {
00433 if (strcasecmp(indication,ts->name)==0) {
00434 /* indication already there, replace */
00435 free((void*)ts->name);
00436 free((void*)ts->data);
00437 break;
00438 }
00439 }
00440 if (!ts) {
00441 /* not there, we have to add */
00442 ts = malloc(sizeof(struct tone_zone_sound));
00443 if (!ts) {
00444 ast_log(LOG_WARNING, "Out of memory\n");
00445 ast_mutex_unlock(&tzlock);
00446 return -2;
00447 }
00448 ts->next = NULL;
00449 }
00450 ts->name = strdup(indication);
00451 ts->data = strdup(tonelist);
00452 if (ts->name==NULL || ts->data==NULL) {
00453 ast_log(LOG_WARNING, "Out of memory\n");
00454 ast_mutex_unlock(&tzlock);
00455 return -2;
00456 }
00457 if (ps)
00458 ps->next = ts;
00459 else
00460 zone->tones = ts;
00461 ast_mutex_unlock(&tzlock);
00462 return 0;
00463 }
|
|
|
Definition at line 335 of file indications.c. References ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verbose(), tone_zone::country, LOG_WARNING, tone_zone::next, option_verbose, tzlock, and VERBOSE_PREFIX_3. 00336 {
00337 struct tone_zone *tz,*pz;
00338
00339 if (ast_mutex_lock(&tzlock)) {
00340 ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
00341 return -1;
00342 }
00343 for (pz=NULL,tz=tone_zones; tz; pz=tz,tz=tz->next) {
00344 if (strcasecmp(zone->country,tz->country)==0) {
00345 /* tone_zone already there, replace */
00346 zone->next = tz->next;
00347 if (pz)
00348 pz->next = zone;
00349 else
00350 tone_zones = zone;
00351 /* if we are replacing the default zone, re-point it */
00352 if (tz == current_tonezone)
00353 current_tonezone = zone;
00354 /* now free the previous zone */
00355 free_zone(tz);
00356 ast_mutex_unlock(&tzlock);
00357 return 0;
00358 }
00359 }
00360 /* country not there, add */
00361 zone->next = NULL;
00362 if (pz)
00363 pz->next = zone;
00364 else
00365 tone_zones = zone;
00366 ast_mutex_unlock(&tzlock);
00367
00368 if (option_verbose > 2)
00369 ast_verbose(VERBOSE_PREFIX_3 "Registered indication country '%s'\n",zone->country);
00370 return 0;
00371 }
|
|
|
Definition at line 236 of file indications.c. References ast_get_indication_zone(), ast_verbose(), option_verbose, and VERBOSE_PREFIX_3. 00237 {
00238 if (country) {
00239 struct tone_zone *z = ast_get_indication_zone(country);
00240 if (z) {
00241 if (option_verbose > 2)
00242 ast_verbose(VERBOSE_PREFIX_3 "Setting default indication country to '%s'\n",country);
00243 current_tonezone = z;
00244 return 0;
00245 }
00246 }
00247 return 1; /* not found */
00248 }
|
|
||||||||||||
|
Definition at line 466 of file indications.c. References tone_zone::alias, ast_log(), ast_mutex_lock, ast_mutex_unlock, tone_zone_sound::data, free, LOG_WARNING, tone_zone_sound::name, tone_zone_sound::next, tone_zone::tones, and tzlock. 00467 {
00468 struct tone_zone_sound *ts,*ps = NULL, *tmp;
00469 int res = -1;
00470
00471 /* is it an alias? stop */
00472 if (zone->alias[0])
00473 return -1;
00474
00475 if (ast_mutex_lock(&tzlock)) {
00476 ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
00477 return -1;
00478 }
00479 ts = zone->tones;
00480 while (ts) {
00481 if (strcasecmp(indication,ts->name)==0) {
00482 /* indication found */
00483 tmp = ts->next;
00484 if (ps)
00485 ps->next = tmp;
00486 else
00487 zone->tones = tmp;
00488 free((void*)ts->name);
00489 free((void*)ts->data);
00490 free(ts);
00491 ts = tmp;
00492 res = 0;
00493 }
00494 else {
00495 /* next zone please */
00496 ps = ts;
00497 ts = ts->next;
00498 }
00499 }
00500 /* indication not found, goodbye */
00501 ast_mutex_unlock(&tzlock);
00502 return res;
00503 }
|
|
|
Definition at line 375 of file indications.c. References tone_zone::alias, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verbose(), tone_zone::country, LOG_NOTICE, LOG_WARNING, tone_zone::next, option_verbose, tzlock, and VERBOSE_PREFIX_3. 00376 {
00377 struct tone_zone *tz, *pz = NULL, *tmp;
00378 int res = -1;
00379
00380 if (ast_mutex_lock(&tzlock)) {
00381 ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
00382 return -1;
00383 }
00384 tz = tone_zones;
00385 while (tz) {
00386 if (country==NULL ||
00387 (strcasecmp(country, tz->country)==0 ||
00388 strcasecmp(country, tz->alias)==0)) {
00389 /* tone_zone found, remove */
00390 tmp = tz->next;
00391 if (pz)
00392 pz->next = tmp;
00393 else
00394 tone_zones = tmp;
00395 /* if we are unregistering the default country, w'll notice */
00396 if (tz == current_tonezone) {
00397 ast_log(LOG_NOTICE,"Removed default indication country '%s'\n",tz->country);
00398 current_tonezone = NULL;
00399 }
00400 if (option_verbose > 2)
00401 ast_verbose(VERBOSE_PREFIX_3 "Unregistered indication country '%s'\n",tz->country);
00402 free_zone(tz);
00403 if (tone_zones == tz)
00404 tone_zones = tmp;
00405 tz = tmp;
00406 res = 0;
00407 }
00408 else {
00409 /* next zone please */
00410 pz = tz;
00411 tz = tz->next;
00412 }
00413 }
00414 ast_mutex_unlock(&tzlock);
00415 return res;
00416 }
|
|
|
Definition at line 228 of file indications.c. |
|
|
Referenced by ast_get_indication_tone(), ast_get_indication_zone(), ast_register_indication(), ast_register_indication_country(), ast_unregister_indication(), and ast_unregister_indication_country(). |
1.4.2