Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
Data Structures | Macros | Functions | Variables
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 "asterisk/bridge.h"
#include "asterisk/format_cache.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 char * ast_ext_ctx (const char *src, char **ext, char **ctx)
 
 AST_MODULE_INFO_STANDARD_DEPRECATED (ASTERISK_GPL_KEY, "OSS Console Channel Driver")
 
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)
 Load the module. More...
 
static int oss_answer (struct ast_channel *c)
 remote side answered the phone More...
 
static int oss_call (struct ast_channel *c, const 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 struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
 allocate a new channel. More...
 
static struct ast_frameoss_read (struct ast_channel *chan)
 
static struct ast_channeloss_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *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_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

Definition in file chan_oss.c.

Macro Definition Documentation

◆ BOOST_MAX

#define BOOST_MAX   40

slightly less than 7 bits

Definition at line 285 of file chan_oss.c.

Referenced by store_boost().

◆ BOOST_SCALE

#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 284 of file chan_oss.c.

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

◆ DEV_DSP

#define DEV_DSP   "/dev/dsp"

Definition at line 237 of file chan_oss.c.

Referenced by store_config().

◆ FRAGS

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

Definition at line 220 of file chan_oss.c.

◆ FRAME_SIZE

#define FRAME_SIZE   160

Definition at line 214 of file chan_oss.c.

Referenced by oss_read(), and soundcard_writeframe().

◆ O_CLOSE

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

Definition at line 232 of file chan_oss.c.

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

◆ QUEUE_SIZE

#define QUEUE_SIZE   10

Definition at line 215 of file chan_oss.c.

◆ TEXT_SIZE

#define TEXT_SIZE   256

Definition at line 227 of file chan_oss.c.

Referenced by console_sendtext().

◆ WARN_frag

#define WARN_frag   4

Definition at line 274 of file chan_oss.c.

Referenced by setformat().

◆ WARN_speed

#define WARN_speed   2

Definition at line 273 of file chan_oss.c.

Referenced by setformat().

◆ WARN_used_blocks

#define WARN_used_blocks   1

Definition at line 272 of file chan_oss.c.

Referenced by used_blocks().

Function Documentation

◆ ast_ext_ctx()

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

Definition at line 402 of file chan_oss.c.

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

Referenced by console_dial(), and console_transfer().

403 {
404  struct chan_oss_pvt *o = find_desc(oss_active);
405 
406  if (ext == NULL || ctx == NULL)
407  return NULL; /* error */
408 
409  *ext = *ctx = NULL;
410 
411  if (src && *src != '\0')
412  *ext = ast_strdup(src);
413 
414  if (*ext == NULL)
415  return NULL;
416 
417  if (!o->overridecontext) {
418  /* parse from the right */
419  *ctx = strrchr(*ext, '@');
420  if (*ctx)
421  *(*ctx)++ = '\0';
422  }
423 
424  return *ext;
425 }
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:296
static char * oss_active
Definition: chan_oss.c:316
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
const char * ext
Definition: http.c:147
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
int overridecontext
Definition: chan_oss.c:278

◆ AST_MODULE_INFO_STANDARD_DEPRECATED()

AST_MODULE_INFO_STANDARD_DEPRECATED ( ASTERISK_GPL_KEY  ,
"OSS Console Channel Driver"   
)

Referenced by load_module().

◆ console_active()

static char* console_active ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1215 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, NULL, oss_active, and ast_cli_entry::usage.

1216 {
1217  switch (cmd) {
1218  case CLI_INIT:
1219  e->command = "console {set|show} active [<device>]";
1220  e->usage =
1221  "Usage: console active [device]\n"
1222  " If used without a parameter, displays which device is the current\n"
1223  " console. If a device is specified, the console sound device is changed to\n"
1224  " the device specified.\n";
1225  return NULL;
1226  case CLI_GENERATE:
1227  return NULL;
1228  }
1229 
1230  if (a->argc == 3)
1231  ast_cli(a->fd, "active console is [%s]\n", oss_active);
1232  else if (a->argc != 4)
1233  return CLI_SHOWUSAGE;
1234  else {
1235  struct chan_oss_pvt *o;
1236  if (strcmp(a->argv[3], "show") == 0) {
1237  for (o = oss_default.next; o; o = o->next)
1238  ast_cli(a->fd, "device [%s] exists\n", o->name);
1239  return CLI_SUCCESS;
1240  }
1241  o = find_desc(a->argv[3]);
1242  if (o == NULL)
1243  ast_cli(a->fd, "No device [%s] exists\n", a->argv[3]);
1244  else
1245  oss_active = o->name;
1246  }
1247  return CLI_SUCCESS;
1248 }
struct chan_oss_pvt * next
Definition: chan_oss.c:253
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const int fd
Definition: cli.h:159
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
char * name
Definition: chan_oss.c:255
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:324

◆ console_answer()

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 983 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, NULL, and ast_cli_entry::usage.

984 {
985  switch (cmd) {
986  case CLI_INIT:
987  e->command = "console answer";
988  e->usage =
989  "Usage: console answer\n"
990  " Answers an incoming call on the console (OSS) channel.\n";
991  return NULL;
992 
993  case CLI_GENERATE:
994  return NULL; /* no completion */
995  }
996  if (a->argc != e->args)
997  return CLI_SHOWUSAGE;
998  return console_do_answer(a->fd);
999 }
const int argc
Definition: cli.h:160
static char * console_do_answer(int fd)
helper function for the answer key/cli command
Definition: chan_oss.c:966
Definition: cli.h:152
#define NULL
Definition: resample.c:96
int args
This gets set in ast_cli_register()
Definition: cli.h:185
const int fd
Definition: cli.h:159
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177

◆ console_autoanswer()

static char* console_autoanswer ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 927 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, NULL, oss_active, and ast_cli_entry::usage.

928 {
929  struct chan_oss_pvt *o = find_desc(oss_active);
930 
931  switch (cmd) {
932  case CLI_INIT:
933  e->command = "console {set|show} autoanswer [on|off]";
934  e->usage =
935  "Usage: console {set|show} autoanswer [on|off]\n"
936  " Enables or disables autoanswer feature. If used without\n"
937  " argument, displays the current on/off status of autoanswer.\n"
938  " The default value of autoanswer is in 'oss.conf'.\n";
939  return NULL;
940 
941  case CLI_GENERATE:
942  return NULL;
943  }
944 
945  if (a->argc == e->args - 1) {
946  ast_cli(a->fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
947  return CLI_SUCCESS;
948  }
949  if (a->argc != e->args)
950  return CLI_SHOWUSAGE;
951  if (o == NULL) {
952  ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
953  oss_active);
954  return CLI_FAILURE;
955  }
956  if (!strcasecmp(a->argv[e->args-1], "on"))
957  o->autoanswer = 1;
958  else if (!strcasecmp(a->argv[e->args - 1], "off"))
959  o->autoanswer = 0;
960  else
961  return CLI_SHOWUSAGE;
962  return CLI_SUCCESS;
963 }
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
#define LOG_WARNING
Definition: logger.h:274
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int args
This gets set in ast_cli_register()
Definition: cli.h:185
#define ast_log
Definition: astobj2.c:42
const int fd
Definition: cli.h:159
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
int autoanswer
Definition: chan_oss.c:264

◆ console_boost()

static char* console_boost ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1272 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(), NULL, oss_active, store_boost(), and ast_cli_entry::usage.

1273 {
1274  struct chan_oss_pvt *o = find_desc(oss_active);
1275 
1276  switch (cmd) {
1277  case CLI_INIT:
1278  e->command = "console boost";
1279  e->usage =
1280  "Usage: console boost [boost in dB]\n"
1281  " Sets or display mic boost in dB\n";
1282  return NULL;
1283  case CLI_GENERATE:
1284  return NULL;
1285  }
1286 
1287  if (a->argc == 2)
1288  ast_cli(a->fd, "boost currently %5.1f\n", 20 * log10(((double) o->boost / (double) BOOST_SCALE)));
1289  else if (a->argc == 3)
1290  store_boost(o, a->argv[2]);
1291  return CLI_SUCCESS;
1292 }
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const int fd
Definition: cli.h:159
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static void store_boost(struct chan_oss_pvt *o, const char *s)
store the boost factor
Definition: chan_oss.c:1253
#define CLI_SUCCESS
Definition: cli.h:44
#define BOOST_SCALE
Definition: chan_oss.c:284

◆ console_cmd()

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 891 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, NULL, oss_active, store_config_core(), ast_cli_entry::usage, value, and var.

892 {
893  struct chan_oss_pvt *o = find_desc(oss_active);
894  const char *var, *value;
895  switch (cmd) {
896  case CLI_INIT:
898  e->usage =
899  "Usage: " CONSOLE_VIDEO_CMDS "...\n"
900  " Generic handler for console commands.\n";
901  return NULL;
902 
903  case CLI_GENERATE:
904  return NULL;
905  }
906 
907  if (a->argc < e->args)
908  return CLI_SHOWUSAGE;
909  if (o == NULL) {
910  ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
911  oss_active);
912  return CLI_FAILURE;
913  }
914  var = a->argv[e->args-1];
915  value = a->argc > e->args ? a->argv[e->args] : NULL;
916  if (value) /* handle setting */
917  store_config_core(o, var, value);
918  if (!console_video_cli(o->env, var, a->fd)) /* print video-related values */
919  return CLI_SUCCESS;
920  /* handle other values */
921  if (!strcasecmp(var, "device")) {
922  ast_cli(a->fd, "device is [%s]\n", o->device);
923  }
924  return CLI_SUCCESS;
925 }
#define CONSOLE_VIDEO_CMDS
Definition: console_video.h:27
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
#define LOG_WARNING
Definition: logger.h:274
#define var
Definition: ast_expr2f.c:614
Definition: cli.h:152
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int args
This gets set in ast_cli_register()
Definition: cli.h:185
#define ast_log
Definition: astobj2.c:42
const int fd
Definition: cli.h:159
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
int console_video_cli(struct video_desc *env, const char *var, int fd)
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
struct video_desc * env
Definition: chan_oss.c:293
char device[64]
Definition: chan_oss.c:287
static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value)
Definition: chan_oss.c:1337

