Wed Jan 8 2020 09:50:04

Asterisk developer's documentation


chan_oss.c File Reference

Channel driver for OSS sound cards. More...

#include "asterisk.h"
#include <ctype.h>
#include <math.h>
#include <sys/ioctl.h>
#include <soundcard.h>
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/callerid.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/cli.h"
#include "asterisk/causes.h"
#include "asterisk/musiconhold.h"
#include "asterisk/app.h"
#include "console_video.h"

Go to the source code of this file.

Data Structures

struct  chan_oss_pvt
 descriptor for one of our channels. More...
 

Macros

#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 O_CLOSE   0x444 /* special 'close' mode for device */
 
#define QUEUE_SIZE   10
 
#define TEXT_SIZE   256
 
#define WARN_frag   4
 
#define WARN_speed   2
 
#define WARN_used_blocks   1
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static char * ast_ext_ctx (const char *src, char **ext, char **ctx)
 
static char * console_active (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_answer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 answer command from the console More...
 
static char * console_autoanswer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_boost (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_dial (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_do_answer (int fd)
 helper function for the answer key/cli command More...
 
static char * console_flash (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_hangup (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_mute (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_sendtext (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Console send text CLI command. More...
 
static char * console_transfer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static struct chan_oss_pvtfind_desc (const char *dev)
 returns a pointer to the descriptor with the given name More...
 
struct video_desc * get_video_desc (struct ast_channel *c)
 return the pointer to the video descriptor More...
 
static int load_module (void)
 
static int oss_answer (struct ast_channel *c)
 remote side answered the phone More...
 
static int oss_call (struct ast_channel *c, char *dest, int timeout)
 handler for incoming calls. Either autoanswer, or start ringing More...
 
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, const char *linkedid)
 allocate a new channel. More...
 
static struct ast_frameoss_read (struct ast_channel *chan)
 
static struct ast_channeloss_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
 
static int oss_text (struct ast_channel *c, const char *text)
 
static int oss_write (struct ast_channel *c, struct ast_frame *f)
 used for data coming from the network More...
 
static int setformat (struct chan_oss_pvt *o, int mode)
 
static int soundcard_writeframe (struct chan_oss_pvt *o, short *data)
 
static void store_boost (struct chan_oss_pvt *o, const char *s)
 store the boost factor More...
 
static void store_callerid (struct chan_oss_pvt *o, const char *s)
 
static struct chan_oss_pvtstore_config (struct ast_config *cfg, char *ctg)
 
static void store_config_core (struct chan_oss_pvt *o, const char *var, const char *value)
 
static void store_mixer (struct chan_oss_pvt *o, const char *s)
 
static int unload_module (void)
 
static int used_blocks (struct chan_oss_pvt *o)
 Returns the number of blocks used in the audio output channel. More...
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "OSS Console Channel Driver" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_cli_entry cli_oss []
 
static char * config = "oss.conf"
 
static struct ast_jb_conf default_jbconf
 
static struct ast_jb_conf global_jbconf
 
static char * oss_active
 
static int oss_debug
 
static struct chan_oss_pvt oss_default
 
static struct ast_channel_tech oss_tech
 
static char tdesc [] = "OSS Console Channel Driver"
 

Detailed Description

Channel driver for OSS sound cards.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Luigi Rizzo
See also

Definition in file chan_oss.c.

Macro Definition Documentation

#define BOOST_MAX   40

slightly less than 7 bits

Definition at line 275 of file chan_oss.c.

Referenced by store_boost().

#define BOOST_SCALE   (1<<9)

boost support. BOOST_SCALE * 10 ^(BOOST_MAX/20) must be representable in 16 bits to avoid overflows.

Definition at line 274 of file chan_oss.c.

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

#define DEV_DSP   "/dev/dsp"

Definition at line 232 of file chan_oss.c.

Referenced by store_config().

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

Definition at line 215 of file chan_oss.c.

#define FRAME_SIZE   160

Definition at line 209 of file chan_oss.c.

Referenced by oss_read(), and soundcard_writeframe().

#define O_CLOSE   0x444 /* special 'close' mode for device */

Definition at line 227 of file chan_oss.c.

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

#define QUEUE_SIZE   10

Definition at line 210 of file chan_oss.c.

#define TEXT_SIZE   256

Definition at line 222 of file chan_oss.c.

Referenced by console_sendtext().

#define WARN_frag   4

Definition at line 264 of file chan_oss.c.

Referenced by setformat().

#define WARN_speed   2

Definition at line 263 of file chan_oss.c.

Referenced by setformat().

#define WARN_used_blocks   1

Definition at line 262 of file chan_oss.c.

Referenced by used_blocks().

Function Documentation

static void __reg_module ( void  )
static

Definition at line 1502 of file chan_oss.c.

static void __unreg_module ( void  )
static

Definition at line 1502 of file chan_oss.c.

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

Definition at line 393 of file chan_oss.c.

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

Referenced by console_dial(), and console_transfer().

394 {
395  struct chan_oss_pvt *o = find_desc(oss_active);
396 
397  if (ext == NULL || ctx == NULL)
398  return NULL; /* error */
399 
400  *ext = *ctx = NULL;
401 
402  if (src && *src != '\0')
403  *ext = ast_strdup(src);
404 
405  if (*ext == NULL)
406  return NULL;
407 
408  if (!o->overridecontext) {
409  /* parse from the right */
410  *ctx = strrchr(*ext, '@');
411  if (*ctx)
412  *(*ctx)++ = '\0';
413  }
414 
415  return *ext;
416 }
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:286
#define ast_strdup(a)
Definition: astmm.h:109
static char * oss_active
Definition: chan_oss.c:306
const char * ext
Definition: http.c:112
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
int overridecontext
Definition: chan_oss.c:268
static char* console_active ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1208 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_desc(), chan_oss_pvt::name, chan_oss_pvt::next, and ast_cli_entry::usage.

1209 {
1210  switch (cmd) {
1211  case CLI_INIT:
1212  e->command = "console {set|show} active [<device>]";
1213  e->usage =
1214  "Usage: console active [device]\n"
1215  " If used without a parameter, displays which device is the current\n"
1216  " console. If a device is specified, the console sound device is changed to\n"
1217  " the device specified.\n";
1218  return NULL;
1219  case CLI_GENERATE:
1220  return NULL;
1221  }
1222 
1223  if (a->argc == 3)
1224  ast_cli(a->fd, "active console is [%s]\n", oss_active);
1225  else if (a->argc != 4)
1226  return CLI_SHOWUSAGE;
1227  else {
1228  struct chan_oss_pvt *o;
1229  if (strcmp(a->argv[3], "show") == 0) {
1230  for (o = oss_default.next; o; o = o->next)
1231  ast_cli(a->fd, "device [%s] exists\n", o->name);
1232  return CLI_SUCCESS;
1233  }
1234  o = find_desc(a->argv[3]);
1235  if (o == NULL)
1236  ast_cli(a->fd, "No device [%s] exists\n", a->argv[3]);
1237  else
1238  oss_active = o->name;
1239  }
1240  return CLI_SUCCESS;
1241 }
struct chan_oss_pvt * next
Definition: chan_oss.c:248
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
const int fd
Definition: cli.h:153
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
char * name
Definition: chan_oss.c:250
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:314
static char* console_answer ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

answer command from the console

Definition at line 970 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, console_do_answer(), ast_cli_args::fd, and ast_cli_entry::usage.

971 {
972  switch (cmd) {
973  case CLI_INIT:
974  e->command = "console answer";
975  e->usage =
976  "Usage: console answer\n"
977  " Answers an incoming call on the console (OSS) channel.\n";
978  return NULL;
979 
980  case CLI_GENERATE:
981  return NULL; /* no completion */
982  }
983  if (a->argc != e->args)
984  return CLI_SHOWUSAGE;
985  return console_do_answer(a->fd);
986 }
const int argc
Definition: cli.h:154
static char * console_do_answer(int fd)
helper function for the answer key/cli command
Definition: chan_oss.c:953
Definition: cli.h:146
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
#define CLI_SHOWUSAGE
Definition: cli.h:44
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
static char* console_autoanswer ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 914 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), ast_log(), chan_oss_pvt::autoanswer, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_desc(), LOG_WARNING, and ast_cli_entry::usage.

915 {
916  struct chan_oss_pvt *o = find_desc(oss_active);
917 
918  switch (cmd) {
919  case CLI_INIT:
920  e->command = "console {set|show} autoanswer [on|off]";
921  e->usage =
922  "Usage: console {set|show} autoanswer [on|off]\n"
923  " Enables or disables autoanswer feature. If used without\n"
924  " argument, displays the current on/off status of autoanswer.\n"
925  " The default value of autoanswer is in 'oss.conf'.\n";
926  return NULL;
927 
928  case CLI_GENERATE:
929  return NULL;
930  }
931 
932  if (a->argc == e->args - 1) {
933  ast_cli(a->fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
934  return CLI_SUCCESS;
935  }
936  if (a->argc != e->args)
937  return CLI_SHOWUSAGE;
938  if (o == NULL) {
939  ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
940  oss_active);
941  return CLI_FAILURE;
942  }
943  if (!strcasecmp(a->argv[e->args-1], "on"))
944  o->autoanswer = 1;
945  else if (!strcasecmp(a->argv[e->args - 1], "off"))
946  o->autoanswer = 0;
947  else
948  return CLI_SHOWUSAGE;
949  return CLI_SUCCESS;
950 }
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
#define LOG_WARNING
Definition: logger.h:144
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define CLI_FAILURE
Definition: cli.h:45
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
int autoanswer
Definition: chan_oss.c:254
static char* console_boost ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1265 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), chan_oss_pvt::boost, BOOST_SCALE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_desc(), store_boost(), and ast_cli_entry::usage.

1266 {
1267  struct chan_oss_pvt *o = find_desc(oss_active);
1268 
1269  switch (cmd) {
1270  case CLI_INIT:
1271  e->command = "console boost";
1272  e->usage =
1273  "Usage: console boost [boost in dB]\n"
1274  " Sets or display mic boost in dB\n";
1275  return NULL;
1276  case CLI_GENERATE:
1277  return NULL;
1278  }
1279 
1280  if (a->argc == 2)
1281  ast_cli(a->fd, "boost currently %5.1f\n", 20 * log10(((double) o->boost / (double) BOOST_SCALE)));
1282  else if (a->argc == 3)
1283  store_boost(o, a->argv[2]);
1284  return CLI_SUCCESS;
1285 }
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
const int fd
Definition: cli.h:153
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
static void store_boost(struct chan_oss_pvt *o, const char *s)
store the boost factor
Definition: chan_oss.c:1246
#define CLI_SUCCESS
Definition: cli.h:43
#define BOOST_SCALE
Definition: chan_oss.c:274
static char* console_cmd ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Generic console command handler. Basically a wrapper for a subset of config file options which are also available from the CLI

Definition at line 878 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), ast_log(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, console_video_cli(), CONSOLE_VIDEO_CMDS, chan_oss_pvt::device, chan_oss_pvt::env, ast_cli_args::fd, find_desc(), LOG_WARNING, store_config_core(), ast_cli_entry::usage, value, and var.

879 {
880  struct chan_oss_pvt *o = find_desc(oss_active);
881  const char *var, *value;
882  switch (cmd) {
883  case CLI_INIT:
885  e->usage =
886  "Usage: " CONSOLE_VIDEO_CMDS "...\n"
887  " Generic handler for console commands.\n";
888  return NULL;
889 
890  case CLI_GENERATE:
891  return NULL;
892  }
893 
894  if (a->argc < e->args)
895  return CLI_SHOWUSAGE;
896  if (o == NULL) {
897  ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
898  oss_active);
899  return CLI_FAILURE;
900  }
901  var = a->argv[e->args-1];
902  value = a->argc > e->args ? a->argv[e->args] : NULL;
903  if (value) /* handle setting */
904  store_config_core(o, var, value);
905  if (!console_video_cli(o->env, var, a->fd)) /* print video-related values */
906  return CLI_SUCCESS;
907  /* handle other values */
908  if (!strcasecmp(var, "device")) {
909  ast_cli(a->fd, "device is [%s]\n", o->device);
910  }
911  return CLI_SUCCESS;
912 }
#define CONSOLE_VIDEO_CMDS
Definition: console_video.h:27
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
#define LOG_WARNING
Definition: logger.h:144
#define var
Definition: ast_expr2f.c:606
Definition: cli.h:146
int value
Definition: syslog.c:39
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define CLI_FAILURE
Definition: cli.h:45
char * command
Definition: cli.h:180
int console_video_cli(struct video_desc *env, const char *var, int fd)
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
struct video_desc * env
Definition: chan_oss.c:283
char device[64]
Definition: chan_oss.c:277
static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value)
Definition: chan_oss.c:1330
static char* console_dial ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1080 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), ast_exists_extension(), ast_ext_ctx(), AST_FRAME_DTMF, ast_free, ast_queue_frame(), AST_STATE_RINGING, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, chan_oss_pvt::ctx, chan_oss_pvt::ext, ast_cli_args::fd, find_desc(), chan_oss_pvt::hookstate, ast_frame_subclass::integer, oss_new(), chan_oss_pvt::owner, ast_frame::subclass, and ast_cli_entry::usage.

1081 {
1082  char *s = NULL;
1083  char *mye = NULL, *myc = NULL;
1084  struct chan_oss_pvt *o = find_desc(oss_active);
1085 
1086  if (cmd == CLI_INIT) {
1087  e->command = "console dial";
1088  e->usage =
1089  "Usage: console dial [extension[@context]]\n"
1090  " Dials a given extension (and context if specified)\n";
1091  return NULL;
1092  } else if (cmd == CLI_GENERATE)
1093  return NULL;
1094 
1095  if (a->argc > e->args + 1)
1096  return CLI_SHOWUSAGE;
1097  if (o->owner) { /* already in a call */
1098  int i;
1099  struct ast_frame f = { AST_FRAME_DTMF, { 0 } };
1100  const char *s;
1101 
1102  if (a->argc == e->args) { /* argument is mandatory here */
1103  ast_cli(a->fd, "Already in a call. You can only dial digits until you hangup.\n");
1104  return CLI_FAILURE;
1105  }
1106  s = a->argv[e->args];
1107  /* send the string one char at a time */
1108  for (i = 0; i < strlen(s); i++) {
1109  f.subclass.integer = s[i];
1110  ast_queue_frame(o->owner, &f);
1111  }
1112  return CLI_SUCCESS;
1113  }
1114  /* if we have an argument split it into extension and context */
1115  if (a->argc == e->args + 1)
1116  s = ast_ext_ctx(a->argv[e->args], &mye, &myc);
1117  /* supply default values if needed */
1118  if (mye == NULL)
1119  mye = o->ext;
1120  if (myc == NULL)
1121  myc = o->ctx;
1122  if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
1123  o->hookstate = 1;
1124  oss_new(o, mye, myc, AST_STATE_RINGING, NULL);
1125  } else
1126  ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
1127  if (s)
1128  ast_free(s);
1129  return CLI_SUCCESS;
1130 }
union ast_frame_subclass subclass
Definition: frame.h:146
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:286
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
#define AST_FRAME_DTMF
Definition: frame.h:128
Definition: cli.h:146
static char * ast_ext_ctx(const char *src, char **ext, char **ctx)
Definition: chan_oss.c:393
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
int hookstate
Definition: chan_oss.c:256
static struct ast_channel * oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state, const char *linkedid)
allocate a new channel.
Definition: chan_oss.c:789
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:5400
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
#define CLI_FAILURE
Definition: cli.h:45
#define ast_free(a)
Definition: astmm.h:97
char * command
Definition: cli.h:180
static struct ast_format f[]
Definition: format_g726.c:181
char ext[AST_MAX_EXTENSION]
Definition: chan_oss.c:285
struct ast_channel * owner
Definition: chan_oss.c:281
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
Data structure associated with a single frame of data.
Definition: frame.h:142
static char* console_do_answer ( int  fd)
static

