Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Data Structures | Macros | Functions | Variables
chan_alsa.c File Reference

ALSA sound card channel driver. More...

#include "asterisk.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <alsa/asoundlib.h>
#include "asterisk/frame.h"
#include "asterisk/channel.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/musiconhold.h"
#include "asterisk/poll-compat.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
Include dependency graph for chan_alsa.c:

Go to the source code of this file.

Data Structures

struct  chan_alsa_pvt
 

Macros

#define ALSA_INDEV   "default"
 
#define ALSA_OUTDEV   "default"
 
#define ALSA_PCM_NEW_HW_PARAMS_API
 
#define ALSA_PCM_NEW_SW_PARAMS_API
 
#define BUFFER_FMT   ((buffersize * 10) << 16) | (0x0006);
 
#define DEBUG   0
 
#define DESIRED_RATE   8000
 
#define ESTRPIPE   EPIPE
 
#define FRAME_SIZE   160
 
#define MAX_BUFFER_SIZE   100
 
#define MIN_SWITCH_TIME   600
 
#define PERIOD_FRAMES   80 /* 80 Frames, at 2 bytes each */
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int alsa_answer (struct ast_channel *c)
 
static int alsa_call (struct ast_channel *c, const char *dest, int timeout)
 
static snd_pcm_t * alsa_card_init (char *dev, snd_pcm_stream_t stream)
 
static int alsa_digit (struct ast_channel *c, char digit, unsigned int duration)
 
static int alsa_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
 
static int alsa_hangup (struct ast_channel *c)
 
static int alsa_indicate (struct ast_channel *chan, int cond, const void *data, size_t datalen)
 
static struct ast_channelalsa_new (struct chan_alsa_pvt *p, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
 
static struct ast_framealsa_read (struct ast_channel *chan)
 
static struct ast_channelalsa_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 alsa_text (struct ast_channel *c, const char *text)
 
static int alsa_write (struct ast_channel *chan, struct ast_frame *f)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static char * console_answer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * console_autoanswer (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_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)
 
static void grab_owner (void)
 
static int load_module (void)
 Load the module. More...
 
static int soundcard_init (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ALSA 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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, }
 
static struct chan_alsa_pvt alsa
 
static struct ast_channel_tech alsa_tech
 
static ast_mutex_t alsalock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static int autoanswer = 1
 
static struct ast_cli_entry cli_alsa []
 
static const char config [] = "alsa.conf"
 
static char context [AST_MAX_CONTEXT] = "default"
 
static struct ast_jb_conf default_jbconf
 
static char exten [AST_MAX_EXTENSION] = "s"
 
static snd_pcm_format_t format = SND_PCM_FORMAT_S16_BE
 
static struct ast_jb_conf global_jbconf
 
static int hookstate = 0
 
static char indevname [50] = ALSA_INDEV
 
static char language [MAX_LANGUAGE] = ""
 
static char mohinterpret [MAX_MUSICCLASS]
 
static int mute = 0
 
static int noaudiocapture = 0
 
static char outdevname [50] = ALSA_OUTDEV
 
static int readdev = -1
 
static int silencesuppression = 0
 
static int silencethreshold = 1000
 
static const char tdesc [] = "ALSA Console Channel Driver"
 
static int writedev = -1
 

Detailed Description

ALSA sound card channel driver.

Author
Matthew Fredrickson cresl.nosp@m.in@d.nosp@m.igium.nosp@m..com

Definition in file chan_alsa.c.

Macro Definition Documentation

◆ ALSA_INDEV

#define ALSA_INDEV   "default"

Definition at line 87 of file chan_alsa.c.

◆ ALSA_OUTDEV

#define ALSA_OUTDEV   "default"

Definition at line 88 of file chan_alsa.c.

◆ ALSA_PCM_NEW_HW_PARAMS_API

#define ALSA_PCM_NEW_HW_PARAMS_API

Definition at line 54 of file chan_alsa.c.

◆ ALSA_PCM_NEW_SW_PARAMS_API

#define ALSA_PCM_NEW_SW_PARAMS_API

Definition at line 55 of file chan_alsa.c.

◆ BUFFER_FMT

#define BUFFER_FMT   ((buffersize * 10) << 16) | (0x0006);

Definition at line 98 of file chan_alsa.c.

◆ DEBUG

#define DEBUG   0

Definition at line 85 of file chan_alsa.c.

◆ DESIRED_RATE

#define DESIRED_RATE   8000

Definition at line 89 of file chan_alsa.c.

◆ ESTRPIPE

#define ESTRPIPE   EPIPE

Definition at line 48 of file chan_alsa.c.

◆ FRAME_SIZE

#define FRAME_SIZE   160

Definition at line 92 of file chan_alsa.c.

◆ MAX_BUFFER_SIZE

#define MAX_BUFFER_SIZE   100

Definition at line 141 of file chan_alsa.c.

◆ MIN_SWITCH_TIME

#define MIN_SWITCH_TIME   600

Definition at line 101 of file chan_alsa.c.

◆ PERIOD_FRAMES

#define PERIOD_FRAMES   80 /* 80 Frames, at 2 bytes each */

Definition at line 93 of file chan_alsa.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 1047 of file chan_alsa.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 1047 of file chan_alsa.c.

◆ alsa_answer()

static int alsa_answer ( struct ast_channel c)
static

Definition at line 365 of file chan_alsa.c.

366 {
368  ast_verbose(" << Console call has been answered >> \n");
370  if (!noaudiocapture) {
371  snd_pcm_prepare(alsa.icard);
372  snd_pcm_start(alsa.icard);
373  }
375 
376  return 0;
377 }
static int noaudiocapture
Definition: chan_alsa.c:149
static ast_mutex_t alsalock
Definition: chan_alsa.c:115
static struct chan_alsa_pvt alsa
@ AST_STATE_UP
Definition: channelstate.h:42
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7469
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2206
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define ast_mutex_lock(a)
Definition: lock.h:187
snd_pcm_t * icard
Definition: chan_alsa.c:133
static struct test_val c

References alsa, alsalock, ast_mutex_lock, ast_mutex_unlock, ast_setstate(), AST_STATE_UP, ast_verbose(), c, chan_alsa_pvt::icard, and noaudiocapture.

◆ alsa_call()

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

Definition at line 329 of file chan_alsa.c.

330 {
331  struct ast_frame f = { AST_FRAME_CONTROL };
332 
334  ast_verbose(" << Call placed to '%s' on console >> \n", dest);
335  if (autoanswer) {
336  ast_verbose(" << Auto-answered >> \n");
337  if (mute) {
338  ast_verbose( " << Muted >> \n" );
339  }
340  grab_owner();
341  if (alsa.owner) {
345  }
346  } else {
347  ast_verbose(" << Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
348  grab_owner();
349  if (alsa.owner) {
354  }
355  }
356  if (!noaudiocapture) {
357  snd_pcm_prepare(alsa.icard);
358  snd_pcm_start(alsa.icard);
359  }
361 
362  return 0;
363 }
static int mute
Definition: chan_alsa.c:148
static void grab_owner(void)
Definition: chan_alsa.c:322
static int autoanswer
Definition: chan_alsa.c:147
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1133
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4312
#define ast_channel_unlock(chan)
Definition: channel.h:2923
@ AST_FRAME_CONTROL
@ AST_CONTROL_ANSWER
@ AST_CONTROL_RINGING
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
struct ast_channel * owner
Definition: chan_alsa.c:130

References alsa, alsalock, ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_RINGING, AST_FRAME_CONTROL, ast_indicate(), ast_mutex_lock, ast_mutex_unlock, ast_queue_frame(), ast_verbose(), autoanswer, grab_owner(), chan_alsa_pvt::icard, ast_frame_subclass::integer, mute, noaudiocapture, chan_alsa_pvt::owner, and ast_frame::subclass.

◆ alsa_card_init()

static snd_pcm_t* alsa_card_init ( char *  dev,
snd_pcm_stream_t  stream 
)
static

Definition at line 177 of file chan_alsa.c.

178 {
179  int err;
180  int direction;
181  snd_pcm_t *handle = NULL;
182  snd_pcm_hw_params_t *hwparams = NULL;
183  snd_pcm_sw_params_t *swparams = NULL;
184  struct pollfd pfd;
185  snd_pcm_uframes_t period_size = PERIOD_FRAMES * 4;
186  snd_pcm_uframes_t buffer_size = 0;
187  unsigned int rate = DESIRED_RATE;
188  snd_pcm_uframes_t start_threshold, stop_threshold;
189 
190  err = snd_pcm_open(&handle, dev, stream, SND_PCM_NONBLOCK);
191  if (err < 0) {
192  ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
193  return NULL;
194  } else {
195  ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
196  }
197 
198  hwparams = ast_alloca(snd_pcm_hw_params_sizeof());
199  memset(hwparams, 0, snd_pcm_hw_params_sizeof());
200  snd_pcm_hw_params_any(handle, hwparams);
201 
202  err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
203  if (err < 0)
204  ast_log(LOG_ERROR, "set_access failed: %s\n", snd_strerror(err));
205 
206  err = snd_pcm_hw_params_set_format(handle, hwparams, format);
207  if (err < 0)
208  ast_log(LOG_ERROR, "set_format failed: %s\n", snd_strerror(err));
209 
210  err = snd_pcm_hw_params_set_channels(handle, hwparams, 1);
211  if (err < 0)
212  ast_log(LOG_ERROR, "set_channels failed: %s\n", snd_strerror(err));
213 
214  direction = 0;
215  err = snd_pcm_hw_params_set_rate_near(handle, hwparams, &rate, &direction);
216  if (rate != DESIRED_RATE)
217  ast_log(LOG_WARNING, "Rate not correct, requested %d, got %u\n", DESIRED_RATE, rate);
218 
219  direction = 0;
220  err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction);
221  if (err < 0)
222  ast_log(LOG_ERROR, "period_size(%lu frames) is bad: %s\n", period_size, snd_strerror(err));
223  else {
224  ast_debug(1, "Period size is %d\n", err);
225  }
226 
227  buffer_size = 4096 * 2; /* period_size * 16; */
228  err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size);
229  if (err < 0)
230  ast_log(LOG_WARNING, "Problem setting buffer size of %lu: %s\n", buffer_size, snd_strerror(err));
231  else {
232  ast_debug(1, "Buffer size is set to %d frames\n", err);
233  }
234 
235  err = snd_pcm_hw_params(handle, hwparams);
236  if (err < 0)
237  ast_log(LOG_ERROR, "Couldn't set the new hw params: %s\n", snd_strerror(err));
238 
239  swparams = ast_alloca(snd_pcm_sw_params_sizeof());
240  memset(swparams, 0, snd_pcm_sw_params_sizeof());
241  snd_pcm_sw_params_current(handle, swparams);
242 
243  if (stream == SND_PCM_STREAM_PLAYBACK)
244  start_threshold = period_size;
245  else
246  start_threshold = 1;
247 
248  err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
249  if (err < 0)
250  ast_log(LOG_ERROR, "start threshold: %s\n", snd_strerror(err));
251 
252  if (stream == SND_PCM_STREAM_PLAYBACK)
253  stop_threshold = buffer_size;
254  else
255  stop_threshold = buffer_size;
256 
257  err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
258  if (err < 0)
259  ast_log(LOG_ERROR, "stop threshold: %s\n", snd_strerror(err));
260 
261  err = snd_pcm_sw_params(handle, swparams);
262  if (err < 0)
263  ast_log(LOG_ERROR, "sw_params: %s\n", snd_strerror(err));
264 
265  err = snd_pcm_poll_descriptors_count(handle);
266  if (err <= 0)
267  ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
268  if (err != 1) {
269  ast_debug(1, "Can't handle more than one device\n");
270  }
271 
272  snd_pcm_poll_descriptors(handle, &pfd, err);
273  ast_debug(1, "Acquired fd %d from the poll descriptor\n", pfd.fd);
274 
275  if (stream == SND_PCM_STREAM_CAPTURE)
276  readdev = pfd.fd;
277  else
278  writedev = pfd.fd;
279 
280  return handle;
281 }
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ast_log
Definition: astobj2.c:42
#define DESIRED_RATE
Definition: chan_alsa.c:89
#define PERIOD_FRAMES
Definition: chan_alsa.c:93
static int readdev
Definition: chan_alsa.c:144
static int writedev
Definition: chan_alsa.c:145
static snd_pcm_format_t format
Definition: chan_alsa.c:106
direction
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_ERROR
#define LOG_WARNING
#define NULL
Definition: resample.c:96

