Sat Nov 1 06:28:55 2008

Asterisk developer's documentation


chan_oss.c File Reference

Channel driver for OSS sound cards. More...

#include "asterisk.h"
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/time.h>
#include <stdlib.h>
#include <errno.h>
#include <soundcard.h>
#include "asterisk/lock.h"
#include "asterisk/frame.h"
#include "asterisk/logger.h"
#include "asterisk/callerid.h"
#include "asterisk/channel.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/musiconhold.h"
#include "busy.h"
#include "ringtone.h"
#include "ring10.h"
#include "answer.h"

Include dependency graph for chan_oss.c:

Go to the source code of this file.

Data Structures

struct  chan_oss_pvt
struct  sound

Defines

#define BOOST_MAX   40
#define BOOST_SCALE   (1<<9)
#define DEV_DSP   "/dev/dsp"
#define FRAGS   ( ( (6 * 5) << 16 ) | 0x6 )
#define FRAME_SIZE   160
#define M_BOOL(tag, dst)   M_F(tag, (dst) = ast_true(__val) )
#define M_END(x)   x;
#define M_F(tag, f)   if (!strcasecmp((__s), tag)) { f; } else
#define M_START(var, val)   char *__s = var; char *__val = val;
#define M_STR(tag, dst)   M_F(tag, ast_copy_string(dst, __val, sizeof(dst)))
#define M_UINT(tag, dst)   M_F(tag, (dst) = strtoul(__val, NULL, 0) )
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
#define O_CLOSE   0x444
#define QUEUE_SIZE   10
#define TEXT_SIZE   256
#define WARN_frag   4
#define WARN_speed   2
#define WARN_used_blocks   1

Functions

static int __console_mute_unmute (int mute)
static char * ast_ext_ctx (const char *src, char **ext, char **ctx)
 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"OSS Console Channel Driver")
static char * autoanswer_complete (const char *line, const char *word, int pos, int state)
static char * autoanswer_complete_deprecated (const char *line, const char *word, int pos, int state)
static int console_active (int fd, int argc, char *argv[])
static int console_active_deprecated (int fd, int argc, char *argv[])
static int console_answer (int fd, int argc, char *argv[])
static int console_answer_deprecated (int fd, int argc, char *argv[])
static int console_autoanswer (int fd, int argc, char *argv[])
static int console_autoanswer_deprecated (int fd, int argc, char *argv[])
static int console_dial (int fd, int argc, char *argv[])
static int console_dial_deprecated (int fd, int argc, char *argv[])
static int console_flash (int fd, int argc, char *argv[])
static int console_flash_deprecated (int fd, int argc, char *argv[])
static int console_hangup (int fd, int argc, char *argv[])
static int console_hangup_deprecated (int fd, int argc, char *argv[])
static int console_mute (int fd, int argc, char *argv[])
static int console_mute_deprecated (int fd, int argc, char *argv[])
static int console_sendtext (int fd, int argc, char *argv[])
static int console_sendtext_deprecated (int fd, int argc, char *argv[])
static int console_transfer (int fd, int argc, char *argv[])
static int console_transfer_deprecated (int fd, int argc, char *argv[])
static int console_unmute (int fd, int argc, char *argv[])
static int console_unmute_deprecated (int fd, int argc, char *argv[])
static int do_boost (int fd, int argc, char *argv[])
static struct chan_oss_pvtfind_desc (char *dev)
static int load_module (void)
static int oss_answer (struct ast_channel *c)
static int oss_call (struct ast_channel *c, char *dest, int timeout)
static int oss_digit_begin (struct ast_channel *c, char digit)
static int oss_digit_end (struct ast_channel *c, char digit, unsigned int duration)
static int oss_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
static int oss_hangup (struct ast_channel *c)
static int oss_indicate (struct ast_channel *chan, int cond, const void *data, size_t datalen)
static struct ast_channeloss_new (struct chan_oss_pvt *o, char *ext, char *ctx, int state)
static struct ast_frameoss_read (struct ast_channel *chan)
static struct ast_channeloss_request (const char *type, int format, void *data, int *cause)
static int oss_text (struct ast_channel *c, const char *text)
static int oss_write (struct ast_channel *chan, struct ast_frame *f)
static void ring (struct chan_oss_pvt *o, int x)
static void send_sound (struct chan_oss_pvt *o)
static int setformat (struct chan_oss_pvt *o, int mode)
static void * sound_thread (void *arg)
static int soundcard_writeframe (struct chan_oss_pvt *o, short *data)
static void store_boost (struct chan_oss_pvt *o, char *s)
static void store_callerid (struct chan_oss_pvt *o, char *s)
static struct chan_oss_pvtstore_config (struct ast_config *cfg, char *ctg)
static void store_mixer (struct chan_oss_pvt *o, char *s)
static int unload_module (void)
static int used_blocks (struct chan_oss_pvt *o)