◆ console_dial()

static char* console_dial ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1093 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, NULL, oss_active, oss_new(), chan_oss_pvt::owner, ast_frame::subclass, and ast_cli_entry::usage.

1094 {
1095  char *s = NULL;
1096  char *mye = NULL, *myc = NULL;
1097  struct chan_oss_pvt *o = find_desc(oss_active);
1098 
1099  if (cmd == CLI_INIT) {
1100  e->command = "console dial";
1101  e->usage =
1102  "Usage: console dial [extension[@context]]\n"
1103  " Dials a given extension (and context if specified)\n";
1104  return NULL;
1105  } else if (cmd == CLI_GENERATE)
1106  return NULL;
1107 
1108  if (a->argc > e->args + 1)
1109  return CLI_SHOWUSAGE;
1110  if (o->owner) { /* already in a call */
1111  int i;
1112  struct ast_frame f = { AST_FRAME_DTMF, { 0 } };
1113  const char *digits;
1114 
1115  if (a->argc == e->args) { /* argument is mandatory here */
1116  ast_cli(a->fd, "Already in a call. You can only dial digits until you hangup.\n");
1117  return CLI_FAILURE;
1118  }
1119  digits = a->argv[e->args];
1120  /* send the string one char at a time */
1121  for (i = 0; i < strlen(digits); i++) {
1122  f.subclass.integer = digits[i];
1123  ast_queue_frame(o->owner, &f);
1124  }
1125  return CLI_SUCCESS;
1126  }
1127  /* if we have an argument split it into extension and context */
1128  if (a->argc == e->args + 1)
1129  s = ast_ext_ctx(a->argv[e->args], &mye, &myc);
1130  /* supply default values if needed */
1131  if (mye == NULL)
1132  mye = o->ext;
1133  if (myc == NULL)
1134  myc = o->ctx;
1135  if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
1136  o->hookstate = 1;
1137  oss_new(o, mye, myc, AST_STATE_RINGING, NULL, NULL);
1138  } else
1139  ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
1140  if (s)
1141  ast_free(s);
1142  return CLI_SUCCESS;
1143 }
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:296
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
static char * ast_ext_ctx(const char *src, char **ext, char **ctx)
Definition: chan_oss.c:402
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define AST_FRAME_DTMF
struct ast_frame_subclass subclass
int args
This gets set in ast_cli_register()
Definition: cli.h:185
const int fd
Definition: cli.h:159
int hookstate
Definition: chan_oss.c:266
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:4170
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:1135
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_FAILURE
Definition: cli.h:46
#define ast_free(a)
Definition: astmm.h:182
char * command
Definition: cli.h:186
char ext[AST_MAX_EXTENSION]
Definition: chan_oss.c:295
struct ast_channel * owner
Definition: chan_oss.c:291
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
Data structure associated with a single frame of data.
static struct ast_channel * oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
allocate a new channel.
Definition: chan_oss.c:799

◆ console_do_answer()

static char* console_do_answer ( int  fd)
static

helper function for the answer key/cli command

Definition at line 966 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, oss_active, and chan_oss_pvt::owner.

Referenced by console_answer(), and keypad_cfg_read().

967 {
968  struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_ANSWER } };
969  struct chan_oss_pvt *o = find_desc(oss_active);
970  if (!o->owner) {
971  if (fd > -1)
972  ast_cli(fd, "No one is calling us\n");
973  return CLI_FAILURE;
974  }
975  o->hookstate = 1;
976  ast_queue_frame(o->owner, &f);
977  return CLI_SUCCESS;
978 }
static char * oss_active
Definition: chan_oss.c:316
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int hookstate
Definition: chan_oss.c:266
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:1135
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
#define CLI_FAILURE
Definition: cli.h:46
struct ast_channel * owner
Definition: chan_oss.c:291
#define CLI_SUCCESS
Definition: cli.h:44
Data structure associated with a single frame of data.

◆ console_flash()

static char* console_flash ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1067 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, NULL, oss_active, chan_oss_pvt::owner, and ast_cli_entry::usage.

1068 {
1069  struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH } };
1070  struct chan_oss_pvt *o = find_desc(oss_active);
1071 
1072  if (cmd == CLI_INIT) {
1073  e->command = "console flash";
1074  e->usage =
1075  "Usage: console flash\n"
1076  " Flashes the call currently placed on the console.\n";
1077  return NULL;
1078  } else if (cmd == CLI_GENERATE)
1079  return NULL;
1080 
1081  if (a->argc != e->args)
1082  return CLI_SHOWUSAGE;
1083  if (!o->owner) { /* XXX maybe !o->hookstate too ? */
1084  ast_cli(a->fd, "No call to flash\n");
1085  return CLI_FAILURE;
1086  }
1087  o->hookstate = 0;
1088  if (o->owner)
1089  ast_queue_frame(o->owner, &f);
1090  return CLI_SUCCESS;
1091 }
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int args
This gets set in ast_cli_register()
Definition: cli.h:185
const int fd
Definition: cli.h:159
int hookstate
Definition: chan_oss.c:266
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:1135
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
struct ast_channel * owner
Definition: chan_oss.c:291
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
Data structure associated with a single frame of data.

◆ console_hangup()

static char* console_hangup ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1041 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, NULL, O_CLOSE, oss_active, chan_oss_pvt::owner, setformat(), and ast_cli_entry::usage.