helper function for the answer key/cli command

Definition at line 953 of file chan_oss.c.

References ast_cli(), AST_CONTROL_ANSWER, AST_FRAME_CONTROL, ast_queue_frame(), CLI_FAILURE, CLI_SUCCESS, find_desc(), chan_oss_pvt::hookstate, and chan_oss_pvt::owner.

Referenced by console_answer().

954 {
956  struct chan_oss_pvt *o = find_desc(oss_active);
957  if (!o->owner) {
958  if (fd > -1)
959  ast_cli(fd, "No one is calling us\n");
960  return CLI_FAILURE;
961  }
962  o->hookstate = 1;
963  ast_queue_frame(o->owner, &f);
964  return CLI_SUCCESS;
965 }
static char * oss_active
Definition: chan_oss.c:306
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int hookstate
Definition: chan_oss.c:256
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
#define CLI_FAILURE
Definition: cli.h:45
static struct ast_format f[]
Definition: format_g726.c:181
struct ast_channel * owner
Definition: chan_oss.c:281
#define CLI_SUCCESS
Definition: cli.h:43
Data structure associated with a single frame of data.
Definition: frame.h:142
static char* console_flash ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1054 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli(), AST_CONTROL_FLASH, AST_FRAME_CONTROL, ast_queue_frame(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_desc(), chan_oss_pvt::hookstate, chan_oss_pvt::owner, and ast_cli_entry::usage.

1055 {
1056  struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH } };
1057  struct chan_oss_pvt *o = find_desc(oss_active);
1058 
1059  if (cmd == CLI_INIT) {
1060  e->command = "console flash";
1061  e->usage =
1062  "Usage: console flash\n"
1063  " Flashes the call currently placed on the console.\n";
1064  return NULL;
1065  } else if (cmd == CLI_GENERATE)
1066  return NULL;
1067 
1068  if (a->argc != e->args)
1069  return CLI_SHOWUSAGE;
1070  if (!o->owner) { /* XXX maybe !o->hookstate too ? */
1071  ast_cli(a->fd, "No call to flash\n");
1072  return CLI_FAILURE;
1073  }
1074  o->hookstate = 0;
1075  if (o->owner)
1076  ast_queue_frame(o->owner, &f);
1077  return CLI_SUCCESS;
1078 }
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
int hookstate
Definition: chan_oss.c:256
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
#define CLI_SHOWUSAGE
Definition: cli.h:44
#define CLI_FAILURE
Definition: cli.h:45
char * command
Definition: cli.h:180
static struct ast_format f[]
Definition: format_g726.c:181
struct ast_channel * owner
Definition: chan_oss.c:281
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
Data structure associated with a single frame of data.
Definition: frame.h:142
static char* console_hangup ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1028 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, AST_CAUSE_NORMAL_CLEARING, ast_cli(), ast_queue_hangup_with_cause(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_desc(), chan_oss_pvt::hookstate, O_CLOSE, chan_oss_pvt::owner, setformat(), and ast_cli_entry::usage.

1029 {
1030  struct chan_oss_pvt *o = find_desc(oss_active);
1031 
1032  if (cmd == CLI_INIT) {
1033  e->command = "console hangup";
1034  e->usage =
1035  "Usage: console hangup\n"
1036  " Hangs up any call currently placed on the console.\n";
1037  return NULL;
1038  } else if (cmd == CLI_GENERATE)
1039  return NULL;
1040 
1041  if (a->argc != e->args)
1042  return CLI_SHOWUSAGE;
1043  if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
1044  ast_cli(a->fd, "No call to hang up\n");
1045  return CLI_FAILURE;
1046  }
1047  o->hookstate = 0;
1048  if (o->owner)
1050  setformat(o, O_CLOSE);
1051  return CLI_SUCCESS;
1052 }
#define O_CLOSE
Definition: chan_oss.c:227
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:472
int hookstate
Definition: chan_oss.c:256
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
#define CLI_SHOWUSAGE
Definition: cli.h:44
#define CLI_FAILURE
Definition: cli.h:45
char * command
Definition: cli.h:180
struct ast_channel * owner
Definition: chan_oss.c:281
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
static char* console_mute ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1132 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_desc(), chan_oss_pvt::mute, and ast_cli_entry::usage.