Variables

static char active_usage []
static char answer_usage []
static char autoanswer_usage []
static struct ast_cli_entry cli_oss []
static struct ast_cli_entry cli_oss_active_deprecated
static struct ast_cli_entry cli_oss_answer_deprecated
static struct ast_cli_entry cli_oss_autoanswer_deprecated
static struct ast_cli_entry cli_oss_boost_deprecated
static struct ast_cli_entry cli_oss_dial_deprecated
static struct ast_cli_entry cli_oss_flash_deprecated
static struct ast_cli_entry cli_oss_hangup_deprecated
static struct ast_cli_entry cli_oss_mute_deprecated
static struct ast_cli_entry cli_oss_send_text_deprecated
static struct ast_cli_entry cli_oss_transfer_deprecated
static struct ast_cli_entry cli_oss_unmute_deprecated
static char * config = "oss.conf"
static struct ast_jb_conf default_jbconf
static char dial_usage []
static char flash_usage []
static struct ast_jb_conf global_jbconf
static char hangup_usage []
static char mute_usage []
static char * oss_active
static int oss_debug
static struct chan_oss_pvt oss_default
static struct ast_channel_tech oss_tech
static char sendtext_usage []
static struct sound sounds []
static char tdesc [] = "OSS Console Channel Driver"
static char transfer_usage []
static char unmute_usage []


Detailed Description

Channel driver for OSS sound cards.

Author:
Mark Spencer <markster@digium.com>

Luigi Rizzo

See also

Definition in file chan_oss.c.


Define Documentation

#define BOOST_MAX   40

Definition at line 360 of file chan_oss.c.

Referenced by store_boost().

#define BOOST_SCALE   (1<<9)

Definition at line 359 of file chan_oss.c.

Referenced by do_boost(), oss_read(), and store_boost().

#define DEV_DSP   "/dev/dsp"

Definition at line 274 of file chan_oss.c.

Referenced by store_config().

#define FRAGS   ( ( (6 * 5) << 16 ) | 0x6 )

Definition at line 257 of file chan_oss.c.

#define FRAME_SIZE   160

Definition at line 251 of file chan_oss.c.

#define M_BOOL ( tag,
dst   )     M_F(tag, (dst) = ast_true(__val) )

Definition at line 217 of file chan_oss.c.

Referenced by store_config().

#define M_END (  )     x;

Definition at line 215 of file chan_oss.c.

Referenced by store_config().

#define M_F ( tag,
f   )     if (!strcasecmp((__s), tag)) { f; } else

Definition at line 216 of file chan_oss.c.

Referenced by store_config().

#define M_START ( var,
val   )     char *__s = var; char *__val = val;

Definition at line 213 of file chan_oss.c.

Referenced by store_config().

#define M_STR ( tag,
dst   )     M_F(tag, ast_copy_string(dst, __val, sizeof(dst)))

Definition at line 219 of file chan_oss.c.

Referenced by store_config().

#define M_UINT ( tag,
dst   )     M_F(tag, (dst) = strtoul(__val, NULL, 0) )

Definition at line 218 of file chan_oss.c.

Referenced by store_config().

#define MAX ( a,
 )     ((a) > (b) ? (a) : (b))

Definition at line 281 of file chan_oss.c.

#define MIN ( a,
 )     ((a) < (b) ? (a) : (b))

Definition at line 278 of file chan_oss.c.