1042 {
1043  struct chan_oss_pvt *o = find_desc(oss_active);
1044 
1045  if (cmd == CLI_INIT) {
1046  e->command = "console hangup";
1047  e->usage =
1048  "Usage: console hangup\n"
1049  " Hangs up any call currently placed on the console.\n";
1050  return NULL;
1051  } else if (cmd == CLI_GENERATE)
1052  return NULL;
1053 
1054  if (a->argc != e->args)
1055  return CLI_SHOWUSAGE;
1056  if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
1057  ast_cli(a->fd, "No call to hang up\n");
1058  return CLI_FAILURE;
1059  }
1060  o->hookstate = 0;
1061  if (o->owner)
1063  setformat(o, O_CLOSE);
1064  return CLI_SUCCESS;
1065 }
#define O_CLOSE
Definition: chan_oss.c:232
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1162
int args
This gets set in ast_cli_register()
Definition: cli.h:185
const int fd
Definition: cli.h:159
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:481
int hookstate
Definition: chan_oss.c:266
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
struct ast_channel * owner
Definition: chan_oss.c:291
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ console_mute()

static char* console_mute ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1145 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, NULL, oss_active, and ast_cli_entry::usage.

1146 {
1147  struct chan_oss_pvt *o = find_desc(oss_active);
1148  const char *s;
1149  int toggle = 0;
1150 
1151  if (cmd == CLI_INIT) {
1152  e->command = "console {mute|unmute} [toggle]";
1153  e->usage =
1154  "Usage: console {mute|unmute} [toggle]\n"
1155  " Mute/unmute the microphone.\n";
1156  return NULL;
1157  } else if (cmd == CLI_GENERATE)
1158  return NULL;
1159 
1160  if (a->argc > e->args)
1161  return CLI_SHOWUSAGE;
1162  if (a->argc == e->args) {
1163  if (strcasecmp(a->argv[e->args-1], "toggle"))
1164  return CLI_SHOWUSAGE;
1165  toggle = 1;
1166  }
1167  s = a->argv[e->args-2];
1168  if (!strcasecmp(s, "mute"))
1169  o->mute = toggle ? !o->mute : 1;
1170  else if (!strcasecmp(s, "unmute"))
1171  o->mute = toggle ? !o->mute : 0;
1172  else
1173  return CLI_SHOWUSAGE;
1174  ast_cli(a->fd, "Console mic is %s\n", o->mute ? "off" : "on");
1175  return CLI_SUCCESS;
1176 }
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int args
This gets set in ast_cli_register()
Definition: cli.h:185
const int fd
Definition: cli.h:159
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ console_sendtext()

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 1007 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, buf, 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, NULL, oss_active, chan_oss_pvt::owner, ast_frame::ptr, ast_frame::subclass, TEXT_SIZE, and ast_cli_entry::usage.

1008 {
1009  struct chan_oss_pvt *o = find_desc(oss_active);
1010  char buf[TEXT_SIZE];
1011 
1012  if (cmd == CLI_INIT) {
1013  e->command = "console send text";
1014  e->usage =
1015  "Usage: console send text <message>\n"
1016  " Sends a text message for display on the remote terminal.\n";
1017  return NULL;
1018  } else if (cmd == CLI_GENERATE)
1019  return NULL;
1020 
1021  if (a->argc < e->args + 1)
1022  return CLI_SHOWUSAGE;
1023  if (!o->owner) {
1024  ast_cli(a->fd, "Not in a call\n");
1025  return CLI_FAILURE;
1026  }
1027  ast_join(buf, sizeof(buf) - 1, a->argv + e->args);
1028  if (!ast_strlen_zero(buf)) {
1029  struct ast_frame f = { 0, };
1030  int i = strlen(buf);
1031  buf[i] = '\n';
1033  f.subclass.integer = 0;
1034  f.data.ptr = buf;
1035  f.datalen = i + 1;
1036  ast_queue_frame(o->owner, &f);
1037  }
1038  return CLI_SUCCESS;
1039 }
#define TEXT_SIZE
Definition: chan_oss.c:227
#define ast_join(s, len, w)
Definition: strings.h:483
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
struct ast_frame_subclass subclass
int args
This gets set in ast_cli_register()
Definition: cli.h:185
union ast_frame::@255 data
const int fd
Definition: cli.h:159
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:1135
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define ast_strlen_zero(a)
Definition: muted.c:73
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
struct ast_channel * owner
Definition: chan_oss.c:291
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
Data structure associated with a single frame of data.
enum ast_frame_type frametype

◆ console_transfer()

static char* console_transfer ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1178 of file chan_oss.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_bridge_transfer_blind(), AST_BRIDGE_TRANSFER_SUCCESS, ast_channel_context(), ast_channel_is_bridged(), ast_channel_name(), ast_cli(), ast_ext_ctx(), ast_free, ast_log, ast_strdupa, 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(), LOG_WARNING, NULL, oss_active, chan_oss_pvt::owner, tmp(), and ast_cli_entry::usage.

1179 {
1180  struct chan_oss_pvt *o = find_desc(oss_active);
1181  char *tmp, *ext, *ctx;
1182 
1183  switch (cmd) {
1184  case CLI_INIT:
1185  e->command = "console transfer";
1186  e->usage =
1187  "Usage: console transfer <extension>[@context]\n"
1188  " Transfers the currently connected call to the given extension (and\n"
1189  " context if specified)\n";
1190  return NULL;
1191  case CLI_GENERATE:
1192  return NULL;
1193  }
1194 
1195  if (a->argc != 3)
1196  return CLI_SHOWUSAGE;
1197  if (o == NULL)
1198  return CLI_FAILURE;
1199  if (o->owner == NULL || !ast_channel_is_bridged(o->owner)) {
1200  ast_cli(a->fd, "There is no call to transfer\n");
1201  return CLI_SUCCESS;
1202  }
1203 
1204  tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
1205  if (ctx == NULL) { /* supply default context if needed */
1207  }
1209  ast_log(LOG_WARNING, "Unable to transfer call from channel %s\n", ast_channel_name(o->owner));
1210  }
1211  ast_free(tmp);
1212  return CLI_SUCCESS;
1213 }
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:296
static char * oss_active
Definition: chan_oss.c:316
const int argc
Definition: cli.h:160
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
Definition: cli.h:152
static char * ast_ext_ctx(const char *src, char **ext, char **ctx)
Definition: chan_oss.c:402
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const char * ext
Definition: http.c:147
#define ast_log
Definition: astobj2.c:42
enum ast_transfer_result ast_bridge_transfer_blind(int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
Blind transfer target to the extension and context provided.
Definition: bridge.c:4457
const int fd
Definition: cli.h:159
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition: channel.c:10579
#define CLI_FAILURE
Definition: cli.h:46
#define ast_free(a)
Definition: astmm.h:182
char * command
Definition: cli.h:186
struct ast_channel * owner
Definition: chan_oss.c:291
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)

◆ find_desc()

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 376 of file chan_oss.c.

References ast_log, LOG_WARNING, chan_oss_pvt::name, chan_oss_pvt::next, and NULL.

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_cfg_read(), load_module(), and oss_request().

377 {
378  struct chan_oss_pvt *o = NULL;
379 
380  if (!dev)
381  ast_log(LOG_WARNING, "null dev\n");
382 
383  for (o = oss_default.next; o && o->name && dev && strcmp(o->name, dev) != 0; o = o->next);
384 
385  if (!o)
386  ast_log(LOG_WARNING, "could not find <%s>\n", dev ? dev : "--no-device--");
387 
388  return o;
389 }
struct chan_oss_pvt * next
Definition: chan_oss.c:253
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
descriptor for one of our channels.
Definition: chan_oss.c:252
char * name
Definition: chan_oss.c:255
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:324

◆ get_video_desc()

struct video_desc* get_video_desc ( struct ast_channel c)

return the pointer to the video descriptor

Definition at line 319 of file chan_oss.c.