References ast_alloca, ast_debug, ast_log, DESIRED_RATE, format, LOG_ERROR, LOG_WARNING, NULL, PERIOD_FRAMES, readdev, and writedev.

Referenced by soundcard_init().

◆ alsa_digit()

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

Definition at line 303 of file chan_alsa.c.

304 {
306  ast_verbose(" << Console Received digit %c of duration %u ms >> \n",
307  digit, duration);
309 
310  return 0;
311 }
char digit

References alsalock, ast_mutex_lock, ast_mutex_unlock, ast_verbose(), and digit.

◆ alsa_fixup()

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

Definition at line 535 of file chan_alsa.c.

536 {
537  struct chan_alsa_pvt *p = ast_channel_tech_pvt(newchan);
538 
540  p->owner = newchan;
542 
543  return 0;
544 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)

References alsalock, ast_channel_tech_pvt(), ast_mutex_lock, ast_mutex_unlock, and chan_alsa_pvt::owner.

◆ alsa_hangup()

static int alsa_hangup ( struct ast_channel c)
static

Definition at line 379 of file chan_alsa.c.

380 {
383  alsa.owner = NULL;
384  ast_verbose(" << Hangup on console >> \n");
386  hookstate = 0;
387  if (!noaudiocapture) {
388  snd_pcm_drop(alsa.icard);
389  }
391 
392  return 0;
393 }
static int hookstate
Definition: chan_alsa.c:125
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
struct ast_module * self
Definition: module.h:342

References alsa, alsalock, ast_channel_tech_pvt_set(), ast_module_unref, ast_mutex_lock, ast_mutex_unlock, ast_verbose(), c, hookstate, chan_alsa_pvt::icard, noaudiocapture, NULL, chan_alsa_pvt::owner, and ast_module_info::self.

◆ alsa_indicate()

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

Definition at line 546 of file chan_alsa.c.

547 {
548  int res = 0;
549 
551 
552  switch (cond) {
553  case AST_CONTROL_BUSY:
555  case AST_CONTROL_RINGING:
558  case -1:
559  res = -1; /* Ask for inband indications */
560  break;
565  break;
566  case AST_CONTROL_HOLD:
567  ast_verbose(" << Console Has Been Placed on Hold >> \n");
568  ast_moh_start(chan, data, mohinterpret);
569  break;
570  case AST_CONTROL_UNHOLD:
571  ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
572  ast_moh_stop(chan);
573  break;
574  default:
575  ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, ast_channel_name(chan));
576  res = -1;
577  }
578 
580 
581  return res;
582 }
ast_cond_t cond
Definition: app_meetme.c:1092
static char mohinterpret[MAX_MUSICCLASS]
Definition: chan_alsa.c:123
const char * ast_channel_name(const struct ast_channel *chan)
@ AST_CONTROL_SRCUPDATE
@ AST_CONTROL_PROGRESS
@ AST_CONTROL_BUSY
@ AST_CONTROL_UNHOLD
@ AST_CONTROL_VIDUPDATE
@ AST_CONTROL_PROCEEDING
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_HOLD
@ AST_CONTROL_INCOMPLETE
@ AST_CONTROL_PVT_CAUSE_CODE
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:7849
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:7859