#define O_CLOSE   0x444

Definition at line 269 of file chan_oss.c.

Referenced by console_hangup(), console_hangup_deprecated(), oss_hangup(), setformat(), and sound_thread().

#define QUEUE_SIZE   10

Definition at line 252 of file chan_oss.c.

#define TEXT_SIZE   256

Definition at line 264 of file chan_oss.c.

Referenced by console_sendtext(), and console_sendtext_deprecated().

#define WARN_frag   4

Definition at line 349 of file chan_oss.c.

Referenced by setformat().

#define WARN_speed   2

Definition at line 348 of file chan_oss.c.

Referenced by setformat().

#define WARN_used_blocks   1

Definition at line 347 of file chan_oss.c.

Referenced by used_blocks().


Function Documentation

static int __console_mute_unmute ( int  mute  )  [static]

Definition at line 1406 of file chan_oss.c.

References find_desc(), chan_oss_pvt::mute, oss_active, and RESULT_SUCCESS.

Referenced by console_mute(), console_mute_deprecated(), console_unmute(), and console_unmute_deprecated().

01407 {
01408    struct chan_oss_pvt *o = find_desc(oss_active);
01409    
01410    o->mute = mute;
01411    return RESULT_SUCCESS;
01412 }

static char* ast_ext_ctx ( const char *  src,
char **  ext,
char **  ctx 
) [static]

Definition at line 462 of file chan_oss.c.

References ast_strdup, find_desc(), and chan_oss_pvt::overridecontext.

Referenced by console_dial(), console_dial_deprecated(), console_transfer(), and console_transfer_deprecated().

00463 {
00464    struct chan_oss_pvt *o = find_desc(oss_active);
00465 
00466    if (ext == NULL || ctx == NULL)
00467       return NULL;         /* error */
00468 
00469    *ext = *ctx = NULL;
00470 
00471    if (src && *src != '\0')
00472       *ext = ast_strdup(src);
00473 
00474    if (*ext == NULL)
00475       return NULL;
00476 
00477    if (!o->overridecontext) {
00478       /* parse from the right */
00479       *ctx = strrchr(*ext, '@');
00480       if (*ctx)
00481          *(*ctx)++ = '\0';
00482    }
00483 
00484    return *ext;
00485 }

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"OSS Console Channel Driver"   
)

static char* autoanswer_complete ( const char *  line,
const char *  word,
int  pos,
int  state 
) [static]

Definition at line 1114 of file chan_oss.c.

References ast_cli_complete().

01115 {
01116    static char *choices[] = { "on", "off", NULL };
01117 
01118    return (pos != 3) ? NULL : ast_cli_complete(word, choices, state);
01119 }

static char* autoanswer_complete_deprecated ( const char *  line,
const char *  word,
int  pos,
int  state 
) [static]

Definition at line 1107 of file chan_oss.c.

References ast_cli_complete().

01108 {
01109    static char *choices[] = { "on", "off", NULL };
01110 
01111    return (pos != 2) ? NULL : ast_cli_complete(word, choices, state);
01112 }

static int console_active ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1540 of file chan_oss.c.

References ast_cli(), find_desc(), chan_oss_pvt::name, chan_oss_pvt::next, oss_active, oss_default, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

01541 {
01542    if (argc == 2)
01543       ast_cli(fd, "active console is [%s]\n", oss_active);
01544    else if (argc != 3)
01545       return RESULT_SHOWUSAGE;
01546    else {
01547       struct chan_oss_pvt *o;
01548       if (strcmp(argv[2], "show") == 0) {
01549          for (o = oss_default.next; o; o = o->next)
01550             ast_cli(fd, "device [%s] exists\n", o->name);
01551          return RESULT_SUCCESS;
01552       }
01553       o = find_desc(argv[2]);
01554       if (o == NULL)
01555          ast_cli(fd, "No device [%s] exists\n", argv[2]);
01556       else
01557          oss_active = o->name;
01558    }
01559    return RESULT_SUCCESS;
01560 }

static int console_active_deprecated ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1518 of file chan_oss.c.