References ast_channel_tech_pvt(), chan_oss_pvt::env, find_desc(), NULL, and oss_active.

Referenced by oss_new().

320 {
322  return o ? o->env : NULL;
323 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
static char * oss_active
Definition: chan_oss.c:316
#define NULL
Definition: resample.c:96
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
struct video_desc * env
Definition: chan_oss.c:293

◆ load_module()

static int load_module ( void  )
static

Load the module.

Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.

Definition at line 1478 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_format_cap_alloc, ast_format_cap_append, ast_format_slin, ast_log, AST_MODULE_INFO_STANDARD_DEPRECATED(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ASTERISK_GPL_KEY, ast_channel_tech::capabilities, config, CONFIG_STATUS_FILEINVALID, find_desc(), global_jbconf, LOG_ERROR, LOG_NOTICE, NULL, oss_active, store_config(), and unload_module().

1479 {
1480  struct ast_config *cfg = NULL;
1481  char *ctg = NULL;
1482  struct ast_flags config_flags = { 0 };
1483 
1484  /* Copy the default jb config over global_jbconf */
1485  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
1486 
1487  /* load config file */
1488  if (!(cfg = ast_config_load(config, config_flags))) {
1489  ast_log(LOG_NOTICE, "Unable to load config %s\n", config);
1490  return AST_MODULE_LOAD_DECLINE;
1491  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
1492  ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
1493  return AST_MODULE_LOAD_DECLINE;
1494  }
1495 
1496  do {
1497  store_config(cfg, ctg);
1498  } while ( (ctg = ast_category_browse(cfg, ctg)) != NULL);
1499 
1500  ast_config_destroy(cfg);
1501 
1502  if (find_desc(oss_active) == NULL) {
1503  ast_log(LOG_NOTICE, "Device %s not found\n", oss_active);
1504  /* XXX we could default to 'dsp' perhaps ? */
1505  unload_module();
1506  return AST_MODULE_LOAD_DECLINE;
1507  }
1508 
1510  return AST_MODULE_LOAD_DECLINE;
1511  }
1513 
1514  /* TODO XXX CONSOLE VIDEO IS DISABLE UNTIL IT HAS A MAINTAINER
1515  * add console_video_formats to oss_tech.capabilities once this occurs. */
1516 
1518  ast_log(LOG_ERROR, "Unable to register channel type 'OSS'\n");
1519  return AST_MODULE_LOAD_DECLINE;
1520  }
1521 
1523 
1524  return AST_MODULE_LOAD_SUCCESS;
1525 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static char * config
Definition: chan_oss.c:240
static int unload_module(void)
Definition: chan_oss.c:1443
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:356
static char * oss_active
Definition: chan_oss.c:316
#define CONFIG_STATUS_FILEINVALID
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
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:535
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3328
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define ast_config_load(filename, flags)
Load a config file.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
static struct ast_cli_entry cli_oss[]
Definition: chan_oss.c:1294
#define LOG_ERROR
Definition: logger.h:285
#define LOG_NOTICE
Definition: logger.h:263
struct ast_format_cap * capabilities
Definition: channel.h:633
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
Structure used to handle boolean flags.
Definition: utils.h:199
static struct ast_jb_conf default_jbconf
Definition: chan_oss.c:76
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
General jitterbuffer configuration.
Definition: abstract_jb.h:69
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:84
static struct chan_oss_pvt * store_config(struct ast_config *cfg, char *ctg)
Definition: chan_oss.c:1368

◆ oss_answer()

static int oss_answer ( struct ast_channel c)
static

remote side answered the phone

Definition at line 645 of file chan_oss.c.

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

646 {
647  struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
648  ast_verbose(" << Console call has been answered >> \n");
650  o->hookstate = 1;
651  return 0;
652 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
int hookstate
Definition: chan_oss.c:266
descriptor for one of our channels.
Definition: chan_oss.c:252
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7325

◆ oss_call()

static int oss_call ( struct ast_channel c,
const char *  dest,
int  timeout 
)
static

handler for incoming calls. Either autoanswer, or start ringing

Definition at line 603 of file chan_oss.c.

References args, AST_APP_ARG, ast_channel_caller(), ast_channel_dialed(), ast_channel_redirecting(), ast_channel_tech_pvt(), 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_frame::flags, chan_oss_pvt::hookstate, ast_frame_subclass::integer, chan_oss_pvt::name, parse(), S_COR, S_OR, and ast_frame::subclass.

604 {
605  struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
606  struct ast_frame f = { AST_FRAME_CONTROL, };
608  AST_APP_ARG(name);
610  );
611  char *parse = ast_strdupa(dest);
612 
613  AST_NONSTANDARD_APP_ARGS(args, parse, '/');
614 
615  ast_verbose(" << Call to device '%s' dnid '%s' rdnis '%s' on console from '%s' <%s> >>\n",
616  dest,
617  S_OR(ast_channel_dialed(c)->number.str, ""),
618  S_COR(ast_channel_redirecting(c)->from.number.valid, ast_channel_redirecting(c)->from.number.str, ""),
619  S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, ""),
620  S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, ""));
621  if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "answer") == 0) {
623  ast_queue_frame(c, &f);
624  } else if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "noanswer") == 0) {
626  ast_queue_frame(c, &f);
628  } else if (o->autoanswer) {
629  ast_verbose(" << Auto-answered >> \n");
631  ast_queue_frame(c, &f);
632  o->hookstate = 1;
633  } else {
634  ast_verbose("<< Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
636  ast_queue_frame(c, &f);
638  }
639  return 0;
640 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4271
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
const char * args
struct ast_frame_subclass subclass
Number structure.
Definition: app_followme.c:154
#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:85
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int hookstate
Definition: chan_oss.c:266
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:1135
descriptor for one of our channels.
Definition: chan_oss.c:252
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
#define ast_strlen_zero(a)
Definition: muted.c:73
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
static const char name[]
Definition: cdr_mysql.c:74
unsigned int flags
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
Data structure associated with a single frame of data.
int autoanswer
Definition: chan_oss.c:264
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ oss_digit_begin()

static int oss_digit_begin ( struct ast_channel c,
char  digit 
)
static

Definition at line 580 of file chan_oss.c.

581 {
582  return 0;
583 }

◆ oss_digit_end()

static int oss_digit_end ( struct ast_channel c,
char  digit,
unsigned int  duration 
)
static

Definition at line 585 of file chan_oss.c.

References ast_verbose().

586 {
587  /* no better use for received digits than print them */
588  ast_verbose(" << Console Received digit %c of duration %u ms >> \n",
589  digit, duration);
590  return 0;
591 }
char digit
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207

◆ oss_fixup()

static int oss_fixup ( struct ast_channel oldchan,
struct ast_channel newchan 
)
static

Definition at line 754 of file chan_oss.c.

References ast_channel_tech_pvt(), and chan_oss_pvt::owner.

755 {
756  struct chan_oss_pvt *o = ast_channel_tech_pvt(newchan);
757  o->owner = newchan;
758  return 0;
759 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
descriptor for one of our channels.
Definition: chan_oss.c:252
struct ast_channel * owner
Definition: chan_oss.c:291

◆ oss_hangup()

static int oss_hangup ( struct ast_channel c)
static

Definition at line 654 of file chan_oss.c.

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

655 {
656  struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
657 
659  o->owner = NULL;
660  ast_verbose(" << Hangup on console >> \n");
663  if (o->hookstate) {
664  if (o->autoanswer || o->autohangup) {
665  /* Assume auto-hangup too */
666  o->hookstate = 0;
667  setformat(o, O_CLOSE);
668  }
669  }
670  return 0;
671 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define O_CLOSE
Definition: chan_oss.c:232
int autohangup
Definition: chan_oss.c:265
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
#define NULL
Definition: resample.c:96
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
struct ast_module * self
Definition: module.h:342
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:481
int hookstate
Definition: chan_oss.c:266
descriptor for one of our channels.
Definition: chan_oss.c:252
struct ast_channel * owner
Definition: chan_oss.c:291
void console_video_uninit(struct video_desc *env)
struct video_desc * env
Definition: chan_oss.c:293
int autoanswer
Definition: chan_oss.c:264
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)

◆ oss_indicate()

static int oss_indicate ( struct ast_channel chan,
int  cond,
const void *  data,
size_t  datalen 
)
static

Definition at line 761 of file chan_oss.c.

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

762 {
763  struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
764  int res = 0;
765 
766  switch (cond) {
768  case AST_CONTROL_BUSY:
770  case AST_CONTROL_RINGING:
772  case -1:
773  res = -1;
774  break;
779  break;
780  case AST_CONTROL_HOLD:
781  ast_verbose(" << Console Has Been Placed on Hold >> \n");
782  ast_moh_start(c, data, o->mohinterpret);
783  break;
784  case AST_CONTROL_UNHOLD:
785  ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
786  ast_moh_stop(c);
787  break;
788  default:
789  ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, ast_channel_name(c));
790  return -1;
791  }
792 
793  return res;
794 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
static struct test_val c
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:7715
#define ast_log
Definition: astobj2.c:42
ast_cond_t cond
Definition: app_meetme.c:1090
descriptor for one of our channels.
Definition: chan_oss.c:252
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:7705
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:300
const char * ast_channel_name(const struct ast_channel *chan)

◆ oss_new()

static struct ast_channel* oss_new ( struct chan_oss_pvt o,
char *  ext,
char *  ctx,
int  state,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor 
)
static

allocate a new channel.

Definition at line 799 of file chan_oss.c.

References ast_party_caller::ani, ast_channel_alloc, ast_channel_caller(), ast_channel_dialed(), ast_channel_name(), ast_channel_nativeformats_set(), ast_channel_set_fd(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_unlock, ast_format_slin, ast_hangup(), ast_jb_configure(), ast_log, ast_module_ref, ast_pbx_start(), AST_STATE_DOWN, ast_strdup, ast_strlen_zero, c, ast_channel_tech::capabilities, chan_oss_pvt::cid_name, chan_oss_pvt::cid_num, console_video_start(), chan_oss_pvt::device, get_video_desc(), global_jbconf, chan_oss_pvt::language, LOG_WARNING, NULL, ast_party_id::number, ast_party_dialed::number, chan_oss_pvt::owner, ast_module_info::self, setformat(), chan_oss_pvt::sounddev, ast_party_number::str, ast_party_dialed::str, and ast_party_number::valid.

Referenced by console_dial(), and oss_request().

800 {
801  struct ast_channel *c;
802 
803  c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, assignedids, requestor, 0, "Console/%s", o->device + 5);
804  if (c == NULL)
805  return NULL;
807  if (o->sounddev < 0)
808  setformat(o, O_RDWR);
809  ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
810 
814 
815  /* if the console makes the call, add video to the offer */
816  /* if (state == AST_STATE_RINGING) TODO XXX CONSOLE VIDEO IS DISABLED UNTIL IT GETS A MAINTAINER
817  c->nativeformats |= console_video_formats; */
818 
820 
821  if (!ast_strlen_zero(o->language))
822  ast_channel_language_set(c, o->language);
823  /* Don't use ast_set_callerid() here because it will
824  * generate a needless NewCallerID event */
825  if (!ast_strlen_zero(o->cid_num)) {
828  }
829  if (!ast_strlen_zero(ext)) {
831  }
832 
833  o->owner = c;
837  if (state != AST_STATE_DOWN) {
838  if (ast_pbx_start(c)) {
839  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(c));
840  ast_hangup(c);
841  o->owner = c = NULL;
842  }
843  }
844  console_video_start(get_video_desc(c), c); /* XXX cleanup */
845 
846  return c;
847 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
Main Channel structure associated with a channel.
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:356
#define LOG_WARNING
Definition: logger.h:274
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:4703
void console_video_start(struct video_desc *env, struct ast_channel *owner)
static struct test_val c
struct ast_party_dialed::@240 number
Dialed/Called number.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
const char * ext
Definition: http.c:147
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_log
Definition: astobj2.c:42
struct ast_module * self
Definition: module.h:342
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:481
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
char cid_name[256]
Definition: chan_oss.c:298
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
struct ast_format_cap * capabilities
Definition: channel.h:633
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_channel_unlock(chan)
Definition: channel.h:2838
char cid_num[256]
Definition: chan_oss.c:299
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2523
struct ast_channel * owner
Definition: chan_oss.c:291
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2406
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
Definition: abstract_jb.c:593
int sounddev
Definition: chan_oss.c:257
const char * ast_channel_name(const struct ast_channel *chan)
char device[64]
Definition: chan_oss.c:287
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1242
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
char language[MAX_LANGUAGE]
Definition: chan_oss.c:297
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct video_desc * get_video_desc(struct ast_channel *c)
return the pointer to the video descriptor
Definition: chan_oss.c:319
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:84
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343
#define ast_module_ref(mod)
Hold a reference to the module.
Definition: module.h:443

◆ oss_read()

static struct ast_frame * oss_read ( struct ast_channel chan)
static

Definition at line 705 of file chan_oss.c.

References ast_channel_tech_pvt(), ast_format_slin, AST_FRAME_NULL, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, AST_STATE_UP, chan_oss_pvt::boost, BOOST_SCALE, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, 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, and ast_channel_tech::type.

706 {
707  int res;
708  struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
709  struct ast_frame *f = &o->read_f;
710 
711  /* XXX can be simplified returning &ast_null_frame */
712  /* prepare a NULL frame in case we don't have enough data to return */
713  memset(f, '\0', sizeof(struct ast_frame));
715  f->src = oss_tech.type;
716 
717  res = read(o->sounddev, o->oss_read_buf + o->readpos, sizeof(o->oss_read_buf) - o->readpos);
718  if (res < 0) /* audio data not ready, return a NULL frame */
719  return f;
720 
721  o->readpos += res;
722  if (o->readpos < sizeof(o->oss_read_buf)) /* not enough samples */
723  return f;
724 
725  if (o->mute)
726  return f;
727 
728  o->readpos = AST_FRIENDLY_OFFSET; /* reset read pointer for next frame */
729  if (ast_channel_state(c) != AST_STATE_UP) /* drop data if frame is not up */
730  return f;
731  /* ok we can build and deliver the frame to the caller */
734  f->samples = FRAME_SIZE;
735  f->datalen = FRAME_SIZE * 2;
737  if (o->boost != BOOST_SCALE) { /* scale and clip values */
738  int i, x;
739  int16_t *p = (int16_t *) f->data.ptr;
740  for (i = 0; i < f->samples; i++) {
741  x = (p[i] * o->boost) / BOOST_SCALE;
742  if (x > 32767)
743  x = 32767;
744  else if (x < -32768)
745  x = -32768;
746  p[i] = x;
747  }
748  }
749 
751  return f;
752 }
const char *const type
Definition: channel.h:630
short int16_t
Definition: db.h:59
void * ast_channel_tech_pvt(const struct ast_channel *chan)
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:356
ast_channel_state
ast_channel states
Definition: channelstate.h:35
static struct test_val c
struct ast_frame_subclass subclass
union ast_frame::@255 data
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
const char * src
descriptor for one of our channels.
Definition: chan_oss.c:252
#define FRAME_SIZE
Definition: chan_oss.c:214
struct ast_frame read_f
Definition: chan_oss.c:310
int sounddev
Definition: chan_oss.c:257
Data structure associated with a single frame of data.
enum ast_frame_type frametype
struct ast_format * format
char oss_read_buf[FRAME_SIZE *2+AST_FRIENDLY_OFFSET]
Definition: chan_oss.c:308
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
#define BOOST_SCALE
Definition: chan_oss.c:284

◆ oss_request()

static struct ast_channel * oss_request ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  data,
int *  cause 
)
static

Definition at line 849 of file chan_oss.c.

References args, AST_APP_ARG, AST_CAUSE_BUSY, AST_DECLARE_APP_ARGS, ast_format_cap_get_names(), ast_format_cap_iscompatible_format(), AST_FORMAT_CAP_NAMES_LEN, AST_FORMAT_CMP_NOT_EQUAL, ast_format_slin, ast_log, AST_NONSTANDARD_APP_ARGS, AST_STATE_DOWN, ast_str_alloca, ast_strdupa, c, find_desc(), LOG_NOTICE, LOG_WARNING, chan_oss_pvt::name, NULL, oss_new(), chan_oss_pvt::owner, parse(), store_config_core(), value, and var.

850 {
851  struct ast_channel *c;
852  struct chan_oss_pvt *o;
854  AST_APP_ARG(name);
855  AST_APP_ARG(flags);
856  );
857  char *parse = ast_strdupa(data);
858 
859  AST_NONSTANDARD_APP_ARGS(args, parse, '/');
860  o = find_desc(args.name);
861 
862  ast_log(LOG_WARNING, "oss_request ty <%s> data 0x%p <%s>\n", type, data, data);
863  if (o == NULL) {
864  ast_log(LOG_NOTICE, "Device %s not found\n", args.name);
865  /* XXX we could default to 'dsp' perhaps ? */
866  return NULL;
867  }
869  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
870  ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_format_cap_get_names(cap, &codec_buf));
871  return NULL;
872  }
873  if (o->owner) {
874  ast_log(LOG_NOTICE, "Already have a call (chan %p) on the OSS channel\n", o->owner);
875  *cause = AST_CAUSE_BUSY;
876  return NULL;
877  }
878  c = oss_new(o, NULL, NULL, AST_STATE_DOWN, assignedids, requestor);
879  if (c == NULL) {
880  ast_log(LOG_WARNING, "Unable to create new OSS channel\n");
881  return NULL;
882  }
883  return c;
884 }
static const char type[]
Definition: chan_ooh323.c:109
Main Channel structure associated with a channel.
#define LOG_WARNING
Definition: logger.h:274
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
static struct test_val c
#define ast_str_alloca(init_len)
Definition: strings.h:800
const char * args
#define NULL
Definition: resample.c:96
enum ast_format_cmp_res ast_format_cap_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format)
Find if ast_format is within the capabilities of the ast_format_cap object.
Definition: format_cap.c:583
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:376
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
#define LOG_NOTICE
Definition: logger.h:263
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:736
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
static const char name[]
Definition: cdr_mysql.c:74
struct ast_channel * owner
Definition: chan_oss.c:291
#define AST_CAUSE_BUSY
Definition: causes.h:148
static struct ast_channel * oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
allocate a new channel.
Definition: chan_oss.c:799
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ oss_text()