References alsalock, ast_channel_name(), 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_mutex_lock, ast_mutex_unlock, ast_verbose(), cond, LOG_WARNING, and mohinterpret.

◆ alsa_new()

static struct ast_channel* alsa_new ( struct chan_alsa_pvt p,
int  state,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor 
)
static

Definition at line 584 of file chan_alsa.c.

585 {
586  struct ast_channel *tmp = NULL;
587 
588  if (!(tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, assignedids, requestor, 0, "ALSA/%s", indevname)))
589  return NULL;
590 
592 
598 
600  if (!ast_strlen_zero(p->context))
602  if (!ast_strlen_zero(p->exten))
605  ast_channel_language_set(tmp, language);
606  p->owner = tmp;
609 
612 
613  if (state != AST_STATE_DOWN) {
614  if (ast_pbx_start(tmp)) {
615  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
616  ast_hangup(tmp);
617  tmp = NULL;
618  }
619  }
620 
621  return tmp;
622 }
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
static int tmp()
Definition: bt_open.c:389
static char indevname[50]
Definition: chan_alsa.c:109
static struct ast_channel_tech alsa_tech
Definition: chan_alsa.c:162
static struct ast_jb_conf global_jbconf
Definition: chan_alsa.c:83
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:121
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2542
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1258
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2425
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
@ AST_STATE_DOWN
Definition: channelstate.h:36
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
#define ast_module_ref(mod)
Hold a reference to the module.
Definition: module.h:443
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:4715
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
struct ast_format_cap * capabilities
Definition: channel.h:632
Main Channel structure associated with a channel.
char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:131
char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:132

References alsa_tech, ast_channel_alloc, ast_channel_context_set(), ast_channel_exten_set(), ast_channel_name(), ast_channel_nativeformats_set(), ast_channel_set_fd(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), 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_strlen_zero(), ast_channel_tech::capabilities, chan_alsa_pvt::context, chan_alsa_pvt::exten, global_jbconf, indevname, language, LOG_WARNING, NULL, chan_alsa_pvt::owner, readdev, ast_module_info::self, and tmp().

Referenced by alsa_request(), and console_dial().

◆ alsa_read()

static struct ast_frame * alsa_read ( struct ast_channel chan)
static

Definition at line 447 of file chan_alsa.c.

448 {
449  static struct ast_frame f;
450  static short __buf[FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
451  short *buf;
452  static int readpos = 0;
453  static int left = FRAME_SIZE;
454  snd_pcm_state_t state;
455  int r = 0;
456 
458  f.frametype = AST_FRAME_NULL;
459  f.subclass.integer = 0;
460  f.samples = 0;
461  f.datalen = 0;
462  f.data.ptr = NULL;
463  f.offset = 0;
464  f.src = "Console";
465  f.mallocd = 0;
466  f.delivery.tv_sec = 0;
467  f.delivery.tv_usec = 0;
468 
469  if (noaudiocapture) {
470  /* Return null frame to asterisk*/
472  return &f;
473  }
474 
475  state = snd_pcm_state(alsa.icard);
476  if ((state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING)) {
477  snd_pcm_prepare(alsa.icard);
478  }
479 
480  buf = __buf + AST_FRIENDLY_OFFSET / 2;
481 
482  r = snd_pcm_readi(alsa.icard, buf + readpos, left);
483  if (r == -EPIPE) {
484 #if DEBUG
485  ast_log(LOG_ERROR, "XRUN read\n");
486 #endif
487  snd_pcm_prepare(alsa.icard);
488  } else if (r == -ESTRPIPE) {
489  ast_log(LOG_ERROR, "-ESTRPIPE\n");
490  snd_pcm_prepare(alsa.icard);
491  } else if (r < 0) {
492  ast_log(LOG_ERROR, "Read error: %s\n", snd_strerror(r));
493  }
494 
495  /* Return NULL frame on error */
496  if (r < 0) {
498  return &f;
499  }
500 
501  /* Update positions */
502  readpos += r;
503  left -= r;
504 
505  if (readpos >= FRAME_SIZE) {
506  /* A real frame */
507  readpos = 0;
508  left = FRAME_SIZE;
509  if (ast_channel_state(chan) != AST_STATE_UP) {
510  /* Don't transmit unless it's up */
512  return &f;
513  }
514  if (mute) {
515  /* Don't transmit if muted */
517  return &f;
518  }
519 
520  f.frametype = AST_FRAME_VOICE;
521  f.subclass.format = ast_format_slin;
522  f.samples = FRAME_SIZE;
523  f.datalen = FRAME_SIZE * 2;
524  f.data.ptr = buf;
525  f.offset = AST_FRIENDLY_OFFSET;
526  f.src = "Console";
527  f.mallocd = 0;
528 
529  }
531 
532  return &f;
533 }
#define ESTRPIPE
Definition: chan_alsa.c:48
#define FRAME_SIZE
Definition: chan_alsa.c:92
enum sip_cc_notify_state state
Definition: chan_sip.c:966
ast_channel_state
ast_channel states
Definition: channelstate.h:35
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
@ AST_FRAME_NULL
@ AST_FRAME_VOICE

References alsa, alsalock, ast_format_slin, AST_FRAME_NULL, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, ast_mutex_lock, ast_mutex_unlock, AST_STATE_UP, buf, ast_frame::data, ast_frame::datalen, ast_frame::delivery, ESTRPIPE, ast_frame_subclass::format, FRAME_SIZE, ast_frame::frametype, chan_alsa_pvt::icard, ast_frame_subclass::integer, LOG_ERROR, ast_frame::mallocd, mute, noaudiocapture, NULL, ast_frame::offset, ast_frame::ptr, ast_frame::samples, ast_frame::src, state, and ast_frame::subclass.

◆ alsa_request()

static struct ast_channel * alsa_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 624 of file chan_alsa.c.

625 {
626  struct ast_channel *tmp = NULL;
627 
629  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
630  ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_format_cap_get_names(cap, &codec_buf));
631  return NULL;
632  }
633 
635 
636  if (alsa.owner) {
637  ast_log(LOG_NOTICE, "Already have a call on the ALSA channel\n");
638  *cause = AST_CAUSE_BUSY;
639  } else if (!(tmp = alsa_new(&alsa, AST_STATE_DOWN, assignedids, requestor))) {
640  ast_log(LOG_WARNING, "Unable to create new ALSA channel\n");
641  }
642 
644 
645  return tmp;
646 }
#define AST_CAUSE_BUSY
Definition: causes.h:149
static struct ast_channel * alsa_new(struct chan_alsa_pvt *p, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
Definition: chan_alsa.c:584
@ AST_FORMAT_CMP_NOT_EQUAL
Definition: format.h:38
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:324
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:734
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:581
#define LOG_NOTICE
#define ast_str_alloca(init_len)
Definition: strings.h:826
Support for dynamic strings.
Definition: strings.h:604

References alsa, alsa_new(), alsalock, AST_CAUSE_BUSY, 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_mutex_lock, ast_mutex_unlock, AST_STATE_DOWN, ast_str_alloca, LOG_NOTICE, LOG_WARNING, NULL, chan_alsa_pvt::owner, and tmp().

◆ alsa_text()

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

Definition at line 313 of file chan_alsa.c.

314 {
316  ast_verbose(" << Console Received text %s >> \n", text);
318 
319  return 0;
320 }
char * text
Definition: app_queue.c:1641

References alsalock, ast_mutex_lock, ast_mutex_unlock, ast_verbose(), and text.

◆ alsa_write()

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

Definition at line 395 of file chan_alsa.c.

396 {
397  static char sizbuf[8000];
398  static int sizpos = 0;
399  int len = sizpos;
400  int res = 0;
401  /* size_t frames = 0; */
402  snd_pcm_state_t state;
403 
405 
406  /* We have to digest the frame in 160-byte portions */
407  if (f->datalen > sizeof(sizbuf) - sizpos) {
408  ast_log(LOG_WARNING, "Frame too large\n");
409  res = -1;
410  } else {
411  memcpy(sizbuf + sizpos, f->data.ptr, f->datalen);
412  len += f->datalen;
413  state = snd_pcm_state(alsa.ocard);
414  if (state == SND_PCM_STATE_XRUN)
415  snd_pcm_prepare(alsa.ocard);
416  while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
417  usleep(1);
418  }
419  if (res == -EPIPE) {
420 #if DEBUG
421  ast_debug(1, "XRUN write\n");
422 #endif
423  snd_pcm_prepare(alsa.ocard);
424  while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
425  usleep(1);
426  }
427  if (res != len / 2) {
428  ast_log(LOG_ERROR, "Write error: %s\n", snd_strerror(res));
429  res = -1;
430  } else if (res < 0) {
431  ast_log(LOG_ERROR, "Write error %s\n", snd_strerror(res));
432  res = -1;
433  }
434  } else {
435  if (res == -ESTRPIPE)
436  ast_log(LOG_ERROR, "You've got some big problems\n");
437  else if (res < 0)
438  ast_log(LOG_NOTICE, "Error %d on write\n", res);
439  }
440  }
442 
443  return res >= 0 ? 0 : res;
444 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
union ast_frame::@254 data
snd_pcm_t * ocard
Definition: chan_alsa.c:133