References ast_cli(), find_desc(), chan_oss_pvt::name, chan_oss_pvt::next, oss_active, oss_default, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

01519 {
01520    if (argc == 1)
01521       ast_cli(fd, "active console is [%s]\n", oss_active);
01522    else if (argc != 2)
01523       return RESULT_SHOWUSAGE;
01524    else {
01525       struct chan_oss_pvt *o;
01526       if (strcmp(argv[1], "show") == 0) {
01527          for (o = oss_default.next; o; o = o->next)
01528             ast_cli(fd, "device [%s] exists\n", o->name);
01529          return RESULT_SUCCESS;
01530       }
01531       o = find_desc(argv[1]);
01532       if (o == NULL)
01533          ast_cli(fd, "No device [%s] exists\n", argv[1]);
01534       else
01535          oss_active = o->name;
01536    }
01537    return RESULT_SUCCESS;
01538 }

static int console_answer ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1152 of file chan_oss.c.

References ast_cli(), AST_CONTROL_ANSWER, AST_FRAME_CONTROL, ast_queue_frame(), chan_oss_pvt::cursound, f, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::nosound, oss_active, chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, and ring().

01153 {
01154    struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
01155    struct chan_oss_pvt *o = find_desc(oss_active);
01156 
01157    if (argc != 2)
01158       return RESULT_SHOWUSAGE;
01159    if (!o->owner) {
01160       ast_cli(fd, "No one is calling us\n");
01161       return RESULT_FAILURE;
01162    }
01163    o->hookstate = 1;
01164    o->cursound = -1;
01165    o->nosound = 0;
01166    ast_queue_frame(o->owner, &f);
01167 #if 0
01168    /* XXX do we really need it ? considering we shut down immediately... */
01169    ring(o, AST_CONTROL_ANSWER);
01170 #endif
01171    return RESULT_SUCCESS;
01172 }

static int console_answer_deprecated ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1130 of file chan_oss.c.

References ast_cli(), AST_CONTROL_ANSWER, AST_FRAME_CONTROL, ast_queue_frame(), chan_oss_pvt::cursound, f, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::nosound, oss_active, chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, and ring().

01131 {
01132    struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
01133    struct chan_oss_pvt *o = find_desc(oss_active);
01134 
01135    if (argc != 1)
01136       return RESULT_SHOWUSAGE;
01137    if (!o->owner) {
01138       ast_cli(fd, "No one is calling us\n");
01139       return RESULT_FAILURE;
01140    }
01141    o->hookstate = 1;
01142    o->cursound = -1;
01143    o->nosound = 0;
01144    ast_queue_frame(o->owner, &f);
01145 #if 0
01146    /* XXX do we really need it ? considering we shut down immediately... */
01147    ring(o, AST_CONTROL_ANSWER);
01148 #endif
01149    return RESULT_SUCCESS;
01150 }

static int console_autoanswer ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1083 of file chan_oss.c.

References ast_cli(), ast_log(), chan_oss_pvt::autoanswer, find_desc(), LOG_WARNING, oss_active, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

01084 {
01085    struct chan_oss_pvt *o = find_desc(oss_active);
01086 
01087    if (argc == 2) {
01088       ast_cli(fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
01089       return RESULT_SUCCESS;
01090    }
01091    if (argc != 3)
01092       return RESULT_SHOWUSAGE;
01093    if (o == NULL) {
01094       ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
01095           oss_active);
01096       return RESULT_FAILURE;
01097    }
01098    if (!strcasecmp(argv[2], "on"))
01099       o->autoanswer = -1;
01100    else if (!strcasecmp(argv[2], "off"))
01101       o->autoanswer = 0;
01102    else
01103       return RESULT_SHOWUSAGE;
01104    return RESULT_SUCCESS;
01105 }

static int console_autoanswer_deprecated ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1060 of file chan_oss.c.

References ast_cli(), ast_log(), chan_oss_pvt::autoanswer, find_desc(), LOG_WARNING, oss_active, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