static int oss_text ( struct ast_channel c,
const char *  text 
)
static

Definition at line 593 of file chan_oss.c.

References ast_verbose().

594 {
595  /* print received messages */
596  ast_verbose(" << Console Received text %s >> \n", text);
597  return 0;
598 }
char * text
Definition: app_queue.c:1511
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207

◆ oss_write()

static int oss_write ( struct ast_channel chan,
struct ast_frame f 
)
static

used for data coming from the network

Definition at line 674 of file chan_oss.c.

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

675 {
676  int src;
677  struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
678 
679  /*
680  * we could receive a block which is not a multiple of our
681  * FRAME_SIZE, so buffer it locally and write to the device
682  * in FRAME_SIZE chunks.
683  * Keep the residue stored for future use.
684  */
685  src = 0; /* read position into f->data */
686  while (src < f->datalen) {
687  /* Compute spare room in the buffer */
688  int l = sizeof(o->oss_write_buf) - o->oss_write_dst;
689 
690  if (f->datalen - src >= l) { /* enough to fill a frame */
691  memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l);
692  soundcard_writeframe(o, (short *) o->oss_write_buf);
693  src += l;
694  o->oss_write_dst = 0;
695  } else { /* copy residue */
696  l = f->datalen - src;
697  memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l);
698  src += l; /* but really, we are done */
699  o->oss_write_dst += l;
700  }
701  }
702  return 0;
703 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
if(!yyg->yy_init)
Definition: ast_expr2f.c:868
static struct test_val c
char oss_write_buf[FRAME_SIZE *2]
Definition: chan_oss.c:303
union ast_frame::@255 data
descriptor for one of our channels.
Definition: chan_oss.c:252
int oss_write_dst
Definition: chan_oss.c:304
static int soundcard_writeframe(struct chan_oss_pvt *o, short *data)
Definition: chan_oss.c:452