References alsa, alsalock, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_frame::data, ast_frame::datalen, ESTRPIPE, len(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, chan_alsa_pvt::ocard, ast_frame::ptr, and state.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 1047 of file chan_alsa.c.

◆ console_answer()

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

Definition at line 684 of file chan_alsa.c.

685 {
686  char *res = CLI_SUCCESS;
687 
688  switch (cmd) {
689  case CLI_INIT:
690  e->command = "console answer";
691  e->usage =
692  "Usage: console answer\n"
693  " Answers an incoming call on the console (ALSA) channel.\n";
694 
695  return NULL;
696  case CLI_GENERATE:
697  return NULL;
698  }
699 
700  if (a->argc != 2)
701  return CLI_SHOWUSAGE;
702 
704 
705  if (!alsa.owner) {
706  ast_cli(a->fd, "No one is calling us\n");
707  res = CLI_FAILURE;
708  } else {
709  if (mute) {
710  ast_verbose( " << Muted >> \n" );
711  }
712  hookstate = 1;
713  grab_owner();
714  if (alsa.owner) {
717  }
718  }
719 
720  if (!noaudiocapture) {
721  snd_pcm_prepare(alsa.icard);
722  snd_pcm_start(alsa.icard);
723  }
724 
726 
727  return res;
728 }
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1225
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_SUCCESS
Definition: cli.h:44
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
@ CLI_INIT
Definition: cli.h:152
@ CLI_GENERATE
Definition: cli.h:153
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static struct test_val a

References a, alsa, alsalock, ast_channel_unlock, ast_cli(), AST_CONTROL_ANSWER, ast_mutex_lock, ast_mutex_unlock, ast_queue_control(), ast_verbose(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, grab_owner(), hookstate, chan_alsa_pvt::icard, mute, noaudiocapture, NULL, chan_alsa_pvt::owner, and ast_cli_entry::usage.

◆ console_autoanswer()

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

Definition at line 648 of file chan_alsa.c.

649 {
650  char *res = CLI_SUCCESS;
651 
652  switch (cmd) {
653  case CLI_INIT:
654  e->command = "console autoanswer [on|off]";
655  e->usage =
656  "Usage: console autoanswer [on|off]\n"
657  " Enables or disables autoanswer feature. If used without\n"
658  " argument, displays the current on/off status of autoanswer.\n"
659  " The default value of autoanswer is in 'alsa.conf'.\n";
660  return NULL;
661  case CLI_GENERATE:
662  return NULL;
663  }
664 
665  if ((a->argc != 2) && (a->argc != 3))
666  return CLI_SHOWUSAGE;
667 
669  if (a->argc == 2) {
670  ast_cli(a->fd, "Auto answer is %s.\n", autoanswer ? "on" : "off");
671  } else {
672  if (!strcasecmp(a->argv[2], "on"))
673  autoanswer = -1;
674  else if (!strcasecmp(a->argv[2], "off"))
675  autoanswer = 0;
676  else
677  res = CLI_SHOWUSAGE;
678  }
680 
681  return res;
682 }

References a, alsalock, ast_cli(), ast_mutex_lock, ast_mutex_unlock, autoanswer, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.

◆ console_dial()

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

Definition at line 817 of file chan_alsa.c.

818 {
819  char tmp[256], *tmp2;
820  char *mye, *myc;
821  const char *d;
822  char *res = CLI_SUCCESS;
823 
824  switch (cmd) {
825  case CLI_INIT:
826  e->command = "console dial";
827  e->usage =
828  "Usage: console dial [extension[@context]]\n"
829  " Dials a given extension (and context if specified)\n";
830  return NULL;
831  case CLI_GENERATE:
832  return NULL;
833  }
834 
835  if ((a->argc != 2) && (a->argc != 3))
836  return CLI_SHOWUSAGE;
837 
839 
840  if (alsa.owner) {
841  if (a->argc == 3) {
842  if (alsa.owner) {
843  for (d = a->argv[2]; *d; d++) {
844  struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = *d };
845 
847  }
848  }
849  } else {
850  ast_cli(a->fd, "You're already in a call. You can use this only to dial digits until you hangup\n");
851  res = CLI_FAILURE;
852  }
853  } else {
854  mye = exten;
855  myc = context;
856  if (a->argc == 3) {
857  char *stringp = NULL;
858 
859  ast_copy_string(tmp, a->argv[2], sizeof(tmp));
860  stringp = tmp;
861  strsep(&stringp, "@");
862  tmp2 = strsep(&stringp, "@");
863  if (!ast_strlen_zero(tmp))
864  mye = tmp;
865  if (!ast_strlen_zero(tmp2))
866  myc = tmp2;
867  }
868  if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
869  ast_copy_string(alsa.exten, mye, sizeof(alsa.exten));
870  ast_copy_string(alsa.context, myc, sizeof(alsa.context));
871  hookstate = 1;
873  } else
874  ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
875  }
876 
878 
879  return res;
880 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:122
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
@ AST_STATE_RINGING
Definition: channelstate.h:41
char * strsep(char **str, const char *delims)
#define AST_FRAME_DTMF
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:4182
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:406
enum ast_frame_type frametype
static struct test_val d

References a, alsa, alsa_new(), alsalock, ast_cli(), ast_copy_string(), ast_exists_extension(), AST_FRAME_DTMF, ast_mutex_lock, ast_mutex_unlock, ast_queue_frame(), AST_STATE_RINGING, ast_strlen_zero(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, context, chan_alsa_pvt::context, d, exten, chan_alsa_pvt::exten, ast_frame::frametype, hookstate, NULL, chan_alsa_pvt::owner, strsep(), tmp(), and ast_cli_entry::usage.

◆ console_hangup()

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

Definition at line 779 of file chan_alsa.c.

780 {
781  char *res = CLI_SUCCESS;
782 
783  switch (cmd) {
784  case CLI_INIT:
785  e->command = "console hangup";
786  e->usage =
787  "Usage: console hangup\n"
788  " Hangs up any call currently placed on the console.\n";
789  return NULL;
790  case CLI_GENERATE:
791  return NULL;
792  }
793 
794 
795  if (a->argc != 2)
796  return CLI_SHOWUSAGE;
797 
799 
800  if (!alsa.owner && !hookstate) {
801  ast_cli(a->fd, "No call to hangup\n");
802  res = CLI_FAILURE;
803  } else {
804  hookstate = 0;
805  grab_owner();
806  if (alsa.owner) {
809  }
810  }
811 
813 
814  return res;
815 }
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:106
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1160

References a, alsa, alsalock, AST_CAUSE_NORMAL_CLEARING, ast_channel_unlock, ast_cli(), ast_mutex_lock, ast_mutex_unlock, ast_queue_hangup_with_cause(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, grab_owner(), hookstate, NULL, chan_alsa_pvt::owner, and ast_cli_entry::usage.

◆ console_mute()

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

Definition at line 882 of file chan_alsa.c.

883 {
884  int toggle = 0;
885  char *res = CLI_SUCCESS;
886 
887  switch (cmd) {
888  case CLI_INIT:
889  e->command = "console {mute|unmute} [toggle]";
890  e->usage =
891  "Usage: console {mute|unmute} [toggle]\n"
892  " Mute/unmute the microphone.\n";
893  return NULL;
894  case CLI_GENERATE:
895  return NULL;
896  }
897 
898 
899  if (a->argc > 3) {
900  return CLI_SHOWUSAGE;
901  }
902 
903  if (a->argc == 3) {
904  if (strcasecmp(a->argv[2], "toggle"))
905  return CLI_SHOWUSAGE;
906  toggle = 1;
907  }
908 
909  if (a->argc < 2) {
910  return CLI_SHOWUSAGE;
911  }
912 
913  if (!strcasecmp(a->argv[1], "mute")) {
914  mute = toggle ? !mute : 1;
915  } else if (!strcasecmp(a->argv[1], "unmute")) {
916  mute = toggle ? !mute : 0;
917  } else {
918  return CLI_SHOWUSAGE;
919  }
920 
921  ast_cli(a->fd, "Console mic is %s\n", mute ? "off" : "on");
922 
923  return res;
924 }

◆ console_sendtext()

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

Definition at line 730 of file chan_alsa.c.

731 {
732  int tmparg = 3;
733  char *res = CLI_SUCCESS;
734 
735  switch (cmd) {
736  case CLI_INIT:
737  e->command = "console send text";
738  e->usage =
739  "Usage: console send text <message>\n"
740  " Sends a text message for display on the remote terminal.\n";
741  return NULL;
742  case CLI_GENERATE:
743  return NULL;
744  }
745 
746  if (a->argc < 3)
747  return CLI_SHOWUSAGE;
748 
750 
751  if (!alsa.owner) {
752  ast_cli(a->fd, "No channel active\n");
753  res = CLI_FAILURE;
754  } else {
755  struct ast_frame f = { AST_FRAME_TEXT };
756  char text2send[256] = "";
757 
758  while (tmparg < a->argc) {
759  strncat(text2send, a->argv[tmparg++], sizeof(text2send) - strlen(text2send) - 1);
760  strncat(text2send, " ", sizeof(text2send) - strlen(text2send) - 1);
761  }
762 
763  text2send[strlen(text2send) - 1] = '\n';
764  f.data.ptr = text2send;
765  f.datalen = strlen(text2send) + 1;
766  grab_owner();
767  if (alsa.owner) {
771  }
772  }
773 
775 
776  return res;
777 }
@ AST_FRAME_TEXT

References a, alsa, alsalock, ast_channel_unlock, ast_cli(), AST_CONTROL_ANSWER, AST_FRAME_TEXT, ast_mutex_lock, ast_mutex_unlock, ast_queue_control(), ast_queue_frame(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_frame::data, ast_frame::datalen, grab_owner(), NULL, chan_alsa_pvt::owner, ast_frame::ptr, and ast_cli_entry::usage.

◆ grab_owner()

static void grab_owner ( void  )
static

Definition at line 322 of file chan_alsa.c.

323 {
324  while (alsa.owner && ast_channel_trylock(alsa.owner)) {
326  }
327 }
#define ast_channel_trylock(chan)
Definition: channel.h:2924
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:477

References alsa, alsalock, ast_channel_trylock, DEADLOCK_AVOIDANCE, and chan_alsa_pvt::owner.

Referenced by alsa_call(), console_answer(), console_hangup(), and console_sendtext().

◆ 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 965 of file chan_alsa.c.

966 {
967  struct ast_config *cfg;
968  struct ast_variable *v;
969  struct ast_flags config_flags = { 0 };
970 
973  }
975 
976  /* Copy the default jb config over global_jbconf */
977  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
978 
979  strcpy(mohinterpret, "default");
980 
981  if (!(cfg = ast_config_load(config, config_flags))) {
982  ast_log(LOG_ERROR, "Unable to read ALSA configuration file %s. Aborting.\n", config);
984  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
985  ast_log(LOG_ERROR, "%s is in an invalid format. Aborting.\n", config);
987  }
988 
989  v = ast_variable_browse(cfg, "general");
990  for (; v; v = v->next) {
991  /* handle jb conf */
992  if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
993  continue;
994  }
995 
996  if (!strcasecmp(v->name, "autoanswer")) {
997  autoanswer = ast_true(v->value);
998  } else if (!strcasecmp(v->name, "mute")) {
999  mute = ast_true(v->value);
1000  } else if (!strcasecmp(v->name, "noaudiocapture")) {
1002  } else if (!strcasecmp(v->name, "silencesuppression")) {
1004  } else if (!strcasecmp(v->name, "silencethreshold")) {
1005  silencethreshold = atoi(v->value);
1006  } else if (!strcasecmp(v->name, "context")) {
1007  ast_copy_string(context, v->value, sizeof(context));
1008  } else if (!strcasecmp(v->name, "language")) {
1009  ast_copy_string(language, v->value, sizeof(language));
1010  } else if (!strcasecmp(v->name, "extension")) {
1011  ast_copy_string(exten, v->value, sizeof(exten));
1012  } else if (!strcasecmp(v->name, "input_device")) {
1013  ast_copy_string(indevname, v->value, sizeof(indevname));
1014  } else if (!strcasecmp(v->name, "output_device")) {
1016  } else if (!strcasecmp(v->name, "mohinterpret")) {
1018  }
1019  }
1020  ast_config_destroy(cfg);
1021 
1022  if (soundcard_init() < 0) {
1023  ast_verb(2, "No sound card detected -- console channel will be unavailable\n");
1024  ast_verb(2, "Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf\n");
1025  unload_module();
1026 
1027  return AST_MODULE_LOAD_DECLINE;
1028  }
1029 
1031  ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
1032  unload_module();
1033 
1034  return AST_MODULE_LOAD_DECLINE;
1035  }
1036 
1038 
1039  return AST_MODULE_LOAD_SUCCESS;
1040 }
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
static char outdevname[50]
Definition: chan_alsa.c:110
static struct ast_jb_conf default_jbconf
Definition: chan_alsa.c:76
static int soundcard_init(void)
Definition: chan_alsa.c:283
static int silencesuppression
Definition: chan_alsa.c:112
static const char config[]
Definition: chan_alsa.c:118
static int silencethreshold
Definition: chan_alsa.c:113
static int unload_module(void)
Definition: chan_alsa.c:935
static struct ast_cli_entry cli_alsa[]
Definition: chan_alsa.c:926
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:539
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
#define ast_config_load(filename, flags)
Load a config file.
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1215
#define ast_verb(level,...)
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097
Structure used to handle boolean flags.
Definition: utils.h:199
General jitterbuffer configuration.
Definition: abstract_jb.h:70
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
#define ARRAY_LEN(a)
Definition: utils.h:661

◆ soundcard_init()

static int soundcard_init ( void  )
static

Definition at line 283 of file chan_alsa.c.

284 {
285  if (!noaudiocapture) {
286  alsa.icard = alsa_card_init(indevname, SND_PCM_STREAM_CAPTURE);
287  if (!alsa.icard) {
288  ast_log(LOG_ERROR, "Problem opening alsa capture device\n");
289  return -1;
290  }
291  }
292 
293  alsa.ocard = alsa_card_init(outdevname, SND_PCM_STREAM_PLAYBACK);
294 
295  if (!alsa.ocard) {
296  ast_log(LOG_ERROR, "Problem opening ALSA playback device\n");
297  return -1;
298  }
299 
300  return writedev;
301 }
static snd_pcm_t * alsa_card_init(char *dev, snd_pcm_stream_t stream)
Definition: chan_alsa.c:177

References alsa, alsa_card_init(), ast_log, chan_alsa_pvt::icard, indevname, LOG_ERROR, noaudiocapture, chan_alsa_pvt::ocard, outdevname, and writedev.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 935 of file chan_alsa.c.

936 {
939 
940  if (alsa.icard)
941  snd_pcm_close(alsa.icard);
942  if (alsa.ocard)
943  snd_pcm_close(alsa.ocard);
944  if (alsa.owner)
946  if (alsa.owner)
947  return -1;
948 
951 
952  return 0;
953 }
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
@ AST_SOFTHANGUP_APPUNLOAD
Definition: channel.h:1143
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:570
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2470
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30

References alsa, alsa_tech, ao2_cleanup, ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_channel_tech::capabilities, cli_alsa, chan_alsa_pvt::icard, NULL, chan_alsa_pvt::ocard, and chan_alsa_pvt::owner.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ALSA 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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, }
static

