2 * Asterisk -- A telephony toolkit for Linux.
4 * Use /dev/dsp as a channel, and the console to command it :).
6 * The full-duplex "simulation" is pretty weak. This is generally a
7 * VERY BADLY WRITTEN DRIVER so please don't use it as a model for
10 * Copyright (C) 1999, Mark Spencer
12 * Mark Spencer <markster@linux-support.net>
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License
18 #include <asterisk/lock.h>
19 #include <asterisk/frame.h>
20 #include <asterisk/logger.h>
21 #include <asterisk/channel.h>
22 #include <asterisk/module.h>
23 #include <asterisk/channel_pvt.h>
24 #include <asterisk/options.h>
25 #include <asterisk/pbx.h>
26 #include <asterisk/config.h>
27 #include <asterisk/cli.h>
31 #include <sys/ioctl.h>
36 #include <linux/soundcard.h>
42 /* Which device to use */
43 #define DEV_DSP "/dev/dsp"
45 /* Lets use 160 sample frames, just like GSM. */
46 #define FRAME_SIZE 160
48 /* When you set the frame size, you have to come up with
49 the right buffer format as well. */
50 /* 5 64-byte frames = one frame */
51 #define BUFFER_FMT ((buffersize * 10) << 16) | (0x0006);
53 /* Don't switch between read/write modes faster than every 300 ms */
54 #define MIN_SWITCH_TIME 600
56 static struct timeval lasttime;
59 static int silencesuppression = 0;
60 static int silencethreshold = 1000;
63 static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
65 static char *type = "Console";
66 static char *desc = "OSS Console Channel Driver";
67 static char *tdesc = "OSS Console Channel Driver";
68 static char *config = "oss.conf";
70 static char context[AST_MAX_EXTENSION] = "default";
71 static char language[MAX_LANGUAGE] = "";
72 static char exten[AST_MAX_EXTENSION] = "s";
76 static short silence[FRAME_SIZE] = {0, };
87 static struct sound sounds[] = {
88 { AST_CONTROL_RINGING, ringtone, sizeof(ringtone)/2, 16000, 32000, 1 },
89 { AST_CONTROL_BUSY, busy, sizeof(busy)/2, 4000, 4000, 1 },
90 { AST_CONTROL_CONGESTION, busy, sizeof(busy)/2, 2000, 2000, 1 },
91 { AST_CONTROL_RING, ring10, sizeof(ring10)/2, 16000, 32000, 1 },
92 { AST_CONTROL_ANSWER, answer, sizeof(answer)/2, 2200, 0, 0 },
95 /* Sound command pipe */
98 static struct chan_oss_pvt {
99 /* We only have one OSS structure -- near sighted perhaps, but it
100 keeps this driver as simple as possible -- as it should be. */
101 struct ast_channel *owner;
102 char exten[AST_MAX_EXTENSION];
103 char context[AST_MAX_EXTENSION];
106 static int time_has_passed()
110 gettimeofday(&tv, NULL);
111 ms = (tv.tv_sec - lasttime.tv_sec) * 1000 +
112 (tv.tv_usec - lasttime.tv_usec) / 1000;
113 if (ms > MIN_SWITCH_TIME)
118 /* Number of buffers... Each is FRAMESIZE/8 ms long. For example
119 with 160 sample frames, and a buffer size of 3, we have a 60ms buffer,
124 #define MAX_BUFFER_SIZE 100
125 static int buffersize = 3;
127 static int full_duplex = 0;
129 /* Are we reading or writing (simulated full duplex) */
130 static int readmode = 1;
132 /* File descriptor for sound device */
133 static int sounddev = -1;
135 static int autoanswer = 1;
137 static int calc_loudness(short *frame)
141 for (x=0;x<FRAME_SIZE;x++) {
147 sum = sum/FRAME_SIZE;
151 static int cursound = -1;
152 static int sampsent = 0;
153 static int silencelen=0;
155 static int nosound=0;
157 static int send_sound(void)
159 short myframe[FRAME_SIZE];
160 int total = FRAME_SIZE;
167 res = ioctl(sounddev, SNDCTL_DSP_GETOSPACE ,&abi);
169 ast_log(LOG_WARNING, "Unable to read output space\n");
172 /* Calculate how many samples we can send, max */
173 if (total > (abi.fragments * abi.fragsize / 2))
174 total = abi.fragments * abi.fragsize / 2;
176 if (sampsent < sounds[cursound].samplen) {
180 if (amt > (sounds[cursound].datalen - offset))
181 amt = sounds[cursound].datalen - offset;
182 memcpy(myframe + myoff, sounds[cursound].data + offset, amt * 2);
187 if (offset >= sounds[cursound].datalen)
190 /* Set it up for silence */
191 if (sampsent >= sounds[cursound].samplen)
192 silencelen = sounds[cursound].silencelen;
195 if (silencelen > 0) {
199 if (sounds[cursound].repeat) {
210 res = write(sounddev, frame, res * 2);
218 static void *sound_thread(void *unused)
228 FD_SET(sndcmd[0], &rfds);
230 FD_SET(sounddev, &wfds);
234 res = select(max + 1, &rfds, &wfds, NULL, NULL);
236 ast_log(LOG_WARNING, "select failed: %s\n", strerror(errno));
239 if (FD_ISSET(sndcmd[0], &rfds)) {
240 read(sndcmd[0], &cursound, sizeof(cursound));
245 if (FD_ISSET(sounddev, &wfds))
247 ast_log(LOG_WARNING, "Failed to write sound\n");
254 static int silence_suppress(short *buf)
258 static int silentframes = 0;
259 static char silbuf[FRAME_SIZE * 2 * SILBUF];
260 static int silbufcnt=0;
261 if (!silencesuppression)
263 loudness = calc_loudness((short *)(buf));
265 ast_log(LOG_DEBUG, "loudness is %d\n", loudness);
266 if (loudness < silencethreshold) {
269 /* Keep track of the last few bits of silence so we can play
270 them as lead-in when the time is right */
271 if (silbufcnt >= SILBUF) {
272 /* Make way for more buffer */
273 memmove(silbuf, silbuf + FRAME_SIZE * 2, FRAME_SIZE * 2 * (SILBUF - 1));
276 memcpy(silbuf + FRAME_SIZE * 2 * silbufcnt, buf, FRAME_SIZE * 2);
277 if (silentframes > 10) {
278 /* We've had plenty of silence, so compress it now */
283 /* Write any buffered silence we have, it may have something
286 write(sounddev, silbuf, silbufcnt * FRAME_SIZE);
294 static int setformat(void)
296 int fmt, desired, res, fd = sounddev;
297 static int warnedalready = 0;
298 static int warnedalready2 = 0;
300 res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
302 ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");
305 res = ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
307 if (option_verbose > 1)
308 ast_verbose(VERBOSE_PREFIX_2 "Console is full duplex\n");
312 res = ioctl(fd, SNDCTL_DSP_STEREO, &fmt);
314 ast_log(LOG_WARNING, "Failed to set audio device to mono\n");
317 /* 8000 Hz desired */
320 res = ioctl(fd, SNDCTL_DSP_SPEED, &fmt);
322 ast_log(LOG_WARNING, "Failed to set audio device to mono\n");
325 if (fmt != desired) {
326 if (!warnedalready++)
327 ast_log(LOG_WARNING, "Requested %d Hz, got %d Hz -- sound may be choppy\n", desired, fmt);
331 res = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fmt);
333 if (!warnedalready2++)
334 ast_log(LOG_WARNING, "Unable to set fragment size -- sound may be choppy\n");
340 static int soundcard_setoutput(int force)
342 /* Make sure the soundcard is in output mode. */
344 if (full_duplex || (!readmode && !force))
347 if (force || time_has_passed()) {
348 ioctl(sounddev, SNDCTL_DSP_RESET);
349 /* Keep the same fd reserved by closing the sound device and copying stdin at the same
351 /* dup2(0, sound); */
353 fd = open(DEV_DSP, O_WRONLY |O_NONBLOCK);
355 ast_log(LOG_WARNING, "Unable to re-open DSP device: %s\n", strerror(errno));
358 /* dup2 will close the original and make fd be sound */
359 if (dup2(fd, sounddev) < 0) {
360 ast_log(LOG_WARNING, "dup2() failed: %s\n", strerror(errno));
371 static int soundcard_setinput(int force)
374 if (full_duplex || (readmode && !force))
377 if (force || time_has_passed()) {
378 ioctl(sounddev, SNDCTL_DSP_RESET);
380 /* dup2(0, sound); */
381 fd = open(DEV_DSP, O_RDONLY | O_NONBLOCK);
383 ast_log(LOG_WARNING, "Unable to re-open DSP device: %s\n", strerror(errno));
386 /* dup2 will close the original and make fd be sound */
387 if (dup2(fd, sounddev) < 0) {
388 ast_log(LOG_WARNING, "dup2() failed: %s\n", strerror(errno));
399 static int soundcard_init()
401 /* Assume it's full duplex for starters */
402 int fd = open(DEV_DSP, O_RDWR | O_NONBLOCK);
404 ast_log(LOG_WARNING, "Unable to open %s: %s\n", DEV_DSP, strerror(errno));
407 gettimeofday(&lasttime, NULL);
411 soundcard_setinput(1);
415 static int oss_digit(struct ast_channel *c, char digit)
417 ast_verbose( " << Console Received digit %c >> \n", digit);
421 static int oss_text(struct ast_channel *c, char *text)
423 ast_verbose( " << Console Received text %s >> \n", text);
427 static int oss_call(struct ast_channel *c, char *dest, int timeout)
430 struct ast_frame f = { 0, };
431 ast_verbose( " << Call placed to '%s' on console >> \n", dest);
433 ast_verbose( " << Auto-answered >> \n" );
434 f.frametype = AST_FRAME_CONTROL;
435 f.subclass = AST_CONTROL_ANSWER;
436 ast_queue_frame(c, &f, 0);
439 ast_verbose( " << Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
440 f.frametype = AST_FRAME_CONTROL;
441 f.subclass = AST_CONTROL_RINGING;
442 ast_queue_frame(c, &f, 0);
443 write(sndcmd[1], &res, sizeof(res));
448 static void answer_sound(void)
453 write(sndcmd[1], &res, sizeof(res));
457 static int oss_answer(struct ast_channel *c)
459 ast_verbose( " << Console call has been answered >> \n");
461 ast_setstate(c, AST_STATE_UP);
466 static int oss_hangup(struct ast_channel *c)
472 ast_verbose( " << Hangup on console >> \n");
473 ast_pthread_mutex_lock(&usecnt_lock);
475 ast_pthread_mutex_unlock(&usecnt_lock);
478 /* Assume auto-hangup too */
481 /* Make congestion noise */
483 write(sndcmd[1], &res, sizeof(res));
489 static int soundcard_writeframe(short *data)
491 /* Write an exactly FRAME_SIZE sized of frame */
492 static int bufcnt = 0;
493 static short buffer[FRAME_SIZE * MAX_BUFFER_SIZE * 5];
494 struct audio_buf_info info;
498 if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info)) {
500 ast_log(LOG_WARNING, "Error reading output space\n");
504 if ((info.fragments >= buffersize * 5) && (bufcnt == buffersize)) {
505 /* We've run out of stuff, buffer again */
508 if (bufcnt == buffersize) {
509 /* Write sample immediately */
510 res = write(fd, ((void *)data), FRAME_SIZE * 2);
512 /* Copy the data into our buffer */
513 res = FRAME_SIZE * 2;
514 memcpy(buffer + (bufcnt * FRAME_SIZE), data, FRAME_SIZE * 2);
516 if (bufcnt == buffersize) {
517 res = write(fd, ((void *)buffer), FRAME_SIZE * 2 * buffersize);
524 static int oss_write(struct ast_channel *chan, struct ast_frame *f)
527 static char sizbuf[8000];
528 static int sizpos = 0;
531 /* Immediately return if no sound is enabled */
534 /* Stop any currently playing sound */
537 /* If we're half duplex, we have to switch to read mode
538 to honor immediate needs if necessary */
539 res = soundcard_setinput(1);
541 ast_log(LOG_WARNING, "Unable to set device to input mode\n");
546 res = soundcard_setoutput(0);
548 ast_log(LOG_WARNING, "Unable to set output device\n");
550 } else if (res > 0) {
551 /* The device is still in read mode, and it's too soon to change it,
552 so just pretend we wrote it */
555 /* We have to digest the frame in 160-byte portions */
556 if (f->datalen > sizeof(sizbuf) - sizpos) {
557 ast_log(LOG_WARNING, "Frame too large\n");
560 memcpy(sizbuf + sizpos, f->data, f->datalen);
563 while(len - pos > FRAME_SIZE * 2) {
564 soundcard_writeframe((short *)(sizbuf + pos));
565 pos += FRAME_SIZE * 2;
568 memmove(sizbuf, sizbuf + pos, len - pos);
573 static struct ast_frame *oss_read(struct ast_channel *chan)
575 static struct ast_frame f;
576 static char buf[FRAME_SIZE * 2 + AST_FRIENDLY_OFFSET];
577 static int readpos = 0;
581 ast_log(LOG_DEBUG, "oss_read()\n");
584 f.frametype = AST_FRAME_NULL;
593 res = soundcard_setinput(0);
595 ast_log(LOG_WARNING, "Unable to set input mode\n");
599 /* Theoretically shouldn't happen, but anyway, return a NULL frame */
602 res = read(sounddev, buf + AST_FRIENDLY_OFFSET + readpos, FRAME_SIZE * 2 - readpos);
604 ast_log(LOG_WARNING, "Error reading from sound device (If you're running 'artsd' then kill it): %s\n", strerror(errno));
612 if (readpos >= FRAME_SIZE * 2) {
615 if (chan->_state != AST_STATE_UP) {
616 /* Don't transmit unless it's up */
619 f.frametype = AST_FRAME_VOICE;
620 f.subclass = AST_FORMAT_SLINEAR;
621 f.timelen = FRAME_SIZE / 8;
622 f.datalen = FRAME_SIZE * 2;
623 f.data = buf + AST_FRIENDLY_OFFSET;
624 f.offset = AST_FRIENDLY_OFFSET;
628 { static int fd = -1;
630 fd = open("output.raw", O_RDWR | O_TRUNC | O_CREAT);
631 write(fd, f.data, f.datalen);
638 static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
640 struct chan_oss_pvt *p = newchan->pvt->pvt;
645 static int oss_indicate(struct ast_channel *chan, int cond)
649 case AST_CONTROL_BUSY:
652 case AST_CONTROL_CONGESTION:
655 case AST_CONTROL_RINGING:
659 ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, chan->name);
663 write(sndcmd[1], &res, sizeof(res));
668 static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
670 struct ast_channel *tmp;
671 tmp = ast_channel_alloc(1);
673 snprintf(tmp->name, sizeof(tmp->name), "OSS/%s", DEV_DSP + 5);
675 tmp->fds[0] = sounddev;
676 tmp->nativeformats = AST_FORMAT_SLINEAR;
678 tmp->pvt->send_digit = oss_digit;
679 tmp->pvt->send_text = oss_text;
680 tmp->pvt->hangup = oss_hangup;
681 tmp->pvt->answer = oss_answer;
682 tmp->pvt->read = oss_read;
683 tmp->pvt->call = oss_call;
684 tmp->pvt->write = oss_write;
685 tmp->pvt->indicate = oss_indicate;
686 tmp->pvt->fixup = oss_fixup;
687 if (strlen(p->context))
688 strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
689 if (strlen(p->exten))
690 strncpy(tmp->exten, p->exten, sizeof(tmp->exten)-1);
691 if (strlen(language))
692 strncpy(tmp->language, language, sizeof(tmp->language)-1);
694 ast_setstate(tmp, state);
695 ast_pthread_mutex_lock(&usecnt_lock);
697 ast_pthread_mutex_unlock(&usecnt_lock);
698 ast_update_use_count();
699 if (state != AST_STATE_DOWN) {
700 if (ast_pbx_start(tmp)) {
701 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
710 static struct ast_channel *oss_request(char *type, int format, void *data)
712 int oldformat = format;
713 struct ast_channel *tmp;
714 format &= AST_FORMAT_SLINEAR;
716 ast_log(LOG_NOTICE, "Asked to get a channel of format '%d'\n", oldformat);
720 ast_log(LOG_NOTICE, "Already have a call on the OSS channel\n");
723 tmp= oss_new(&oss, AST_STATE_DOWN);
725 ast_log(LOG_WARNING, "Unable to create new OSS channel\n");
730 static int console_autoanswer(int fd, int argc, char *argv[])
732 if ((argc != 1) && (argc != 2))
733 return RESULT_SHOWUSAGE;
735 ast_cli(fd, "Auto answer is %s.\n", autoanswer ? "on" : "off");
736 return RESULT_SUCCESS;
738 if (!strcasecmp(argv[1], "on"))
740 else if (!strcasecmp(argv[1], "off"))
743 return RESULT_SHOWUSAGE;
745 return RESULT_SUCCESS;
748 static char *autoanswer_complete(char *line, char *word, int pos, int state)
751 #define MIN(a,b) ((a) < (b) ? (a) : (b))
755 if (strlen(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
758 if (strlen(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
759 return strdup("off");
766 static char autoanswer_usage[] =
767 "Usage: autoanswer [on|off]\n"
768 " Enables or disables autoanswer feature. If used without\n"
769 " argument, displays the current on/off status of autoanswer.\n"
770 " The default value of autoanswer is in 'oss.conf'.\n";
772 static int console_answer(int fd, int argc, char *argv[])
774 struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
776 return RESULT_SHOWUSAGE;
778 ast_cli(fd, "No one is calling us\n");
779 return RESULT_FAILURE;
783 ast_queue_frame(oss.owner, &f, 1);
785 return RESULT_SUCCESS;
788 static char sendtext_usage[] =
789 "Usage: send text <message>\n"
790 " Sends a text message for display on the remote terminal.\n";
792 static int console_sendtext(int fd, int argc, char *argv[])
796 struct ast_frame f = { 0, };
798 return RESULT_SHOWUSAGE;
800 ast_cli(fd, "No one is calling us\n");
801 return RESULT_FAILURE;
803 if (strlen(text2send))
804 ast_cli(fd, "Warning: message already waiting to be sent, overwriting\n");
805 strcpy(text2send, "");
806 while(tmparg <= argc) {
807 strncat(text2send, argv[tmparg++], sizeof(text2send) - strlen(text2send));
808 strncat(text2send, " ", sizeof(text2send) - strlen(text2send));
810 if (strlen(text2send)) {
811 f.frametype = AST_FRAME_TEXT;
814 f.datalen = strlen(text2send);
815 ast_queue_frame(oss.owner, &f, 1);
817 return RESULT_SUCCESS;
820 static char answer_usage[] =
822 " Answers an incoming call on the console (OSS) channel.\n";
824 static int console_hangup(int fd, int argc, char *argv[])
827 return RESULT_SHOWUSAGE;
829 if (!oss.owner && !hookstate) {
830 ast_cli(fd, "No call to hangup up\n");
831 return RESULT_FAILURE;
835 ast_queue_hangup(oss.owner, 1);
837 return RESULT_SUCCESS;
840 static char hangup_usage[] =
842 " Hangs up any call currently placed on the console.\n";
845 static int console_dial(int fd, int argc, char *argv[])
847 char tmp[256], *tmp2;
850 struct ast_frame f = { AST_FRAME_DTMF, 0 };
851 if ((argc != 1) && (argc != 2))
852 return RESULT_SHOWUSAGE;
855 for (x=0;x<strlen(argv[1]);x++) {
856 f.subclass = argv[1][x];
857 ast_queue_frame(oss.owner, &f, 1);
860 ast_cli(fd, "You're already in a call. You can use this only to dial digits until you hangup\n");
861 return RESULT_FAILURE;
863 return RESULT_SUCCESS;
868 strncpy(tmp, argv[1], sizeof(tmp)-1);
870 tmp2 = strtok(NULL, "@");
873 if (tmp2 && strlen(tmp2))
876 if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
877 strncpy(oss.exten, mye, sizeof(oss.exten)-1);
878 strncpy(oss.context, myc, sizeof(oss.context)-1);
880 oss_new(&oss, AST_STATE_RINGING);
882 ast_cli(fd, "No such extension '%s' in context '%s'\n", mye, myc);
883 return RESULT_SUCCESS;
886 static char dial_usage[] =
887 "Usage: dial [extension[@context]]\n"
888 " Dials a given extensison (";
890 static int console_transfer(int fd, int argc, char *argv[])
895 return RESULT_SHOWUSAGE;
896 if (oss.owner && oss.owner->bridge) {
897 strncpy(tmp, argv[1], sizeof(tmp) - 1);
898 context = strchr(tmp, '@');
903 context = oss.owner->context;
904 if (ast_exists_extension(oss.owner->bridge, context, tmp, 1, oss.owner->bridge->callerid)) {
905 ast_cli(fd, "Whee, transferring %s to %s@%s.\n",
906 oss.owner->bridge->name, tmp, context);
907 if (ast_async_goto(oss.owner->bridge, context, tmp, 1, 1))
908 ast_cli(fd, "Failed to transfer :(\n");
910 ast_cli(fd, "No such extension exists\n");
913 ast_cli(fd, "There is no call to transfer\n");
915 return RESULT_SUCCESS;
918 static char transfer_usage[] =
919 "Usage: transfer <extension>[@context]\n"
920 " Transfers the currently connected call to the given extension (and\n"
921 "context if specified)\n";
923 static struct ast_cli_entry myclis[] = {
924 { { "answer", NULL }, console_answer, "Answer an incoming console call", answer_usage },
925 { { "hangup", NULL }, console_hangup, "Hangup a call on the console", hangup_usage },
926 { { "dial", NULL }, console_dial, "Dial an extension on the console", dial_usage },
927 { { "transfer", NULL }, console_transfer, "Transfer a call to a different extension", transfer_usage },
928 { { "send text", NULL }, console_sendtext, "Send text to the remote device", sendtext_usage },
929 { { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete }
936 struct ast_config *cfg = ast_load(config);
937 struct ast_variable *v;
940 ast_log(LOG_ERROR, "Unable to create pipe\n");
943 res = soundcard_init();
945 if (option_verbose > 1) {
946 ast_verbose(VERBOSE_PREFIX_2 "No sound card detected -- console channel will be unavailable\n");
947 ast_verbose(VERBOSE_PREFIX_2 "Turn off OSS support by adding 'noload=chan_oss.so' in /etc/asterisk/modules.conf\n");
952 ast_log(LOG_WARNING, "XXX I don't work right with non-full duplex sound cards XXX\n");
953 res = ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR, oss_request);
955 ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", type);
958 for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
959 ast_cli_register(myclis + x);
961 v = ast_variable_browse(cfg, "general");
963 if (!strcasecmp(v->name, "autoanswer"))
964 autoanswer = ast_true(v->value);
965 else if (!strcasecmp(v->name, "silencesuppression"))
966 silencesuppression = ast_true(v->value);
967 else if (!strcasecmp(v->name, "silencethreshold"))
968 silencethreshold = atoi(v->value);
969 else if (!strcasecmp(v->name, "context"))
970 strncpy(context, v->value, sizeof(context)-1);
971 else if (!strcasecmp(v->name, "language"))
972 strncpy(language, v->value, sizeof(language)-1);
973 else if (!strcasecmp(v->name, "extension"))
974 strncpy(exten, v->value, sizeof(exten)-1);
979 pthread_create(&sthread, NULL, sound_thread, NULL);
988 for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
989 ast_cli_unregister(myclis + x);
996 ast_softhangup(oss.owner, AST_SOFTHANGUP_APPUNLOAD);
1010 ast_pthread_mutex_lock(&usecnt_lock);
1012 ast_pthread_mutex_unlock(&usecnt_lock);
1018 return ASTERISK_GPL_KEY;