◆ setformat()

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 481 of file chan_oss.c.

References ast_channel_set_fd(), ast_log, ast_tvdiff_ms(), ast_tvnow(), ast_verb, chan_oss_pvt::CHAN_OSS_DUPLEX_FULL, chan_oss_pvt::CHAN_OSS_DUPLEX_READ, chan_oss_pvt::CHAN_OSS_DUPLEX_UNSET, chan_oss_pvt::CHAN_OSS_DUPLEX_WRITE, 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().

482 {
483  int fmt, desired, res, fd;
484 
485  if (o->sounddev >= 0) {
486  ioctl(o->sounddev, SNDCTL_DSP_RESET, 0);
487  close(o->sounddev);
489  o->sounddev = -1;
490  }
491  if (mode == O_CLOSE) /* we are done */
492  return 0;
493  if (ast_tvdiff_ms(ast_tvnow(), o->lastopen) < 1000)
494  return -1; /* don't open too often */
495  o->lastopen = ast_tvnow();
496  fd = o->sounddev = open(o->device, mode | O_NONBLOCK);
497  if (fd < 0) {
498  ast_log(LOG_WARNING, "Unable to re-open DSP device %s: %s\n", o->device, strerror(errno));
499  return -1;
500  }
501  if (o->owner)
502  ast_channel_set_fd(o->owner, 0, fd);
503 
504 #if __BYTE_ORDER == __LITTLE_ENDIAN
505  fmt = AFMT_S16_LE;
506 #else
507  fmt = AFMT_S16_BE;
508 #endif
509  res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
510  if (res < 0) {
511  ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");
512  return -1;
513  }
514  switch (mode) {
515  case O_RDWR:
516  res = ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
517  /* Check to see if duplex set (FreeBSD Bug) */
518  res = ioctl(fd, SNDCTL_DSP_GETCAPS, &fmt);
519  if (res == 0 && (fmt & DSP_CAP_DUPLEX)) {
520  ast_verb(2, "Console is full duplex\n");
522  };
523  break;
524 
525  case O_WRONLY:
527  break;
528 
529  case O_RDONLY:
531  break;
532  }
533 
534  fmt = 0;
535  res = ioctl(fd, SNDCTL_DSP_STEREO, &fmt);
536  if (res < 0) {
537  ast_log(LOG_WARNING, "Failed to set audio device to mono\n");
538  return -1;
539  }
540  fmt = desired = DEFAULT_SAMPLE_RATE; /* 8000 Hz desired */
541  res = ioctl(fd, SNDCTL_DSP_SPEED, &fmt);
542 
543  if (res < 0) {
544  ast_log(LOG_WARNING, "Failed to set sample rate to %d\n", desired);
545  return -1;
546  }
547  if (fmt != desired) {
548  if (!(o->warned & WARN_speed)) {
550  "Requested %d Hz, got %d Hz -- sound may be choppy\n",
551  desired, fmt);
552  o->warned |= WARN_speed;
553  }
554  }
555  /*
556  * on Freebsd, SETFRAGMENT does not work very well on some cards.
557  * Default to use 256 bytes, let the user override
558  */
559  if (o->frags) {
560  fmt = o->frags;
561  res = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fmt);
562  if (res < 0) {
563  if (!(o->warned & WARN_frag)) {
565  "Unable to set fragment size -- sound may be choppy\n");
566  o->warned |= WARN_frag;
567  }
568  }
569  }
570  /* on some cards, we need SNDCTL_DSP_SETTRIGGER to start outputting */
571  res = PCM_ENABLE_INPUT | PCM_ENABLE_OUTPUT;
572  res = ioctl(fd, SNDCTL_DSP_SETTRIGGER, &res);
573  /* it may fail if we are in half duplex, never mind */
574  return 0;
575 }
#define DEFAULT_SAMPLE_RATE
Definition: asterisk.h:46
#define WARN_speed
Definition: chan_oss.c:273
#define O_CLOSE
Definition: chan_oss.c:232
#define LOG_WARNING
Definition: logger.h:274
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
#define ast_verb(level,...)
Definition: logger.h:455
#define ast_log
Definition: astobj2.c:42
#define WARN_frag
Definition: chan_oss.c:274
unsigned int frags
Definition: chan_oss.c:269
int errno
struct ast_channel * owner
Definition: chan_oss.c:291
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2406
int sounddev
Definition: chan_oss.c:257
enum chan_oss_pvt::@124 duplex
char device[64]
Definition: chan_oss.c:287
struct timeval lastopen
Definition: chan_oss.c:276