Definition at line 965 of file chan_alsa.c.

◆ alsa

struct chan_alsa_pvt alsa
static

◆ alsa_tech

struct ast_channel_tech alsa_tech
static

Definition at line 160 of file chan_alsa.c.

Referenced by alsa_new(), and unload_module().

◆ alsalock

ast_mutex_t alsalock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
static

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 1047 of file chan_alsa.c.

◆ autoanswer

int autoanswer = 1
static

Definition at line 147 of file chan_alsa.c.

Referenced by alsa_call(), and console_autoanswer().

◆ cli_alsa

struct ast_cli_entry cli_alsa[]
static

Definition at line 882 of file chan_alsa.c.

Referenced by unload_module().

◆ config

const char config[] = "alsa.conf"
static

Definition at line 118 of file chan_alsa.c.

◆ context

char context[AST_MAX_CONTEXT] = "default"
static

Definition at line 120 of file chan_alsa.c.

Referenced by __after_bridge_set_goto(), __ast_channel_alloc(), __ast_channel_alloc_ap(), __has_voicemail(), __sip_alloc(), acf_vm_info(), action_atxfer(), action_blind_transfer(), action_dialplan_exec(), action_extensionstate(), action_originate(), action_redirect(), add_action_to_menu_entry(), add_extension(), add_hints(), add_sip_domain(), advanced_options(), append_mailbox(), append_mailbox_mapping(), apply_context(), ast_app_dtget(), ast_ari_channels_continue_in_dialplan(), ast_blind_transfer_message_create(), ast_bridge_set_after_go_on(), ast_bridge_set_after_goto(), ast_bridge_set_after_h(), ast_bridge_setup_after_goto(), ast_canmatch_extension(), ast_cdr_fork(), ast_channel_by_exten_cb(), ast_channel_get_by_exten(), ast_channel_iterator_by_exten_new(), ast_compile_ael2(), ast_context_remove_extension(), ast_context_remove_extension_callerid(), ast_context_remove_include(), ast_context_remove_switch(), ast_delete_mwi_state_full(), ast_devstate_to_extenstate(), ast_exists_extension(), ast_extension_state(), ast_extension_state_add(), ast_extension_state_add_destroy(), ast_extension_state_add_destroy_extended(), ast_extension_state_add_extended(), ast_extension_state_extended(), ast_findlabel_extension(), ast_get_enum(), ast_get_hint(), ast_get_srv(), ast_get_txt(), ast_hint_extension_nolock(), ast_hint_presence_state(), ast_json_dialplan_cep(), ast_json_dialplan_cep_app(), ast_matchmore_extension(), ast_msg_alloc(), ast_msg_set_context(), ast_mwi_create(), ast_mwi_publish_by_mailbox(), ast_parking_blind_transfer_park(), ast_parking_is_exten_park(), ast_pbx_h_exten_run(), ast_publish_mwi_state_full(), ast_res_pjsip_initialize_configuration(), ast_search_dns(), ast_sip_cli_print_sorcery_objectset(), ast_sip_cli_traverse_objects(), ast_spawn_extension(), ast_srv_cleanup(), ast_srv_get_nth_record(), ast_srv_get_record_count(), ast_srv_lookup(), ast_str_get_hint(), AST_TEST_DEFINE(), ast_unreal_new_channels(), ast_vm_mailbox_snapshot_create(), ast_vm_msg_move(), ast_vm_msg_play(), ast_vm_msg_remove(), ast_waitstream_exten(), ast_xml_query(), ast_xml_query_with_namespaces(), attended_transfer_exec(), attended_transfer_properties_alloc(), base_process_party_a(), blind_transfer_exec(), blr_ebl(), blr_txt(), bridge_channel_internal_queue_blind_transfer(), bridge_exec(), build_context(), build_peer(), canmatch(), cb_extensionstate(), cc_extension_monitor_init(), cdr_object_create_and_append(), channel_snapshot_dialplan_create(), check_access(), check_sip_domain(), cli_aor_print_body(), cli_aor_print_header(), cli_channel_print_body(), cli_channel_print_header(), cli_channelstats_print_body(), cli_channelstats_print_header(), cli_contact_print_body(), cli_contact_print_header(), cli_endpoint_print_child_body(), cli_endpoint_print_child_header(), cli_endpoint_print_header(), cli_print_body(), cli_print_header(), cli_unid_print_header(), common_exec(), complete_dialplan_add_include(), complete_dialplan_remove_extension(), complete_dialplan_remove_include(), complete_voicemail_show_users(), conf_run(), config_parse_variables(), console_dial(), context_used(), copy_plain_file(), copy_to_voicemail(), create_addr_from_peer(), create_dirpath(), create_queue_member(), custom_devstate_callback(), delete_existing_cb(), delete_extens(), disa_exec(), dns_parse_answer(), dns_parse_answer_ex(), dns_system_resolver_add_record(), dns_system_resolver_set_response(), do_directory(), do_magic_pickup(), dp_lookup(), dundi_canmatch(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_exec(), dundi_exists(), dundi_helper(), dundi_ie_append_eid_appropriately(), dundi_matchmore(), dundi_precache(), dundi_precache_internal(), dundi_show_cache(), ebl_callback(), enum_callback(), exec(), execute_state_callback(), exists(), expand_gosub_args(), exten_state_publisher_state_cb(), extension_state_add_destroy(), extension_state_cb(), extensionstate_update(), extenspy_exec(), find_context(), find_context_locked(), find_label_in_current_db(), find_or_create(), find_user(), find_user_realtime(), forward_message(), get_also_info(), get_cid_name(), get_resource_display_name(), get_transfer_context(), gosub_allocate_frame(), goto_parser(), grab_transfer(), handle_blind_transfer(), handle_cli_dialplan_remove_extension(), handle_request_bye(), handle_request_invite(), handle_request_options(), handle_request_refer(), handle_show_dialplan(), handle_voicemail_show_users(), has_voicemail(), hook_on(), hook_state_alloc(), iax2_call(), iax2_canmatch(), iax2_exec(), iax2_exists(), iax2_matchmore(), iax2_transfer(), inboxcount2(), init_hook(), init_queue(), inprocess_count(), internal_extension_state_extended(), invent_message(), ip_identify_match_srv_lookup(), isexten_function_read(), leave_voicemail(), load_config(), load_module(), local_alloc(), local_devicestate(), localized_find_extension(), log_exec(), loopback_subst(), lua_find_extension(), lua_pbx_exec(), lua_register_hints(), lua_register_switches(), lua_sort_extensions(), lua_update_registry(), make_dir(), make_email_file(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), manager_match_mailbox(), manager_state_cb(), manager_status_voicemail_user(), matchmore(), messagecount(), mwi_create_state(), mwi_state_create_message(), mwi_to_event(), new_subscribe(), onedigit_goto(), orig_exten(), park_local_transfer(), parking_add_extension(), parking_blind_transfer_park(), parking_is_exten_park(), parking_notify_metermaids(), parse_line(), pbx_builtin_background(), pbx_extension_helper(), pbx_find_extension(), pbx_substitute_variables_helper_full_location(), pickup_by_exten(), pickup_exec(), play_mailbox_owner(), play_message(), play_message_by_id(), play_message_callerid(), prep_email_sub_vars(), print_escaped_uri(), print_sanitize_debug(), print_uri_debug(), process_precache(), process_weights(), publish_mwi_to_stasis(), publisher_start(), pubsub_on_rx_mwi_notify_request(), pvalGotoGetTarget(), pvalGotoSetTarget(), queue_mwi_event(), queue_set_param(), raise_exception(), readexten_exec(), realtime_canmatch(), realtime_common(), realtime_directory(), realtime_exec(), realtime_exists(), realtime_matchmore(), realtime_switch_common(), receive_message(), refer_incoming_attended_request(), refer_incoming_blind_request(), register_exten(), register_peer_exten(), reload_config(), reschedule_precache(), reset_user_pw(), retrydial_exec(), run_externnotify(), save_to_folder(), sayname(), search_directory(), search_directory_sub(), sendmail(), sendpage(), separate_mailbox(), set_peer_defaults(), set_pvt_defaults(), setup_peer_after_bridge_goto(), SHA1FinalBits(), SHA1Finalize(), SHA1Input(), SHA1PadMessage(), SHA1ProcessMessageBlock(), SHA1Reset(), SHA1Result(), show_debug_helper(), show_dialplan_helper(), show_users_realtime(), sip_cli_print_global(), sip_cli_print_system(), skinny_extensionstate_cb(), socket_process_helper(), spawn_dp_lookup(), spy_sayname(), srv_callback(), stasis_app_control_continue(), state_notify_build_xml(), store_config_core(), test_vm_api_create_mock_snapshot(), test_vm_api_create_voicemail_files(), try_redirect(), txt_callback(), unregister_exten(), vm_authenticate(), vm_execmain(), vm_mailbox_snapshot_create(), vm_msg_move(), vm_msg_remove(), vm_playmsgexec(), vm_sayname(), vmauthenticate(), wait_for_answer(), and waitstream_core().

◆ 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 alsa.conf.sample

Definition at line 1 of file chan_alsa.c.

◆ exten

char exten[AST_MAX_EXTENSION] = "s"
static

Definition at line 122 of file chan_alsa.c.

Referenced by __after_bridge_set_goto(), __analog_ss_thread(), __ast_channel_alloc(), __ast_channel_alloc_ap(), action_atxfer(), action_blind_transfer(), action_dialplan_exec(), action_extensionstate(), action_originate(), action_redirect(), add_action_to_menu_entry(), add_extension(), add_extensions(), add_hints(), add_user_extension(), alloc_notify_task_data(), analog_canmatch_featurecode(), analog_ss_thread(), ast_ari_channels_continue_in_dialplan(), ast_blind_transfer_message_create(), ast_bridge_set_after_go_on(), ast_bridge_set_after_goto(), ast_bridge_setup_after_goto(), ast_canmatch_extension(), ast_cdr_fork(), ast_channel_by_exten_cb(), ast_channel_get_by_exten(), ast_channel_iterator_by_exten_new(), ast_compile_ael2(), ast_context_remove_extension_callerid2(), ast_devstate_to_extenstate(), ast_exists_extension(), ast_extension_state(), ast_extension_state_add(), ast_extension_state_add_destroy(), ast_extension_state_add_destroy_extended(), ast_extension_state_add_extended(), ast_extension_state_extended(), ast_findlabel_extension(), ast_findlabel_extension2(), ast_get_extension_name(), ast_get_hint(), ast_hint_extension_nolock(), ast_hint_presence_state(), ast_is_shrinkable_phonenumber(), ast_is_valid_string(), ast_ivr_menu_run_internal(), ast_json_dialplan_cep(), ast_json_dialplan_cep_app(), ast_matchmore_extension(), ast_msg_set_exten(), ast_parking_blind_transfer_park(), ast_parking_is_exten_park(), ast_parking_park_call(), ast_phoneprov_add_extension(), ast_spawn_extension(), ast_str_get_hint(), AST_TEST_DEFINE(), ast_unreal_new_channels(), ast_walk_context_extensions(), ast_walk_extension_priorities(), attended_transfer_exec(), base_process_party_a(), blind_transfer_exec(), bridge_channel_internal_queue_blind_transfer(), build_extension(), canmatch(), canmatch_featurecode(), cb_extensionstate(), cc_extension_monitor_init(), cdr_object_create_and_append(), chan_pjsip_new(), channel_snapshot_dialplan_create(), check_access(), common_exec(), complete_dialplan_remove_extension(), complete_dpreply(), config_parse_variables(), console_dial(), context_used(), copy_plain_file(), create_queue_member(), custom_devstate_callback(), delete_existing_cb(), delete_extens(), delete_extension(), destroy_extensions(), dialandactivatesub(), disa_exec(), do_directory(), dundi_canmatch(), dundi_exec(), dundi_exists(), dundi_helper(), dundi_matchmore(), exec(), execute_state_callback(), exists(), expand_gosub_args(), ext_fluff_count(), exten_state_pub_data_alloc(), exten_state_publisher_state_cb(), extension_matches(), extension_state_add_destroy(), extension_state_cb(), extensionstate_update(), extenspy_exec(), feature_attended_transfer(), find_cache(), find_label_in_current_context(), find_label_in_current_db(), find_matching_priority(), fix_gotos_in_extensions(), gen_prios(), get_cid_name(), get_destination(), goto_parser(), grab_transfer(), handle_blind_transfer(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_remove_extension(), handle_request_invite(), handle_show_dialplan(), hook_on(), hook_state_alloc(), iax2_canmatch(), iax2_exec(), iax2_exists(), iax2_matchmore(), init_hook(), initreqprep(), internal_extension_state_extended(), isexten_function_read(), leave_voicemail(), linkexten(), linkprio(), local_devicestate(), localized_find_extension(), localized_walk_context_extensions(), localized_walk_extension_priorities(), loopback_canmatch(), loopback_exists(), loopback_matchmore(), loopback_subst(), lua_find_extension(), lua_pbx_exec(), lua_sort_extensions(), lua_update_registry(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), manager_state_cb(), matchmore(), mgcp_ss(), new_iax(), onedigit_goto(), options_on_rx_request(), orig_exten(), originate_exec(), osplookup_exec(), park_local_transfer(), parking_blind_transfer_park(), parking_is_exten_park(), parking_notify_metermaids(), parking_park_call(), parse_line(), pbx_builtin_background(), pbx_extension_helper(), pbx_find_extension(), pbx_substitute_variables_helper_full_location(), pickup_by_exten(), pickup_exec(), pp_each_extension_helper(), publisher_start(), pvalGotoGetTarget(), pvalGotoSetTarget(), raise_exception(), read_newoption(), readexten_exec(), realtime_canmatch(), realtime_common(), realtime_exec(), realtime_exists(), realtime_matchmore(), realtime_switch_common(), refer_incoming_blind_request(), session_inv_on_redirected(), set_ext_pri(), set_priorities(), set_pvt_defaults(), show_dialplan_helper(), show_dialplan_helper_extension_output(), sip_new(), sip_request_call(), skinny_extensionstate_cb(), sla_build_station(), sla_station_destructor(), socket_process_helper(), state_changed(), state_notify_build_xml(), store_config_core(), test_exten(), test_vm_api_create_mock_snapshot(), test_vm_api_destroy_mailbox_voicemails(), test_vm_api_test_setup(), test_vm_api_update_test_snapshots(), transmit_notify_with_mwi(), transmit_register(), update_scoreboard(), user_destructor(), vm_msg_snapshot_create(), and waitstream_core().

◆ format

snd_pcm_format_t format = SND_PCM_FORMAT_S16_BE
static

Definition at line 106 of file chan_alsa.c.

Referenced by __ast_asprintf(), __ast_format_cap_append(), __ast_repl_asprintf(), __ast_repl_vasprintf(), __ast_string_field_ptr_build(), __ast_string_field_ptr_build_va(), __ast_vasprintf(), acf_sprintf(), acf_strftime(), acf_strptime(), FaxPcap::add(), add_codec_to_sdp(), add_email_attachment(), add_format_information_cb(), add_noncodec_to_sdp(), add_sdp(), add_static_payload(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), adsi_input_control(), alsa_card_init(), apply_cap_to_bundled(), ast_adsi_input_control(), ast_ari_recordings_get_stored_file(), ast_audiohook_read_frame(), ast_audiohook_read_frame_all(), ast_channel_set_oldwriteformat(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_format_attribute_get(), ast_format_attribute_set(), ast_format_cache_get_by_codec(), ast_format_cache_is_slinear(), ast_format_cache_set(), ast_format_can_be_smoothed(), ast_format_cap_append_by_type(), ast_format_cap_get_compatible(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format_framing(), ast_format_cap_remove(), ast_format_cap_update_by_allow_disallow(), ast_format_clone(), ast_format_compatibility_format2bitfield(), ast_format_create_named(), ast_format_determine_length(), ast_format_generate_sdp_fmtp(), ast_format_get_attribute_data(), ast_format_get_channel_count(), ast_format_get_codec(), ast_format_get_codec_id(), ast_format_get_codec_name(), ast_format_get_default_ms(), ast_format_get_maximum_ms(), ast_format_get_minimum_bytes(), ast_format_get_minimum_ms(), ast_format_get_name(), ast_format_get_sample_rate(), ast_format_get_smoother_flags(), ast_format_parse_sdp_fmtp(), ast_format_set_attribute_data(), ast_format_set_channel_count(), ast_iostream_printf(), ast_json_dump_file_format(), ast_json_dump_new_file_format(), ast_json_dump_str_format(), ast_json_dump_string_format(), ast_json_pack(), ast_json_stringf(), ast_json_vpack(), ast_json_vstringf(), ast_monitor_stop(), ast_openvstream(), ast_read_image(), ast_rtp_codecs_get_payload_format(), ast_rtp_codecs_payload_code(), ast_rtp_codecs_payload_code_tx(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payload_set_rx(), ast_rtp_engine_load_format(), ast_rtp_engine_unload_format(), ast_rtp_instance_set_read_format(), ast_rtp_instance_set_write_format(), ast_rtp_lookup_mime_subtype2(), ast_rtp_lookup_sample_rate2(), ast_rtp_write(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_is(), ast_say_date_with_format_it(), ast_say_date_with_format_ja(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), ast_set_read_format(), ast_set_write_format(), ast_set_write_format_interleaved_stereo(), ast_sockaddr_stringify_fmt(), ast_strftime_locale(), ast_strptime(), ast_strptime_locale(), ast_taskprocessor_build_name(), AST_TEST_DEFINE(), ast_udptl_set_tag(), audiohook_read_frame_helper(), auth_http_callback(), build_peer(), build_profile(), build_user(), celt_cmp(), celt_destroy(), celt_parse_sdp_fmtp(), chat(), check_header(), check_header_fmt(), configure_local_rtp(), create_addr(), create_outgoing_sdp_stream(), create_video_frame(), dahdi_format_to_cached(), dump_flags(), error(), fatalerror(), file2format(), file_read(), find_static_payload_type(), format2index(), format_cap_framed_init(), format_cap_replace(), format_destroy(), format_hash_cb(), format_in_format_cap(), generate_fmtp_attr(), generate_rtpmap_attr(), generic_http_callback(), get_codecs(), get_soxmix_format(), h263_destroy(), h263_generate_sdp_fmtp(), h263_parse_sdp_fmtp(), h264_destroy(), h264_generate_sdp_fmtp(), h264_parse_sdp_fmtp(), handle_response_setup(), handle_saydatetime(), iax2_codec_choose(), iax2_codec_pref_append(), iax2_codec_pref_best_bitfield2cap(), iax2_codec_pref_from_bitfield(), iax2_codec_pref_prepend(), iax2_format_compatibility_bitfield2cap(), iax2_format_compatibility_cap2bitfield(), iax2_getformatname(), iax2_getformatname_multiple(), iax2_request(), ilbc_destroy(), ilbc_generate_sdp_fmtp(), ilbc_parse_sdp_fmtp(), inform(), jingle_add_payloads_to_description(), load_config(), spandspflow2pcap::main(), make_email_file(), map_video_codec(), minivm_notify_exec(), multicast_rtp_write(), next_item(), notify_new_message(), ooh323_convertAsteriskCapToH323Cap(), ooh323c_set_capability(), ooh323c_set_capability_for_call(), opus_destroy(), opus_generate_sdp_fmtp(), opus_get(), opus_parse_sdp_fmtp(), opus_set(), process_output(), process_sdp_a_audio(), process_sdp_a_video(), reload_config(), rtp_codecs_assign_payload_code_rx(), rtp_get_rate(), rtp_payload_type_alloc(), say(), say_date_generic(), say_date_with_format(), sayunixtime_exec(), sendmail(), set_cached_format(), set_config(), set_format(), set_next_mime_type(), show_sound_info_cb(), silk_cmp(), silk_destroy(), silk_get(), silk_parse_sdp_fmtp(), silk_set(), siren14_parse_sdp_fmtp(), siren7_parse_sdp_fmtp(), socket_process_helper(), speech_aeap_engine_create(), start_monitor_action(), start_monitor_exec(), stasis_app_recording_options_create(), stasis_app_stored_recording_copy(), test_core_format_attribute_get(), test_core_format_attribute_set(), test_core_format_destroy(), test_core_format_generate_sdp_fmtp(), test_core_format_parse_sdp_fmtp(), AllowableRange::to_wiki(), AllowableList::to_wiki(), transmit_connect_with_sdp(), transmit_modify_request(), transmit_modify_with_sdp(), transmit_startmediatransmission(), fe6592859b85_fix_mwi_subscribe_replaces_::upgrade(), vp8_destroy(), vp8_generate_sdp_fmtp(), vp8_parse_sdp_fmtp(), and xml_translate().

◆ global_jbconf

struct ast_jb_conf global_jbconf
static

Definition at line 1 of file chan_alsa.c.

Referenced by alsa_new().

◆ hookstate

int hookstate = 0
static

Definition at line 125 of file chan_alsa.c.

Referenced by alsa_hangup(), console_answer(), console_dial(), and console_hangup().

◆ indevname

char indevname[50] = ALSA_INDEV
static

Definition at line 109 of file chan_alsa.c.

Referenced by alsa_new(), and soundcard_init().

◆ language

char language[MAX_LANGUAGE] = ""
static

◆ mohinterpret

char mohinterpret[MAX_MUSICCLASS]
static

◆ mute

int mute = 0
static

◆ noaudiocapture

int noaudiocapture = 0
static

◆ outdevname

char outdevname[50] = ALSA_OUTDEV
static

Definition at line 110 of file chan_alsa.c.

Referenced by soundcard_init().

◆ readdev

int readdev = -1
static

Definition at line 144 of file chan_alsa.c.

Referenced by alsa_card_init(), and alsa_new().

◆ silencesuppression

int silencesuppression = 0
static

Definition at line 112 of file chan_alsa.c.

◆ silencethreshold

int silencethreshold = 1000
static

Definition at line 113 of file chan_alsa.c.

◆ tdesc

const char tdesc[] = "ALSA Console Channel Driver"
static

Definition at line 117 of file chan_alsa.c.

◆ writedev

int writedev = -1
static

Definition at line 145 of file chan_alsa.c.

Referenced by alsa_card_init(), and soundcard_init().