1133 {
1134  struct chan_oss_pvt *o = find_desc(oss_active);
1135  const char *s;
1136  int toggle = 0;
1137 
1138  if (cmd == CLI_INIT) {
1139  e->command = "console {mute|unmute} [toggle]";
1140  e->usage =
1141  "Usage: console {mute|unmute} [toggle]\n"
1142  " Mute/unmute the microphone.\n";
1143  return NULL;
1144  } else if (cmd == CLI_GENERATE)
1145  return NULL;
1146 
1147  if (a->argc > e->args)
1148  return CLI_SHOWUSAGE;
1149  if (a->argc == e->args) {
1150  if (strcasecmp(a->argv[e->args-1], "toggle"))
1151  return CLI_SHOWUSAGE;
1152  toggle = 1;
1153  }
1154  s = a->argv[e->args-2];
1155  if (!strcasecmp(s, "mute"))
1156  o->mute = toggle ? !o->mute : 1;
1157  else if (!strcasecmp(s, "unmute"))
1158  o->mute = toggle ? !o->mute : 0;
1159  else
1160  return CLI_SHOWUSAGE;
1161  ast_cli(a->fd, "Console mic is %s\n", o->mute ? "off" : "on");
1162  return CLI_SUCCESS;
1163 }
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
static char* console_sendtext ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Console send text CLI command.

Note
concatenate all arguments into a single string. argv is NULL-terminated so we can use it right away