01061 {
01062    struct chan_oss_pvt *o = find_desc(oss_active);
01063 
01064    if (argc == 1) {
01065       ast_cli(fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
01066       return RESULT_SUCCESS;
01067    }
01068    if (argc != 2)
01069       return RESULT_SHOWUSAGE;
01070    if (o == NULL) {
01071       ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n", oss_active);
01072       return RESULT_FAILURE;
01073    }
01074    if (!strcasecmp(argv[1], "on"))
01075       o->autoanswer = -1;
01076    else if (!strcasecmp(argv[1], "off"))
01077       o->autoanswer = 0;
01078    else
01079       return RESULT_SHOWUSAGE;
01080    return RESULT_SUCCESS;
01081 }

static int console_dial ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1361 of file chan_oss.c.

References ast_cli(), ast_exists_extension(), ast_ext_ctx(), AST_FRAME_DTMF, ast_queue_frame(), AST_STATE_RINGING, chan_oss_pvt::ctx, chan_oss_pvt::ext, f, find_desc(), free, chan_oss_pvt::hookstate, oss_active, oss_new(), chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, and s.

01362 {
01363    char *s = NULL, *mye = NULL, *myc = NULL;
01364    struct chan_oss_pvt *o = find_desc(oss_active);
01365 
01366    if (argc != 2 && argc != 3)
01367       return RESULT_SHOWUSAGE;
01368    if (o->owner) {   /* already in a call */
01369       int i;
01370       struct ast_frame f = { AST_FRAME_DTMF, 0 };
01371 
01372       if (argc == 2) {  /* argument is mandatory here */
01373          ast_cli(fd, "Already in a call. You can only dial digits until you hangup.\n");
01374          return RESULT_FAILURE;
01375       }
01376       s = argv[2];
01377       /* send the string one char at a time */
01378       for (i = 0; i < strlen(s); i++) {
01379          f.subclass = s[i];
01380          ast_queue_frame(o->owner, &f);
01381       }
01382       return RESULT_SUCCESS;
01383    }
01384    /* if we have an argument split it into extension and context */
01385    if (argc == 3)
01386       s = ast_ext_ctx(argv[2], &mye, &myc);
01387    /* supply default values if needed */
01388    if (mye == NULL)
01389       mye = o->ext;
01390    if (myc == NULL)
01391       myc = o->ctx;
01392    if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
01393       o->hookstate = 1;
01394       oss_new(o, mye, myc, AST_STATE_RINGING);
01395    } else
01396       ast_cli(fd, "No such extension '%s' in context '%s'\n", mye, myc);
01397    if (s)
01398       free(s);
01399    return RESULT_SUCCESS;
01400 }

static int console_dial_deprecated ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1320 of file chan_oss.c.

References ast_cli(), ast_exists_extension(), ast_ext_ctx(), AST_FRAME_DTMF, ast_queue_frame(), AST_STATE_RINGING, chan_oss_pvt::ctx, chan_oss_pvt::ext, f, find_desc(), free, chan_oss_pvt::hookstate, oss_active, oss_new(), chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, and s.

01321 {
01322    char *s = NULL, *mye = NULL, *myc = NULL;
01323    struct chan_oss_pvt *o = find_desc(oss_active);
01324 
01325    if (argc != 1 && argc != 2)
01326       return RESULT_SHOWUSAGE;
01327    if (o->owner) { /* already in a call */
01328       int i;
01329       struct ast_frame f = { AST_FRAME_DTMF, 0 };
01330 
01331       if (argc == 1) { /* argument is mandatory here */
01332          ast_cli(fd, "Already in a call. You can only dial digits until you hangup.\n");
01333          return RESULT_FAILURE;
01334       }
01335       s = argv[1];
01336       /* send the string one char at a time */
01337       for (i = 0; i < strlen(s); i++) {
01338          f.subclass = s[i];
01339          ast_queue_frame(o->owner, &f);
01340       }
01341       return RESULT_SUCCESS;
01342    }
01343    /* if we have an argument split it into extension and context */
01344    if (argc == 2)
01345       s = ast_ext_ctx(argv[1], &mye, &myc);
01346    /* supply default values if needed */
01347    if (mye == NULL)
01348       mye = o->ext;
01349    if (myc == NULL)
01350       myc = o->ctx;
01351    if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
01352       o->hookstate = 1;
01353       oss_new(o, mye, myc, AST_STATE_RINGING);
01354    } else
01355       ast_cli(fd, "No such extension '%s' in context '%s'\n", mye, myc);
01356    if (s)
01357       free(s);
01358    return RESULT_SUCCESS;
01359 }