◆ soundcard_writeframe()

static int soundcard_writeframe ( struct chan_oss_pvt o,
short *  data 
)
static

Write an exactly FRAME_SIZE sized frame

Definition at line 452 of file chan_oss.c.

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

Referenced by oss_write().

453 {
454  int res;
455 
456  if (o->sounddev < 0)
457  setformat(o, O_RDWR);
458  if (o->sounddev < 0)
459  return 0; /* not fatal */
460  /*
461  * Nothing complex to manage the audio device queue.
462  * If the buffer is full just drop the extra, otherwise write.
463  * XXX in some cases it might be useful to write anyways after
464  * a number of failures, to restart the output chain.
465  */
466  res = used_blocks(o);
467  if (res > o->queuesize) { /* no room to write a block */
468  if (o->w_errors++ == 0 && (oss_debug & 0x4))
469  ast_log(LOG_WARNING, "write: used %d blocks (%d)\n", res, o->w_errors);
470  return 0;
471  }
472  o->w_errors = 0;
473  return write(o->sounddev, (void *)data, FRAME_SIZE * 2);
474 }
int w_errors
Definition: chan_oss.c:275
unsigned int queuesize
Definition: chan_oss.c:268
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:481
static int used_blocks(struct chan_oss_pvt *o)
Returns the number of blocks used in the audio output channel.
Definition: chan_oss.c:430
#define FRAME_SIZE
Definition: chan_oss.c:214
int sounddev
Definition: chan_oss.c:257
static int oss_debug
Definition: chan_oss.c:242

◆ store_boost()

static void store_boost ( struct chan_oss_pvt o,
const char *  s 
)
static

store the boost factor

Definition at line 1253 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().

1254 {
1255  double boost = 0;
1256  if (sscanf(s, "%30lf", &boost) != 1) {
1257  ast_log(LOG_WARNING, "invalid boost <%s>\n", s);
1258  return;
1259  }
1260  if (boost < -BOOST_MAX) {
1261  ast_log(LOG_WARNING, "boost %s too small, using %d\n", s, -BOOST_MAX);
1262  boost = -BOOST_MAX;
1263  } else if (boost > BOOST_MAX) {
1264  ast_log(LOG_WARNING, "boost %s too large, using %d\n", s, BOOST_MAX);
1265  boost = BOOST_MAX;
1266  }
1267  boost = exp(log(10) * boost / 20) * BOOST_SCALE;
1268  o->boost = boost;
1269  ast_log(LOG_WARNING, "setting boost %s to %d\n", s, o->boost);
1270 }
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
#define BOOST_MAX
Definition: chan_oss.c:285
#define BOOST_SCALE
Definition: chan_oss.c:284

◆ store_callerid()

static void store_callerid ( struct chan_oss_pvt o,
const char *  s 
)
static

store the callerid components

Definition at line 1332 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().

1333 {
1334  ast_callerid_split(s, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
1335 }
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1092
char cid_name[256]
Definition: chan_oss.c:298
char cid_num[256]
Definition: chan_oss.c:299

◆ store_config()

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 1368 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, chan_oss_pvt::CHAN_OSS_DUPLEX_FULL, console_video_start(), DEV_DSP, chan_oss_pvt::device, chan_oss_pvt::duplex, chan_oss_pvt::env, errno, error(), get_gui_startup(), chan_oss_pvt::lastopen, LOG_WARNING, chan_oss_pvt::mixer_cmd, chan_oss_pvt::mohinterpret, ast_variable::name, chan_oss_pvt::name, ast_variable::next, chan_oss_pvt::next, NULL, oss_active, oss_default, setformat(), store_config_core(), and ast_variable::value.

Referenced by load_module().

1369 {
1370  struct ast_variable *v;
1371  struct chan_oss_pvt *o;
1372 
1373  if (ctg == NULL) {
1374  o = &oss_default;
1375  ctg = "general";
1376  } else {
1377  if (!(o = ast_calloc(1, sizeof(*o))))
1378  return NULL;
1379  *o = oss_default;
1380  /* "general" is also the default thing */
1381  if (strcmp(ctg, "general") == 0) {
1382  o->name = ast_strdup("dsp");
1383  oss_active = o->name;
1384  goto openit;
1385  }
1386  o->name = ast_strdup(ctg);
1387  }
1388 
1389  strcpy(o->mohinterpret, "default");
1390 
1391  o->lastopen = ast_tvnow(); /* don't leave it 0 or tvdiff may wrap */
1392  /* fill other fields from configuration */
1393  for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
1394  store_config_core(o, v->name, v->value);
1395  }
1396  if (ast_strlen_zero(o->device))
1397  ast_copy_string(o->device, DEV_DSP, sizeof(o->device));
1398  if (o->mixer_cmd) {
1399  char *cmd;
1400 
1401  if (ast_asprintf(&cmd, "mixer %s", o->mixer_cmd) >= 0) {
1402  ast_log(LOG_WARNING, "running [%s]\n", cmd);
1403  if (system(cmd) < 0) {
1404  ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno));
1405  }
1406  ast_free(cmd);
1407  }
1408  }
1409 
1410  /* if the config file requested to start the GUI, do it */
1411  if (get_gui_startup(o->env))
1413 
1414  if (o == &oss_default) /* we are done with the default */
1415  return NULL;
1416 
1417 openit:
1418 #ifdef TRYOPEN
1419  if (setformat(o, O_RDWR) < 0) { /* open device */
1420  ast_verb(1, "Device %s not detected\n", ctg);
1421  ast_verb(1, "Turn off OSS support by adding " "'noload=chan_oss.so' in /etc/asterisk/modules.conf\n");
1422  goto error;
1423  }
1424  if (o->duplex != CHAN_OSS_DUPLEX_FULL)
1425  ast_log(LOG_WARNING, "XXX I don't work right with non " "full-duplex sound cards XXX\n");
1426 #endif /* TRYOPEN */
1427 
1428  /* link into list of devices */
1429  if (o != &oss_default) {
1430  o->next = oss_default.next;
1431  oss_default.next = o;
1432  }
1433  return o;
1434 
1435 #ifdef TRYOPEN
1436 error:
1437  if (o != &oss_default)
1438  ast_free(o);
1439  return NULL;
1440 #endif
1441 }
struct ast_variable * next
struct chan_oss_pvt * next
Definition: chan_oss.c:253
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
static char * oss_active
Definition: chan_oss.c:316
#define LOG_WARNING
Definition: logger.h:274
Structure for variables, used for configurations and for channel variables.
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:150
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:269
#define ast_log
Definition: astobj2.c:42
#define DEV_DSP
Definition: chan_oss.c:237
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:481
descriptor for one of our channels.
Definition: chan_oss.c:252
char * mixer_cmd
Definition: chan_oss.c:267
int errno
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
char * name
Definition: chan_oss.c:255
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:300
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:401
enum chan_oss_pvt::@124 duplex
struct video_desc * env
Definition: chan_oss.c:293
int error(const char *format,...)
Definition: utils/frame.c:999
char device[64]
Definition: chan_oss.c:287
struct timeval lastopen
Definition: chan_oss.c:276
static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value)
Definition: chan_oss.c:1337
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:324