Definition at line 994 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), AST_FRAME_TEXT, ast_join(), ast_queue_frame(), ast_strlen_zero(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_frame::data, ast_frame::datalen, ast_cli_args::fd, find_desc(), ast_frame::frametype, ast_frame_subclass::integer, chan_oss_pvt::owner, ast_frame::ptr, ast_frame::subclass, TEXT_SIZE, and ast_cli_entry::usage.

995 {
996  struct chan_oss_pvt *o = find_desc(oss_active);
997  char buf[TEXT_SIZE];
998 
999  if (cmd == CLI_INIT) {
1000  e->command = "console send text";
1001  e->usage =
1002  "Usage: console send text <message>\n"
1003  " Sends a text message for display on the remote terminal.\n";
1004  return NULL;
1005  } else if (cmd == CLI_GENERATE)
1006  return NULL;
1007 
1008  if (a->argc < e->args + 1)
1009  return CLI_SHOWUSAGE;
1010  if (!o->owner) {
1011  ast_cli(a->fd, "Not in a call\n");
1012  return CLI_FAILURE;
1013  }
1014  ast_join(buf, sizeof(buf) - 1, a->argv + e->args);
1015  if (!ast_strlen_zero(buf)) {
1016  struct ast_frame f = { 0, };
1017  int i = strlen(buf);
1018  buf[i] = '\n';
1020  f.subclass.integer = 0;
1021  f.data.ptr = buf;
1022  f.datalen = i + 1;
1023  ast_queue_frame(o->owner, &f);
1024  }
1025  return CLI_SUCCESS;
1026 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define TEXT_SIZE
Definition: chan_oss.c:222
void * ptr
Definition: frame.h:160
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int datalen
Definition: frame.h:148
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
#define CLI_FAILURE
Definition: cli.h:45
char * command
Definition: cli.h:180
void ast_join(char *s, size_t len, const char *const w[])
Definition: utils.c:1690
static struct ast_format f[]
Definition: format_g726.c:181
struct ast_channel * owner
Definition: chan_oss.c:281
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
union ast_frame::@172 data
static char* console_transfer ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1165 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_async_goto(), ast_bridged_channel(), ast_cli(), ast_exists_extension(), ast_ext_ctx(), ast_free, ast_channel::caller, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_channel::context, ext, ast_cli_args::fd, find_desc(), ast_party_caller::id, ast_channel::name, ast_party_id::number, chan_oss_pvt::owner, S_COR, ast_party_number::str, ast_cli_entry::usage, and ast_party_number::valid.

1166 {
1167  struct chan_oss_pvt *o = find_desc(oss_active);
1168  struct ast_channel *b = NULL;
1169  char *tmp, *ext, *ctx;
1170 
1171  switch (cmd) {
1172  case CLI_INIT:
1173  e->command = "console transfer";
1174  e->usage =
1175  "Usage: console transfer <extension>[@context]\n"
1176  " Transfers the currently connected call to the given extension (and\n"
1177  " context if specified)\n";
1178  return NULL;
1179  case CLI_GENERATE:
1180  return NULL;
1181  }
1182 
1183  if (a->argc != 3)
1184  return CLI_SHOWUSAGE;
1185  if (o == NULL)
1186  return CLI_FAILURE;
1187  if (o->owner == NULL || (b = ast_bridged_channel(o->owner)) == NULL) {
1188  ast_cli(a->fd, "There is no call to transfer\n");
1189  return CLI_SUCCESS;
1190  }
1191 
1192  tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
1193  if (ctx == NULL) /* supply default context if needed */
1194  ctx = o->owner->context;
1195  if (!ast_exists_extension(b, ctx, ext, 1,
1196  S_COR(b->caller.id.number.valid, b->caller.id.number.str, NULL))) {
1197  ast_cli(a->fd, "No such extension exists\n");
1198  } else {
1199  ast_cli(a->fd, "Whee, transferring %s to %s@%s.\n", b->name, ext, ctx);
1200  if (ast_async_goto(b, ctx, ext, 1))
1201  ast_cli(a->fd, "Failed to transfer :(\n");
1202  }
1203  if (tmp)
1204  ast_free(tmp);
1205  return CLI_SUCCESS;
1206 }
Main Channel structure associated with a channel.
Definition: channel.h:742
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
static char * oss_active
Definition: chan_oss.c:306
const int argc
Definition: cli.h:154
Definition: cli.h:146
static char * ast_ext_ctx(const char *src, char **ext, char **ctx)
Definition: chan_oss.c:393
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
const char * ext
Definition: http.c:112
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
const int fd
Definition: cli.h:153
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:5400
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
#define CLI_FAILURE
Definition: cli.h:45
#define ast_free(a)
Definition: astmm.h:97
char * command
Definition: cli.h:180
struct ast_channel * owner
Definition: chan_oss.c:281
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Definition: pbx.c:8731
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static struct chan_oss_pvt * find_desc ( const char *  dev)
static

returns a pointer to the descriptor with the given name

forward declaration

Definition at line 367 of file chan_oss.c.

References ast_log(), LOG_WARNING, chan_oss_pvt::name, and chan_oss_pvt::next.

Referenced by ast_ext_ctx(), console_active(), console_autoanswer(), console_boost(), console_cmd(), console_dial(), console_do_answer(), console_flash(), console_hangup(), console_mute(), console_sendtext(), console_transfer(), get_video_desc(), keypad_toggle(), load_module(), and oss_request().

368 {
369  struct chan_oss_pvt *o = NULL;
370 
371  if (!dev)
372  ast_log(LOG_WARNING, "null dev\n");
373 
374  for (o = oss_default.next; o && o->name && dev && strcmp(o->name, dev) != 0; o = o->next);
375 
376  if (!o)
377  ast_log(LOG_WARNING, "could not find <%s>\n", dev ? dev : "--no-device--");
378 
379  return o;
380 }
struct chan_oss_pvt * next
Definition: chan_oss.c:248
#define LOG_WARNING
Definition: logger.h:144
descriptor for one of our channels.
Definition: chan_oss.c:247
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char * name
Definition: chan_oss.c:250
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:314
struct video_desc* get_video_desc ( struct ast_channel c)

return the pointer to the video descriptor

Definition at line 309 of file chan_oss.c.

References chan_oss_pvt::env, find_desc(), and ast_channel::tech_pvt.

Referenced by oss_new().

310 {
311  struct chan_oss_pvt *o = c ? c->tech_pvt : find_desc(oss_active);
312  return o ? o->env : NULL;
313 }
void * tech_pvt
Definition: channel.h:744
static char * oss_active
Definition: chan_oss.c:306
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
struct video_desc * env
Definition: chan_oss.c:283
static int load_module ( void  )
static

Definition at line 1436 of file chan_oss.c.

References ARRAY_LEN, ast_category_browse(), ast_channel_register(), ast_cli_register_multiple(), ast_config_destroy(), ast_config_load, ast_log(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_channel_tech::capabilities, CONFIG_STATUS_FILEINVALID, console_video_formats, find_desc(), global_jbconf, LOG_ERROR, LOG_NOTICE, and store_config().

1437 {
1438  struct ast_config *cfg = NULL;
1439  char *ctg = NULL;
1440  struct ast_flags config_flags = { 0 };
1441 
1442  /* Copy the default jb config over global_jbconf */
1443  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
1444 
1445  /* load config file */
1446  if (!(cfg = ast_config_load(config, config_flags))) {
1447  ast_log(LOG_NOTICE, "Unable to load config %s\n", config);
1448  return AST_MODULE_LOAD_DECLINE;
1449  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
1450  ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
1451  return AST_MODULE_LOAD_DECLINE;
1452  }
1453 
1454  do {
1455  store_config(cfg, ctg);
1456  } while ( (ctg = ast_category_browse(cfg, ctg)) != NULL);
1457 
1458  ast_config_destroy(cfg);
1459 
1460  if (find_desc(oss_active) == NULL) {
1461  ast_log(LOG_NOTICE, "Device %s not found\n", oss_active);
1462  /* XXX we could default to 'dsp' perhaps ? */
1463  /* XXX should cleanup allocated memory etc. */
1464  return AST_MODULE_LOAD_FAILURE;
1465  }
1466 
1468 
1470  ast_log(LOG_ERROR, "Unable to register channel type 'OSS'\n");
1471  return AST_MODULE_LOAD_DECLINE;
1472  }
1473 
1475 
1476  return AST_MODULE_LOAD_SUCCESS;
1477 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static char * config
Definition: chan_oss.c:235
format_t capabilities
Definition: channel.h:511
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:346
static char * oss_active
Definition: chan_oss.c:306
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:907
int console_video_formats
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
#define ast_config_load(filename, flags)
Load a config file.
Definition: config.h:170
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
Definition: config.c:810
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
static struct ast_cli_entry cli_oss[]
Definition: chan_oss.c:1287
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
Structure used to handle boolean flags.
Definition: utils.h:200
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
static struct ast_jb_conf default_jbconf
Definition: chan_oss.c:71
General jitterbuffer configuration.
Definition: abstract_jb.h:55
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:79
static struct chan_oss_pvt * store_config(struct ast_config *cfg, char *ctg)
Definition: chan_oss.c:1361
static int oss_answer ( struct ast_channel c)
static

remote side answered the phone

Definition at line 636 of file chan_oss.c.

References ast_setstate(), AST_STATE_UP, ast_verbose(), chan_oss_pvt::hookstate, and ast_channel::tech_pvt.

637 {
638  struct chan_oss_pvt *o = c->tech_pvt;
639  ast_verbose(" << Console call has been answered >> \n");
641  o->hookstate = 1;
642  return 0;
643 }
void * tech_pvt
Definition: channel.h:744
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
int hookstate
Definition: chan_oss.c:256
descriptor for one of our channels.
Definition: chan_oss.c:247
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
static int oss_call ( struct ast_channel c,
char *  dest,
int  timeout 
)
static

handler for incoming calls. Either autoanswer, or start ringing

Definition at line 594 of file chan_oss.c.

References args, AST_APP_ARG, AST_CONTROL_ANSWER, AST_CONTROL_RINGING, AST_DECLARE_APP_ARGS, AST_FRAME_CONTROL, ast_indicate(), AST_NONSTANDARD_APP_ARGS, ast_queue_frame(), ast_strdupa, ast_strlen_zero(), ast_verbose(), chan_oss_pvt::autoanswer, ast_channel::caller, ast_channel::dialed, ast_frame::flags, ast_party_redirecting::from, chan_oss_pvt::hookstate, ast_party_caller::id, ast_frame_subclass::integer, name, ast_party_id::name, ast_party_id::number, ast_party_dialed::number, parse(), ast_channel::redirecting, S_COR, S_OR, ast_party_name::str, ast_party_number::str, ast_party_dialed::str, ast_frame::subclass, ast_channel::tech_pvt, ast_party_name::valid, and ast_party_number::valid.

595 {
596  struct chan_oss_pvt *o = c->tech_pvt;
597  struct ast_frame f = { AST_FRAME_CONTROL, };
599  AST_APP_ARG(name);
601  );
602  char *parse = ast_strdupa(dest);
603 
604  AST_NONSTANDARD_APP_ARGS(args, parse, '/');
605 
606  ast_verbose(" << Call to device '%s' dnid '%s' rdnis '%s' on console from '%s' <%s> >>\n",
607  dest,
608  S_OR(c->dialed.number.str, ""),
610  S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
611  S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""));
612  if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "answer") == 0) {
614  ast_queue_frame(c, &f);
615  } else if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "noanswer") == 0) {
617  ast_queue_frame(c, &f);
619  } else if (o->autoanswer) {
620  ast_verbose(" << Auto-answered >> \n");
622  ast_queue_frame(c, &f);
623  o->hookstate = 1;
624  } else {
625  ast_verbose("<< Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
627  ast_queue_frame(c, &f);
629  }
630  return 0;
631 }
union ast_frame_subclass subclass
Definition: frame.h:146
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void * tech_pvt
Definition: channel.h:744
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_dialed::@155 number
Dialed/Called number.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
int hookstate
Definition: chan_oss.c:256
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
descriptor for one of our channels.
Definition: chan_oss.c:247
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static const char name[]
unsigned int flags
Definition: frame.h:166
static struct ast_format f[]
Definition: format_g726.c:181
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
Data structure associated with a single frame of data.
Definition: frame.h:142
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
int autoanswer
Definition: chan_oss.c:254
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int oss_digit_begin ( struct ast_channel c,
char  digit 
)
static

Definition at line 571 of file chan_oss.c.

572 {
573  return 0;
574 }
static int oss_digit_end ( struct ast_channel c,
char  digit,
unsigned int  duration 
)
static

Definition at line 576 of file chan_oss.c.

References ast_verbose().

577 {
578  /* no better use for received digits than print them */
579  ast_verbose(" << Console Received digit %c of duration %u ms >> \n",
580  digit, duration);
581  return 0;
582 }
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
static int oss_fixup ( struct ast_channel oldchan,
struct ast_channel newchan 
)
static

Definition at line 745 of file chan_oss.c.

References chan_oss_pvt::owner, and ast_channel::tech_pvt.

746 {
747  struct chan_oss_pvt *o = newchan->tech_pvt;
748  o->owner = newchan;
749  return 0;
750 }
void * tech_pvt
Definition: channel.h:744
descriptor for one of our channels.
Definition: chan_oss.c:247
struct ast_channel * owner
Definition: chan_oss.c:281
static int oss_hangup ( struct ast_channel c)
static

Definition at line 645 of file chan_oss.c.