static int console_flash ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1297 of file chan_oss.c.

References ast_cli(), AST_CONTROL_FLASH, AST_FRAME_CONTROL, ast_queue_frame(), chan_oss_pvt::cursound, f, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::nosound, oss_active, chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

01298 {
01299    struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
01300    struct chan_oss_pvt *o = find_desc(oss_active);
01301 
01302    if (argc != 2)
01303       return RESULT_SHOWUSAGE;
01304    o->cursound = -1;
01305    o->nosound = 0;            /* when cursound is -1 nosound must be 0 */
01306    if (!o->owner) {        /* XXX maybe !o->hookstate too ? */
01307       ast_cli(fd, "No call to flash\n");
01308       return RESULT_FAILURE;
01309    }
01310    o->hookstate = 0;
01311    if (o->owner)           /* XXX must be true, right ? */
01312       ast_queue_frame(o->owner, &f);
01313    return RESULT_SUCCESS;
01314 }

static int console_flash_deprecated ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1278 of file chan_oss.c.

References ast_cli(), AST_CONTROL_FLASH, AST_FRAME_CONTROL, ast_queue_frame(), chan_oss_pvt::cursound, f, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::nosound, oss_active, chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

01279 {
01280    struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
01281    struct chan_oss_pvt *o = find_desc(oss_active);
01282 
01283    if (argc != 1)
01284       return RESULT_SHOWUSAGE;
01285    o->cursound = -1;
01286    o->nosound = 0; /* when cursound is -1 nosound must be 0 */
01287    if (!o->owner) { /* XXX maybe !o->hookstate too ? */
01288       ast_cli(fd, "No call to flash\n");
01289       return RESULT_FAILURE;
01290    }
01291    o->hookstate = 0;
01292    if (o->owner) /* XXX must be true, right ? */
01293       ast_queue_frame(o->owner, &f);
01294    return RESULT_SUCCESS;
01295 }

static int console_hangup ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1255 of file chan_oss.c.

References ast_cli(), ast_queue_hangup(), chan_oss_pvt::cursound, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::nosound, O_CLOSE, oss_active, chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, and setformat().

01256 {
01257    struct chan_oss_pvt *o = find_desc(oss_active);
01258 
01259    if (argc != 2)
01260       return RESULT_SHOWUSAGE;
01261    o->cursound = -1;
01262    o->nosound = 0;
01263    if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
01264       ast_cli(fd, "No call to hang up\n");
01265       return RESULT_FAILURE;
01266    }
01267    o->hookstate = 0;
01268    if (o->owner)
01269       ast_queue_hangup(o->owner);
01270    setformat(o, O_CLOSE);
01271    return RESULT_SUCCESS;
01272 }

static int console_hangup_deprecated ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1236 of file chan_oss.c.

References ast_cli(), ast_queue_hangup(), chan_oss_pvt::cursound, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::nosound, O_CLOSE, oss_active, chan_oss_pvt::owner, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, and setformat().

01237 {
01238    struct chan_oss_pvt *o = find_desc(oss_active);
01239 
01240    if (argc != 1)
01241       return RESULT_SHOWUSAGE;
01242    o->cursound = -1;
01243    o->nosound = 0;
01244    if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
01245       ast_cli(fd, "No call to hang up\n");
01246       return RESULT_FAILURE;
01247    }
01248    o->hookstate = 0;
01249    if (o->owner)
01250       ast_queue_hangup(o->owner);
01251    setformat(o, O_CLOSE);
01252    return RESULT_SUCCESS;
01253 }

static int console_mute ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1422 of file chan_oss.c.

References __console_mute_unmute(), and RESULT_SHOWUSAGE.

01423 {
01424    if (argc != 2)
01425       return RESULT_SHOWUSAGE;
01426 
01427    return __console_mute_unmute(1);
01428 }