◆ store_config_core()

static void store_config_core ( struct chan_oss_pvt o,
const char *  var,
const char *  value 
)
static

Definition at line 1337 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, oss_debug, chan_oss_pvt::overridecontext, chan_oss_pvt::queuesize, store_boost(), store_callerid(), and store_mixer().

Referenced by console_cmd(), oss_request(), and store_config().

1338 {
1339  CV_START(var, value);
1340 
1341  /* handle jb conf */
1343  return;
1344 
1345  if (!console_video_config(&o->env, var, value))
1346  return; /* matched there */
1347  CV_BOOL("autoanswer", o->autoanswer);
1348  CV_BOOL("autohangup", o->autohangup);
1349  CV_BOOL("overridecontext", o->overridecontext);
1350  CV_STR("device", o->device);
1351  CV_UINT("frags", o->frags);
1352  CV_UINT("debug", oss_debug);
1353  CV_UINT("queuesize", o->queuesize);
1354  CV_STR("context", o->ctx);
1355  CV_STR("language", o->language);
1356  CV_STR("mohinterpret", o->mohinterpret);
1357  CV_STR("extension", o->ext);
1358  CV_F("mixer", store_mixer(o, value));
1359  CV_F("callerid", store_callerid(o, value)) ;
1360  CV_F("boost", store_boost(o, value));
1361 
1362  CV_END;
1363 }
static void store_mixer(struct chan_oss_pvt *o, const char *s)
Definition: chan_oss.c:1313
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:296
unsigned int queuesize
Definition: chan_oss.c:268
#define CV_UINT(__x, __dst)
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Definition: abstract_jb.c:545
#define var
Definition: ast_expr2f.c:614
int autohangup
Definition: chan_oss.c:265
#define CV_END
close a variable parsing block
int value
Definition: syslog.c:37
#define CV_START(__in_var, __in_val)
the macro to open a block for variable parsing
#define CV_STR(__x, __dst)
int console_video_config(struct video_desc **penv, const char *var, const char *val)
#define CV_F(__pattern, __body)
call a generic function if the name matches.
unsigned int frags
Definition: chan_oss.c:269
#define CV_BOOL(__x, __dst)
helper macros to assign the value to a BOOL, UINT, static string and dynamic string ...
static void store_callerid(struct chan_oss_pvt *o, const char *s)
Definition: chan_oss.c:1332
char ext[AST_MAX_EXTENSION]
Definition: chan_oss.c:295
static void store_boost(struct chan_oss_pvt *o, const char *s)
store the boost factor
Definition: chan_oss.c:1253
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:300
struct video_desc * env
Definition: chan_oss.c:293
char device[64]
Definition: chan_oss.c:287
int overridecontext
Definition: chan_oss.c:278
int autoanswer
Definition: chan_oss.c:264
static int oss_debug
Definition: chan_oss.c:242
char language[MAX_LANGUAGE]
Definition: chan_oss.c:297
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:84

◆ store_mixer()

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 1313 of file chan_oss.c.

References ast_free, ast_log, ast_strdup, LOG_WARNING, chan_oss_pvt::mixer_cmd, and NULL.

Referenced by store_config_core().

1314 {
1315  int i;
1316 
1317  for (i = 0; i < strlen(s); i++) {
1318  if (!isalnum(s[i]) && strchr(" \t-/", s[i]) == NULL) {
1319  ast_log(LOG_WARNING, "Suspect char %c in mixer cmd, ignoring:\n\t%s\n", s[i], s);
1320  return;
1321  }
1322  }
1323  if (o->mixer_cmd)
1324  ast_free(o->mixer_cmd);
1325  o->mixer_cmd = ast_strdup(s);
1326  ast_log(LOG_WARNING, "setting mixer %s\n", s);
1327 }
#define LOG_WARNING
Definition: logger.h:274
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
char * mixer_cmd
Definition: chan_oss.c:267
#define ast_free(a)
Definition: astmm.h:182

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 1443 of file chan_oss.c.

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

Referenced by load_module().

1444 {
1445  struct chan_oss_pvt *o, *next;
1446 
1449 
1450  o = oss_default.next;
1451  while (o) {
1452  close(o->sounddev);
1453  if (o->owner)
1455  if (o->owner)
1456  return -1;
1457  next = o->next;
1458  ast_free(o->name);
1459  ast_free(o);
1460  o = next;
1461  }
1464 
1465  return 0;
1466 }
struct chan_oss_pvt * next
Definition: chan_oss.c:253
#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: clicompat.c:30
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:356
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:566
#define NULL
Definition: resample.c:96
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
Definition: channel.c:2451
descriptor for one of our channels.
Definition: chan_oss.c:252
static struct ast_cli_entry cli_oss[]
Definition: chan_oss.c:1294
struct ast_format_cap * capabilities
Definition: channel.h:633
#define ast_free(a)
Definition: astmm.h:182
struct ast_channel * owner
Definition: chan_oss.c:291
char * name
Definition: chan_oss.c:255
int sounddev
Definition: chan_oss.c:257
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:324

◆ used_blocks()

static int used_blocks ( struct chan_oss_pvt o)
static

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

Definition at line 430 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().

431 {
432  struct audio_buf_info info;
433 
434  if (ioctl(o->sounddev, SNDCTL_DSP_GETOSPACE, &info)) {
435  if (!(o->warned & WARN_used_blocks)) {
436  ast_log(LOG_WARNING, "Error reading output space\n");
437  o->warned |= WARN_used_blocks;
438  }
439  return 1;
440  }
441 
442  if (o->total_blocks == 0) {
443  if (0) /* debugging */
444  ast_log(LOG_WARNING, "fragtotal %d size %d avail %d\n", info.fragstotal, info.fragsize, info.fragments);
445  o->total_blocks = info.fragments;
446  }
447 
448  return o->total_blocks - info.fragments;
449 }
#define LOG_WARNING
Definition: logger.h:274
int total_blocks
Definition: chan_oss.c:256
#define ast_log
Definition: astobj2.c:42
def info(msg)
int sounddev
Definition: chan_oss.c:257
#define WARN_used_blocks
Definition: chan_oss.c:272

Variable Documentation

◆ cli_oss

struct ast_cli_entry cli_oss[]
static

Definition at line 1294 of file chan_oss.c.

◆ config

char* config = "oss.conf"
static

Definition at line 240 of file chan_oss.c.

Referenced by load_module().

◆ default_jbconf

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 76 of file chan_oss.c.

◆ global_jbconf

struct ast_jb_conf global_jbconf
static

Definition at line 84 of file chan_oss.c.

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

◆ oss_active

char* oss_active
static

◆ oss_debug

int oss_debug
static

Definition at line 242 of file chan_oss.c.

Referenced by soundcard_writeframe(), and store_config_core().

◆ oss_default

struct chan_oss_pvt oss_default
static

Definition at line 324 of file chan_oss.c.

Referenced by store_config().

◆ oss_tech

struct ast_channel_tech oss_tech
static

Definition at line 356 of file chan_oss.c.

◆ tdesc

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

Definition at line 353 of file chan_oss.c.