References ast_module_unref(), ast_verbose(), chan_oss_pvt::autoanswer, chan_oss_pvt::autohangup, console_video_uninit(), chan_oss_pvt::env, chan_oss_pvt::hookstate, O_CLOSE, chan_oss_pvt::owner, ast_module_info::self, setformat(), and ast_channel::tech_pvt.

646 {
647  struct chan_oss_pvt *o = c->tech_pvt;
648 
649  c->tech_pvt = NULL;
650  o->owner = NULL;
651  ast_verbose(" << Hangup on console >> \n");
654  if (o->hookstate) {
655  if (o->autoanswer || o->autohangup) {
656  /* Assume auto-hangup too */
657  o->hookstate = 0;
658  setformat(o, O_CLOSE);
659  }
660  }
661  return 0;
662 }
void ast_module_unref(struct ast_module *)
Definition: loader.c:1312
void * tech_pvt
Definition: channel.h:744
#define O_CLOSE
Definition: chan_oss.c:227
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
int autohangup
Definition: chan_oss.c:255
struct ast_module * self
Definition: module.h:227
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:472
int hookstate
Definition: chan_oss.c:256
descriptor for one of our channels.
Definition: chan_oss.c:247
struct ast_channel * owner
Definition: chan_oss.c:281
void console_video_uninit(struct video_desc *env)
struct video_desc * env
Definition: chan_oss.c:283
int autoanswer
Definition: chan_oss.c:254
static int oss_indicate ( struct ast_channel chan,
int  cond,
const void *  data,
size_t  datalen 
)
static

Definition at line 752 of file chan_oss.c.

References AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_log(), ast_moh_start(), ast_moh_stop(), ast_verbose(), LOG_WARNING, chan_oss_pvt::mohinterpret, ast_channel::name, and ast_channel::tech_pvt.

753 {
754  struct chan_oss_pvt *o = c->tech_pvt;
755  int res = 0;
756 
757  switch (cond) {
759  case AST_CONTROL_BUSY:
761  case AST_CONTROL_RINGING:
762  case -1:
763  res = -1;
764  break;
769  break;
770  case AST_CONTROL_HOLD:
771  ast_verbose(" << Console Has Been Placed on Hold >> \n");
772  ast_moh_start(c, data, o->mohinterpret);
773  break;
774  case AST_CONTROL_UNHOLD:
775  ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
776  ast_moh_stop(c);
777  break;
778  default:
779  ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, c->name);
780  return -1;
781  }
782 
783  return res;
784 }
#define LOG_WARNING
Definition: logger.h:144
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
ast_cond_t cond
Definition: app_meetme.c:963
descriptor for one of our channels.
Definition: chan_oss.c:247
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:290
static struct ast_channel* oss_new ( struct chan_oss_pvt o,
char *  ext,
char *  ctx,
int  state,
const char *  linkedid 
)
static

allocate a new channel.

Definition at line 789 of file chan_oss.c.

References ast_party_caller::ani, ast_channel_alloc(), ast_channel_set_fd(), AST_FORMAT_SLINEAR, ast_hangup(), ast_jb_configure(), ast_log(), ast_module_ref(), ast_pbx_start(), AST_STATE_DOWN, AST_STATE_RINGING, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_channel::caller, chan_oss_pvt::cid_name, chan_oss_pvt::cid_num, console_video_formats, console_video_start(), chan_oss_pvt::device, ast_channel::dialed, get_video_desc(), global_jbconf, language, chan_oss_pvt::language, LOG_WARNING, ast_channel::name, ast_channel::nativeformats, ast_party_id::number, ast_party_dialed::number, oss_tech, chan_oss_pvt::owner, ast_channel::readformat, ast_module_info::self, setformat(), chan_oss_pvt::sounddev, ast_party_number::str, ast_party_dialed::str, ast_channel::tech, ast_channel::tech_pvt, ast_party_number::valid, and ast_channel::writeformat.

Referenced by console_dial(), and oss_request().

790 {
791  struct ast_channel *c;
792 
793  c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, linkedid, 0, "Console/%s", o->device + 5);
794  if (c == NULL)
795  return NULL;
796  c->tech = &oss_tech;
797  if (o->sounddev < 0)
798  setformat(o, O_RDWR);
799  ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
801  /* if the console makes the call, add video to the offer */
802  if (state == AST_STATE_RINGING)
804 
807  c->tech_pvt = o;
808 
809  if (!ast_strlen_zero(o->language))
811  /* Don't use ast_set_callerid() here because it will
812  * generate a needless NewCallerID event */
813  if (!ast_strlen_zero(o->cid_num)) {
814  c->caller.ani.number.valid = 1;
816  }
817  if (!ast_strlen_zero(ext)) {
819  }
820 
821  o->owner = c;
824  if (state != AST_STATE_DOWN) {
825  if (ast_pbx_start(c)) {
826  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
827  ast_hangup(c);
828  o->owner = c = NULL;
829  }
830  }
831  console_video_start(get_video_desc(c), c); /* XXX cleanup */
832 
833  return c;
834 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
Main Channel structure associated with a channel.
Definition: channel.h:742
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define ast_strdup(a)
Definition: astmm.h:109
format_t writeformat
Definition: channel.h:854
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:346
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:5879
void console_video_start(struct video_desc *env, struct ast_channel *owner)
format_t nativeformats
Definition: channel.h:852
int console_video_formats
const ast_string_field linkedid
Definition: channel.h:787
const char * ext
Definition: http.c:112
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
Definition: channel.c:9825
struct ast_module * self
Definition: module.h:227
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_dialed::@155 number
Dialed/Called number.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:472
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
char cid_name[256]
Definition: chan_oss.c:288
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char cid_num[256]
Definition: chan_oss.c:289
struct ast_channel * owner
Definition: chan_oss.c:281
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
Definition: abstract_jb.c:616
int sounddev
Definition: chan_oss.c:252
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
format_t readformat
Definition: channel.h:853
char device[64]
Definition: chan_oss.c:277
struct ast_channel_tech * tech
Definition: channel.h:743
char language[MAX_LANGUAGE]
Definition: chan_oss.c:287
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct video_desc * get_video_desc(struct ast_channel *c)
return the pointer to the video descriptor
Definition: chan_oss.c:309
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:79
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
struct ast_module * ast_module_ref(struct ast_module *)
Definition: loader.c:1300
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static struct ast_frame * oss_read ( struct ast_channel chan)
static

Definition at line 696 of file chan_oss.c.

References ast_channel::_state, AST_FORMAT_SLINEAR, AST_FRAME_NULL, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, AST_STATE_UP, chan_oss_pvt::boost, BOOST_SCALE, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, f, for(), FRAME_SIZE, ast_frame::frametype, chan_oss_pvt::mute, ast_frame::offset, chan_oss_pvt::oss_read_buf, ast_frame::ptr, chan_oss_pvt::read_f, chan_oss_pvt::readpos, ast_frame::samples, chan_oss_pvt::sounddev, ast_frame::src, ast_frame::subclass, ast_channel::tech_pvt, and ast_channel_tech::type.

697 {
698  int res;
699  struct chan_oss_pvt *o = c->tech_pvt;
700  struct ast_frame *f = &o->read_f;
701 
702  /* XXX can be simplified returning &ast_null_frame */
703  /* prepare a NULL frame in case we don't have enough data to return */
704  memset(f, '\0', sizeof(struct ast_frame));
706  f->src = oss_tech.type;
707 
708  res = read(o->sounddev, o->oss_read_buf + o->readpos, sizeof(o->oss_read_buf) - o->readpos);
709  if (res < 0) /* audio data not ready, return a NULL frame */
710  return f;
711 
712  o->readpos += res;
713  if (o->readpos < sizeof(o->oss_read_buf)) /* not enough samples */
714  return f;
715 
716  if (o->mute)
717  return f;
718 
719  o->readpos = AST_FRIENDLY_OFFSET; /* reset read pointer for next frame */
720  if (c->_state != AST_STATE_UP) /* drop data if frame is not up */
721  return f;
722  /* ok we can build and deliver the frame to the caller */
725  f->samples = FRAME_SIZE;
726  f->datalen = FRAME_SIZE * 2;
728  if (o->boost != BOOST_SCALE) { /* scale and clip values */
729  int i, x;
730  int16_t *p = (int16_t *) f->data.ptr;
731  for (i = 0; i < f->samples; i++) {
732  x = (p[i] * o->boost) / BOOST_SCALE;
733  if (x > 32767)
734  x = 32767;
735  else if (x < -32768)
736  x = -32768;
737  p[i] = x;
738  }
739  }
740 
742  return f;
743 }
union ast_frame_subclass subclass
Definition: frame.h:146
const char *const type
Definition: channel.h:508
int offset
Definition: frame.h:156
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:346
void * ptr
Definition: frame.h:160
for(;;)
Definition: ast_expr2.c:2460
format_t codec
Definition: frame.h:137
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
const char * src
Definition: frame.h:158
int datalen
Definition: frame.h:148
descriptor for one of our channels.
Definition: chan_oss.c:247
#define FRAME_SIZE
Definition: chan_oss.c:209
static struct ast_format f[]
Definition: format_g726.c:181
struct ast_frame read_f
Definition: chan_oss.c:300
int sounddev
Definition: chan_oss.c:252
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
char oss_read_buf[FRAME_SIZE *2+AST_FRIENDLY_OFFSET]
Definition: chan_oss.c:298
union ast_frame::@172 data
#define BOOST_SCALE
Definition: chan_oss.c:274
int samples
Definition: frame.h:150
static struct ast_channel * oss_request ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
int *  cause 
)
static

Definition at line 836 of file chan_oss.c.

References args, AST_APP_ARG, AST_CAUSE_BUSY, AST_DECLARE_APP_ARGS, AST_FORMAT_SLINEAR, ast_getformatname_multiple(), ast_log(), AST_NONSTANDARD_APP_ARGS, AST_STATE_DOWN, ast_strdupa, find_desc(), ast_channel::linkedid, LOG_NOTICE, LOG_WARNING, name, oss_new(), chan_oss_pvt::owner, and parse().

837 {
838  struct ast_channel *c;
839  struct chan_oss_pvt *o;
841  AST_APP_ARG(name);
842  AST_APP_ARG(flags);
843  );
844  char *parse = ast_strdupa(data);
845  char buf[256];
846 
847  AST_NONSTANDARD_APP_ARGS(args, parse, '/');
848  o = find_desc(args.name);
849 
850  ast_log(LOG_WARNING, "oss_request ty <%s> data 0x%p <%s>\n", type, data, (char *) data);
851  if (o == NULL) {
852  ast_log(LOG_NOTICE, "Device %s not found\n", args.name);
853  /* XXX we could default to 'dsp' perhaps ? */
854  return NULL;
855  }
856  if ((format & AST_FORMAT_SLINEAR) == 0) {
857  ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_getformatname_multiple(buf, sizeof(buf), format));
858  return NULL;
859  }
860  if (o->owner) {
861  ast_log(LOG_NOTICE, "Already have a call (chan %p) on the OSS channel\n", o->owner);
862  *cause = AST_CAUSE_BUSY;
863  return NULL;
864  }
865  c = oss_new(o, NULL, NULL, AST_STATE_DOWN, requestor ? requestor->linkedid : NULL);
866  if (c == NULL) {
867  ast_log(LOG_WARNING, "Unable to create new OSS channel\n");
868  return NULL;
869  }
870  return c;
871 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
const ast_string_field linkedid
Definition: channel.h:787
static struct ast_channel * oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state, const char *linkedid)
allocate a new channel.
Definition: chan_oss.c:789
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static const char name[]
struct ast_channel * owner
Definition: chan_oss.c:281
static const char type[]
Definition: chan_nbs.c:57
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define AST_CAUSE_BUSY
Definition: causes.h:148
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
static snd_pcm_format_t format
Definition: chan_alsa.c:93
static int oss_text ( struct ast_channel c,
const char *  text 
)
static

Definition at line 584 of file chan_oss.c.

References ast_verbose().

585 {
586  /* print received messages */
587  ast_verbose(" << Console Received text %s >> \n", text);
588  return 0;
589 }
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
char * text
Definition: app_queue.c:1091
static int oss_write ( struct ast_channel chan,
struct ast_frame f 
)
static

used for data coming from the network

Definition at line 665 of file chan_oss.c.

References ast_frame::data, ast_frame::datalen, if(), chan_oss_pvt::oss_write_buf, chan_oss_pvt::oss_write_dst, ast_frame::ptr, soundcard_writeframe(), and ast_channel::tech_pvt.

666 {
667  int src;
668  struct chan_oss_pvt *o = c->tech_pvt;
669 
670  /*
671  * we could receive a block which is not a multiple of our
672  * FRAME_SIZE, so buffer it locally and write to the device
673  * in FRAME_SIZE chunks.
674  * Keep the residue stored for future use.
675  */
676  src = 0; /* read position into f->data */
677  while (src < f->datalen) {
678  /* Compute spare room in the buffer */
679  int l = sizeof(o->oss_write_buf) - o->oss_write_dst;
680 
681  if (f->datalen - src >= l) { /* enough to fill a frame */
682  memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l);
683  soundcard_writeframe(o, (short *) o->oss_write_buf);
684  src += l;
685  o->oss_write_dst = 0;
686  } else { /* copy residue */
687  l = f->datalen - src;
688  memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l);
689  src += l; /* but really, we are done */
690  o->oss_write_dst += l;
691  }
692  }
693  return 0;
694 }
void * ptr
Definition: frame.h:160
char oss_write_buf[FRAME_SIZE *2]
Definition: chan_oss.c:293
int datalen
Definition: frame.h:148
descriptor for one of our channels.
Definition: chan_oss.c:247
int oss_write_dst
Definition: chan_oss.c:294
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
union ast_frame::@172 data
static int soundcard_writeframe(struct chan_oss_pvt *o, short *data)
Definition: chan_oss.c:443
static int setformat ( struct chan_oss_pvt o,
int  mode 
)
static

reset and close the device if opened, then open and initialize it in the desired mode, trigger reads and writes so we can start using it.

Definition at line 472 of file chan_oss.c.

References ast_channel_set_fd(), ast_log(), ast_tvdiff_ms(), ast_tvnow(), ast_verb, DEFAULT_SAMPLE_RATE, chan_oss_pvt::device, chan_oss_pvt::duplex, errno, chan_oss_pvt::frags, chan_oss_pvt::lastopen, LOG_WARNING, O_CLOSE, chan_oss_pvt::owner, chan_oss_pvt::sounddev, WARN_frag, WARN_speed, and chan_oss_pvt::warned.

Referenced by console_hangup(), oss_hangup(), oss_new(), soundcard_writeframe(), and store_config().

473 {
474  int fmt, desired, res, fd;
475 
476  if (o->sounddev >= 0) {
477  ioctl(o->sounddev, SNDCTL_DSP_RESET, 0);
478  close(o->sounddev);
479  o->duplex = M_UNSET;
480  o->sounddev = -1;
481  }
482  if (mode == O_CLOSE) /* we are done */
483  return 0;
484  if (ast_tvdiff_ms(ast_tvnow(), o->lastopen) < 1000)
485  return -1; /* don't open too often */
486  o->lastopen = ast_tvnow();
487  fd = o->sounddev = open(o->device, mode | O_NONBLOCK);
488  if (fd < 0) {
489  ast_log(LOG_WARNING, "Unable to re-open DSP device %s: %s\n", o->device, strerror(errno));
490  return -1;
491  }
492  if (o->owner)
493  ast_channel_set_fd(o->owner, 0, fd);
494 
495 #if __BYTE_ORDER == __LITTLE_ENDIAN
496  fmt = AFMT_S16_LE;
497 #else
498  fmt = AFMT_S16_BE;
499 #endif
500  res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
501  if (res < 0) {
502  ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");
503  return -1;
504  }
505  switch (mode) {
506  case O_RDWR:
507  res = ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
508  /* Check to see if duplex set (FreeBSD Bug) */
509  res = ioctl(fd, SNDCTL_DSP_GETCAPS, &fmt);
510  if (res == 0 && (fmt & DSP_CAP_DUPLEX)) {
511  ast_verb(2, "Console is full duplex\n");
512  o->duplex = M_FULL;
513  };
514  break;
515 
516  case O_WRONLY:
517  o->duplex = M_WRITE;
518  break;
519 
520  case O_RDONLY:
521  o->duplex = M_READ;
522  break;
523  }
524 
525  fmt = 0;
526  res = ioctl(fd, SNDCTL_DSP_STEREO, &fmt);
527  if (res < 0) {
528  ast_log(LOG_WARNING, "Failed to set audio device to mono\n");
529  return -1;
530  }
531  fmt = desired = DEFAULT_SAMPLE_RATE; /* 8000 Hz desired */
532  res = ioctl(fd, SNDCTL_DSP_SPEED, &fmt);
533 
534  if (res < 0) {
535  ast_log(LOG_WARNING, "Failed to set sample rate to %d\n", desired);
536  return -1;
537  }
538  if (fmt != desired) {
539  if (!(o->warned & WARN_speed)) {
541  "Requested %d Hz, got %d Hz -- sound may be choppy\n",
542  desired, fmt);
543  o->warned |= WARN_speed;
544  }
545  }
546  /*
547  * on Freebsd, SETFRAGMENT does not work very well on some cards.
548  * Default to use 256 bytes, let the user override
549  */
550  if (o->frags) {
551  fmt = o->frags;
552  res = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fmt);
553  if (res < 0) {
554  if (!(o->warned & WARN_frag)) {
556  "Unable to set fragment size -- sound may be choppy\n");
557  o->warned |= WARN_frag;
558  }
559  }
560  }
561  /* on some cards, we need SNDCTL_DSP_SETTRIGGER to start outputting */
562  res = PCM_ENABLE_INPUT | PCM_ENABLE_OUTPUT;
563  res = ioctl(fd, SNDCTL_DSP_SETTRIGGER, &res);
564  /* it may fail if we are in half duplex, never mind */
565  return 0;
566 }
enum chan_oss_pvt::@98 duplex
#define DEFAULT_SAMPLE_RATE
Definition: asterisk.h:41
#define WARN_speed
Definition: chan_oss.c:263
#define O_CLOSE
Definition: chan_oss.c:227
#define LOG_WARNING
Definition: logger.h:144
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
#define ast_verb(level,...)
Definition: logger.h:243
#define WARN_frag
Definition: chan_oss.c:264
unsigned int frags
Definition: chan_oss.c:259
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
struct ast_channel * owner
Definition: chan_oss.c:281
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
int sounddev
Definition: chan_oss.c:252
char device[64]
Definition: chan_oss.c:277
struct timeval lastopen
Definition: chan_oss.c:266
static int soundcard_writeframe ( struct chan_oss_pvt o,
short *  data 
)
static

Write an exactly FRAME_SIZE sized frame

Definition at line 443 of file chan_oss.c.

References ast_log(), FRAME_SIZE, LOG_WARNING, chan_oss_pvt::queuesize, setformat(), chan_oss_pvt::sounddev, used_blocks(), and chan_oss_pvt::w_errors.

Referenced by oss_write().

444 {
445  int res;
446 
447  if (o->sounddev < 0)
448  setformat(o, O_RDWR);
449  if (o->sounddev < 0)
450  return 0; /* not fatal */
451  /*
452  * Nothing complex to manage the audio device queue.
453  * If the buffer is full just drop the extra, otherwise write.
454  * XXX in some cases it might be useful to write anyways after
455  * a number of failures, to restart the output chain.
456  */
457  res = used_blocks(o);
458  if (res > o->queuesize) { /* no room to write a block */
459  if (o->w_errors++ == 0 && (oss_debug & 0x4))
460  ast_log(LOG_WARNING, "write: used %d blocks (%d)\n", res, o->w_errors);
461  return 0;
462  }
463  o->w_errors = 0;
464  return write(o->sounddev, (void *)data, FRAME_SIZE * 2);
465 }
int w_errors
Definition: chan_oss.c:265
unsigned int queuesize
Definition: chan_oss.c:258
#define LOG_WARNING
Definition: logger.h:144
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:472
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static int used_blocks(struct chan_oss_pvt *o)
Returns the number of blocks used in the audio output channel.
Definition: chan_oss.c:421
#define FRAME_SIZE
Definition: chan_oss.c:209
int sounddev
Definition: chan_oss.c:252
static int oss_debug
Definition: chan_oss.c:237
static void store_boost ( struct chan_oss_pvt o,
const char *  s 
)
static

store the boost factor

Definition at line 1246 of file chan_oss.c.

References ast_log(), chan_oss_pvt::boost, BOOST_MAX, BOOST_SCALE, and LOG_WARNING.

Referenced by console_boost(), and store_config_core().

1247 {
1248  double boost = 0;
1249  if (sscanf(s, "%30lf", &boost) != 1) {
1250  ast_log(LOG_WARNING, "invalid boost <%s>\n", s);
1251  return;
1252  }
1253  if (boost < -BOOST_MAX) {
1254  ast_log(LOG_WARNING, "boost %s too small, using %d\n", s, -BOOST_MAX);
1255  boost = -BOOST_MAX;
1256  } else if (boost > BOOST_MAX) {
1257  ast_log(LOG_WARNING, "boost %s too large, using %d\n", s, BOOST_MAX);
1258  boost = BOOST_MAX;
1259  }
1260  boost = exp(log(10) * boost / 20) * BOOST_SCALE;
1261  o->boost = boost;
1262  ast_log(LOG_WARNING, "setting boost %s to %d\n", s, o->boost);
1263 }
#define LOG_WARNING
Definition: logger.h:144
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define BOOST_MAX
Definition: chan_oss.c:275
#define BOOST_SCALE
Definition: chan_oss.c:274
static void store_callerid ( struct chan_oss_pvt o,
const char *  s 
)
static

store the callerid components

Definition at line 1325 of file chan_oss.c.

References ast_callerid_split(), chan_oss_pvt::cid_name, and chan_oss_pvt::cid_num.

Referenced by store_config_core().

1326 {
1327  ast_callerid_split(s, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
1328 }
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1093
char cid_name[256]
Definition: chan_oss.c:288
char cid_num[256]
Definition: chan_oss.c:289
static struct chan_oss_pvt* store_config ( struct ast_config cfg,
char *  ctg 
)
static

grab fields from the config file, init the descriptor and open the device.

Definition at line 1361 of file chan_oss.c.

References ast_asprintf, ast_calloc, ast_copy_string(), ast_free, ast_log(), ast_strdup, ast_strlen_zero(), ast_tvnow(), ast_variable_browse(), ast_verb, console_video_start(), DEV_DSP, chan_oss_pvt::device, chan_oss_pvt::duplex, chan_oss_pvt::env, errno, get_gui_startup(), chan_oss_pvt::lastopen, LOG_WARNING, chan_oss_pvt::M_FULL, chan_oss_pvt::mixer_cmd, chan_oss_pvt::mohinterpret, ast_variable::name, chan_oss_pvt::name, ast_variable::next, chan_oss_pvt::next, oss_default, setformat(), store_config_core(), and ast_variable::value.

Referenced by load_module().

1362 {
1363  struct ast_variable *v;
1364  struct chan_oss_pvt *o;
1365 
1366  if (ctg == NULL) {
1367  o = &oss_default;
1368  ctg = "general";
1369  } else {
1370  if (!(o = ast_calloc(1, sizeof(*o))))
1371  return NULL;
1372  *o = oss_default;
1373  /* "general" is also the default thing */
1374  if (strcmp(ctg, "general") == 0) {
1375  o->name = ast_strdup("dsp");
1376  oss_active = o->name;
1377  goto openit;
1378  }
1379  o->name = ast_strdup(ctg);
1380  }
1381 
1382  strcpy(o->mohinterpret, "default");
1383 
1384  o->lastopen = ast_tvnow(); /* don't leave it 0 or tvdiff may wrap */
1385  /* fill other fields from configuration */
1386  for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
1387  store_config_core(o, v->name, v->value);
1388  }
1389  if (ast_strlen_zero(o->device))
1390  ast_copy_string(o->device, DEV_DSP, sizeof(o->device));
1391  if (o->mixer_cmd) {
1392  char *cmd;
1393 
1394  if (ast_asprintf(&cmd, "mixer %s", o->mixer_cmd) >= 0) {
1395  ast_log(LOG_WARNING, "running [%s]\n", cmd);
1396  if (system(cmd) < 0) {
1397  ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno));
1398  }
1399  ast_free(cmd);
1400  }
1401  }
1402 
1403  /* if the config file requested to start the GUI, do it */
1404  if (get_gui_startup(o->env))
1405  console_video_start(o->env, NULL);
1406 
1407  if (o == &oss_default) /* we are done with the default */
1408  return NULL;
1409 
1410 openit:
1411 #ifdef TRYOPEN
1412  if (setformat(o, O_RDWR) < 0) { /* open device */
1413  ast_verb(1, "Device %s not detected\n", ctg);
1414  ast_verb(1, "Turn off OSS support by adding " "'noload=chan_oss.so' in /etc/asterisk/modules.conf\n");
1415  goto error;
1416  }
1417  if (o->duplex != M_FULL)
1418  ast_log(LOG_WARNING, "XXX I don't work right with non " "full-duplex sound cards XXX\n");
1419 #endif /* TRYOPEN */
1420 
1421  /* link into list of devices */
1422  if (o != &oss_default) {
1423  o->next = oss_default.next;
1424  oss_default.next = o;
1425  }
1426  return o;
1427 
1428 #ifdef TRYOPEN
1429 error:
1430  if (o != &oss_default)
1431  ast_free(o);
1432  return NULL;
1433 #endif
1434 }
struct chan_oss_pvt * next
Definition: chan_oss.c:248
enum chan_oss_pvt::@98 duplex
#define ast_strdup(a)
Definition: astmm.h:109
static char * oss_active
Definition: chan_oss.c:306
#define LOG_WARNING
Definition: logger.h:144
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
void console_video_start(struct video_desc *env, struct ast_channel *owner)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_verb(level,...)
Definition: logger.h:243
#define ast_asprintf(a, b, c...)
Definition: astmm.h:121
const char * value
Definition: config.h:79
#define DEV_DSP
Definition: chan_oss.c:232
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:472
const char * name
Definition: config.h:77
descriptor for one of our channels.
Definition: chan_oss.c:247
char * mixer_cmd
Definition: chan_oss.c:257
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
#define ast_free(a)
Definition: astmm.h:97
char * name
Definition: chan_oss.c:250
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:290
#define ast_calloc(a, b)
Definition: astmm.h:82
int get_gui_startup(struct video_desc *env)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
struct video_desc * env
Definition: chan_oss.c:283
struct ast_variable * next
Definition: config.h:82
char device[64]
Definition: chan_oss.c:277
struct timeval lastopen
Definition: chan_oss.c:266
static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value)
Definition: chan_oss.c:1330
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:314
static void store_config_core ( struct chan_oss_pvt o,
const char *  var,
const char *  value 
)
static

Definition at line 1330 of file chan_oss.c.

References ast_jb_read_conf(), chan_oss_pvt::autoanswer, chan_oss_pvt::autohangup, console_video_config(), chan_oss_pvt::ctx, CV_BOOL, CV_END, CV_F, CV_START, CV_STR, CV_UINT, chan_oss_pvt::device, chan_oss_pvt::env, chan_oss_pvt::ext, chan_oss_pvt::frags, global_jbconf, chan_oss_pvt::language, chan_oss_pvt::mohinterpret, chan_oss_pvt::overridecontext, chan_oss_pvt::queuesize, store_boost(), store_callerid(), and store_mixer().

Referenced by console_cmd(), and store_config().

1331 {
1332  CV_START(var, value);
1333 
1334  /* handle jb conf */
1336  return;
1337 
1338  if (!console_video_config(&o->env, var, value))
1339  return; /* matched there */
1340  CV_BOOL("autoanswer", o->autoanswer);
1341  CV_BOOL("autohangup", o->autohangup);
1342  CV_BOOL("overridecontext", o->overridecontext);
1343  CV_STR("device", o->device);
1344  CV_UINT("frags", o->frags);
1345  CV_UINT("debug", oss_debug);
1346  CV_UINT("queuesize", o->queuesize);
1347  CV_STR("context", o->ctx);
1348  CV_STR("language", o->language);
1349  CV_STR("mohinterpret", o->mohinterpret);
1350  CV_STR("extension", o->ext);
1351  CV_F("mixer", store_mixer(o, value));
1352  CV_F("callerid", store_callerid(o, value)) ;
1353  CV_F("boost", store_boost(o, value));
1354 
1355  CV_END;
1356 }
static void store_mixer(struct chan_oss_pvt *o, const char *s)
Definition: chan_oss.c:1306
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:286
unsigned int queuesize
Definition: chan_oss.c:258
#define CV_STR(__x, __dst)
Definition: config.h:744
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Definition: abstract_jb.c:577
#define CV_UINT(__x, __dst)
Definition: config.h:743
#define var
Definition: ast_expr2f.c:606
int autohangup
Definition: chan_oss.c:255
int value
Definition: syslog.c:39
int console_video_config(struct video_desc **penv, const char *var, const char *val)
#define CV_END
close a variable parsing block
Definition: config.h:733
#define CV_START(__in_var, __in_val)
the macro to open a block for variable parsing
Definition: config.h:727
unsigned int frags
Definition: chan_oss.c:259
#define CV_BOOL(__x, __dst)
helper macros to assign the value to a BOOL, UINT, static string and dynamic string ...
Definition: config.h:742
static void store_callerid(struct chan_oss_pvt *o, const char *s)
Definition: chan_oss.c:1325
char ext[AST_MAX_EXTENSION]
Definition: chan_oss.c:285
static void store_boost(struct chan_oss_pvt *o, const char *s)
store the boost factor
Definition: chan_oss.c:1246
#define CV_F(__pattern, __body)
call a generic function if the name matches.
Definition: config.h:736
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:290
struct video_desc * env
Definition: chan_oss.c:283
char device[64]
Definition: chan_oss.c:277
int overridecontext
Definition: chan_oss.c:268
int autoanswer
Definition: chan_oss.c:254
static int oss_debug
Definition: chan_oss.c:237
char language[MAX_LANGUAGE]
Definition: chan_oss.c:287
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:79
static void store_mixer ( struct chan_oss_pvt o,
const char *  s 
)
static

store the mixer argument from the config file, filtering possibly invalid or dangerous values (the string is used as argument for system("mixer %s")

Definition at line 1306 of file chan_oss.c.

References ast_free, ast_log(), ast_strdup, LOG_WARNING, and chan_oss_pvt::mixer_cmd.

Referenced by store_config_core().

1307 {
1308  int i;
1309 
1310  for (i = 0; i < strlen(s); i++) {
1311  if (!isalnum(s[i]) && strchr(" \t-/", s[i]) == NULL) {
1312  ast_log(LOG_WARNING, "Suspect char %c in mixer cmd, ignoring:\n\t%s\n", s[i], s);
1313  return;
1314  }
1315  }
1316  if (o->mixer_cmd)
1317  ast_free(o->mixer_cmd);
1318  o->mixer_cmd = ast_strdup(s);
1319  ast_log(LOG_WARNING, "setting mixer %s\n", s);
1320 }
#define ast_strdup(a)
Definition: astmm.h:109
#define LOG_WARNING
Definition: logger.h:144
char * mixer_cmd
Definition: chan_oss.c:257
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
static int unload_module ( void  )
static

Definition at line 1480 of file chan_oss.c.

References ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_free, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, chan_oss_pvt::name, chan_oss_pvt::next, chan_oss_pvt::owner, and chan_oss_pvt::sounddev.

1481 {
1482  struct chan_oss_pvt *o, *next;
1483 
1486 
1487  o = oss_default.next;
1488  while (o) {
1489  close(o->sounddev);
1490  if (o->owner)
1492  if (o->owner)
1493  return -1;
1494  next = o->next;
1495  ast_free(o->name);
1496  ast_free(o);
1497  o = next;
1498  }
1499  return 0;
1500 }
struct chan_oss_pvt * next
Definition: chan_oss.c:248
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: cli.c:2177
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:346
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:938
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
Definition: channel.c:2746
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct ast_cli_entry cli_oss[]
Definition: chan_oss.c:1287
#define ast_free(a)
Definition: astmm.h:97
struct ast_channel * owner
Definition: chan_oss.c:281
char * name
Definition: chan_oss.c:250
int sounddev
Definition: chan_oss.c:252
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:314
static int used_blocks ( struct chan_oss_pvt o)
static

Returns the number of blocks used in the audio output channel.

Definition at line 421 of file chan_oss.c.

References ast_log(), LOG_WARNING, chan_oss_pvt::sounddev, chan_oss_pvt::total_blocks, WARN_used_blocks, and chan_oss_pvt::warned.

Referenced by soundcard_writeframe().

422 {
423  struct audio_buf_info info;
424 
425  if (ioctl(o->sounddev, SNDCTL_DSP_GETOSPACE, &info)) {
426  if (!(o->warned & WARN_used_blocks)) {
427  ast_log(LOG_WARNING, "Error reading output space\n");
428  o->warned |= WARN_used_blocks;
429  }
430  return 1;
431  }
432 
433  if (o->total_blocks == 0) {
434  if (0) /* debugging */
435  ast_log(LOG_WARNING, "fragtotal %d size %d avail %d\n", info.fragstotal, info.fragsize, info.fragments);
436  o->total_blocks = info.fragments;
437  }
438 
439  return o->total_blocks - info.fragments;
440 }
#define LOG_WARNING
Definition: logger.h:144
int total_blocks
Definition: chan_oss.c:251
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int sounddev
Definition: chan_oss.c:252
#define WARN_used_blocks
Definition: chan_oss.c:262

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "OSS Console Channel Driver" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 1502 of file chan_oss.c.

Definition at line 1502 of file chan_oss.c.

struct ast_cli_entry cli_oss[]
static

Definition at line 1287 of file chan_oss.c.

char* config = "oss.conf"
static

Definition at line 235 of file chan_oss.c.

struct ast_jb_conf default_jbconf
static

Global jitterbuffer configuration - by default, jb is disabled

Note
Values shown here match the defaults shown in oss.conf.sample

Definition at line 71 of file chan_oss.c.

struct ast_jb_conf global_jbconf
static

Definition at line 79 of file chan_oss.c.

Referenced by load_module(), oss_new(), and store_config_core().

char* oss_active
static

the active device

Definition at line 306 of file chan_oss.c.

Referenced by keypad_toggle().

int oss_debug
static

Definition at line 237 of file chan_oss.c.

struct chan_oss_pvt oss_default
static

Definition at line 314 of file chan_oss.c.

Referenced by store_config().

struct ast_channel_tech oss_tech
static

Definition at line 346 of file chan_oss.c.

Referenced by oss_new().

char tdesc[] = "OSS Console Channel Driver"
static

Definition at line 343 of file chan_oss.c.