Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
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"

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_EXTENDED, .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 83 of file chan_alsa.c.

◆ ALSA_OUTDEV

#define ALSA_OUTDEV   "default"

Definition at line 84 of file chan_alsa.c.

◆ ALSA_PCM_NEW_HW_PARAMS_API

#define ALSA_PCM_NEW_HW_PARAMS_API

Definition at line 50 of file chan_alsa.c.

◆ ALSA_PCM_NEW_SW_PARAMS_API

#define ALSA_PCM_NEW_SW_PARAMS_API

Definition at line 51 of file chan_alsa.c.

◆ BUFFER_FMT

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

Definition at line 94 of file chan_alsa.c.

◆ DEBUG

#define DEBUG   0

Definition at line 81 of file chan_alsa.c.

Referenced by __big_split(), and hash_seq().

◆ DESIRED_RATE

#define DESIRED_RATE   8000

Definition at line 85 of file chan_alsa.c.

Referenced by alsa_card_init().

◆ ESTRPIPE

#define ESTRPIPE   EPIPE

Definition at line 44 of file chan_alsa.c.

Referenced by alsa_read(), and alsa_write().

◆ FRAME_SIZE

#define FRAME_SIZE   160

Definition at line 88 of file chan_alsa.c.

Referenced by alsa_read().

◆ MAX_BUFFER_SIZE

#define MAX_BUFFER_SIZE   100

Definition at line 137 of file chan_alsa.c.

◆ MIN_SWITCH_TIME

#define MIN_SWITCH_TIME   600

Definition at line 97 of file chan_alsa.c.

◆ PERIOD_FRAMES

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

Definition at line 89 of file chan_alsa.c.

Referenced by alsa_card_init().

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 1043 of file chan_alsa.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 1043 of file chan_alsa.c.

◆ alsa_answer()

static int alsa_answer ( struct ast_channel c)
static

Definition at line 361 of file chan_alsa.c.

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

362 {
364  ast_verbose(" << Console call has been answered >> \n");
366  if (!noaudiocapture) {
367  snd_pcm_prepare(alsa.icard);
368  snd_pcm_start(alsa.icard);
369  }
371 
372  return 0;
373 }
snd_pcm_t * icard
Definition: chan_alsa.c:129
static struct chan_alsa_pvt alsa
static int noaudiocapture
Definition: chan_alsa.c:145
#define ast_mutex_lock(a)
Definition: lock.h:187
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7325
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_call()

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

Definition at line 325 of file chan_alsa.c.

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.

326 {
327  struct ast_frame f = { AST_FRAME_CONTROL };
328 
330  ast_verbose(" << Call placed to '%s' on console >> \n", dest);
331  if (autoanswer) {
332  ast_verbose(" << Auto-answered >> \n");
333  if (mute) {
334  ast_verbose( " << Muted >> \n" );
335  }
336  grab_owner();
337  if (alsa.owner) {
341  }
342  } else {
343  ast_verbose(" << Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
344  grab_owner();
345  if (alsa.owner) {
350  }
351  }
352  if (!noaudiocapture) {
353  snd_pcm_prepare(alsa.icard);
354  snd_pcm_start(alsa.icard);
355  }
357 
358  return 0;
359 }
struct ast_channel * owner
Definition: chan_alsa.c:126
snd_pcm_t * icard
Definition: chan_alsa.c:129
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4271
static struct chan_alsa_pvt alsa
static int noaudiocapture
Definition: chan_alsa.c:145
static int autoanswer
Definition: chan_alsa.c:143
#define ast_mutex_lock(a)
Definition: lock.h:187
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
struct ast_frame_subclass subclass
static int mute
Definition: chan_alsa.c:144
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
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_channel_unlock(chan)
Definition: channel.h:2838
static void grab_owner(void)
Definition: chan_alsa.c:318
Data structure associated with a single frame of data.
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_card_init()

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

Definition at line 173 of file chan_alsa.c.

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

Referenced by soundcard_init().

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

◆ alsa_digit()

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

Definition at line 299 of file chan_alsa.c.

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

300 {
302  ast_verbose(" << Console Received digit %c of duration %u ms >> \n",
303  digit, duration);
305 
306  return 0;
307 }
char digit
#define ast_mutex_lock(a)
Definition: lock.h:187
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_fixup()

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

Definition at line 531 of file chan_alsa.c.

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

532 {
533  struct chan_alsa_pvt *p = ast_channel_tech_pvt(newchan);
534 
536  p->owner = newchan;
538 
539  return 0;
540 }
struct ast_channel * owner
Definition: chan_alsa.c:126
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_mutex_lock(a)
Definition: lock.h:187
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_hangup()

static int alsa_hangup ( struct ast_channel c)
static

Definition at line 375 of file chan_alsa.c.

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

376 {
379  alsa.owner = NULL;
380  ast_verbose(" << Hangup on console >> \n");
382  hookstate = 0;
383  if (!noaudiocapture) {
384  snd_pcm_drop(alsa.icard);
385  }
387 
388  return 0;
389 }
struct ast_channel * owner
Definition: chan_alsa.c:126
snd_pcm_t * icard
Definition: chan_alsa.c:129
static struct chan_alsa_pvt alsa
static int noaudiocapture
Definition: chan_alsa.c:145
#define ast_mutex_lock(a)
Definition: lock.h:187
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 ast_mutex_t alsalock
Definition: chan_alsa.c:111
static int hookstate
Definition: chan_alsa.c:121
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_indicate()

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

Definition at line 542 of file chan_alsa.c.

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(), LOG_WARNING, and mohinterpret.

543 {
544  int res = 0;
545 
547 
548  switch (cond) {
549  case AST_CONTROL_BUSY:
551  case AST_CONTROL_RINGING:
554  case -1:
555  res = -1; /* Ask for inband indications */
556  break;
561  break;
562  case AST_CONTROL_HOLD:
563  ast_verbose(" << Console Has Been Placed on Hold >> \n");
564  ast_moh_start(chan, data, mohinterpret);
565  break;
566  case AST_CONTROL_UNHOLD:
567  ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
568  ast_moh_stop(chan);
569  break;
570  default:
571  ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, ast_channel_name(chan));
572  res = -1;
573  }
574 
576 
577  return res;
578 }
static char mohinterpret[MAX_MUSICCLASS]
Definition: chan_alsa.c:119
#define LOG_WARNING
Definition: logger.h:274
#define ast_mutex_lock(a)
Definition: lock.h:187
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
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
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
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_mutex_unlock(a)
Definition: lock.h:188

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

References 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().

581 {
582  struct ast_channel *tmp = NULL;
583 
584  if (!(tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, assignedids, requestor, 0, "ALSA/%s", indevname)))
585  return NULL;
586 
588 
590  ast_channel_set_fd(tmp, 0, readdev);
594 
595  ast_channel_tech_pvt_set(tmp, p);
596  if (!ast_strlen_zero(p->context))
598  if (!ast_strlen_zero(p->exten))
599  ast_channel_exten_set(tmp, p->exten);
601  ast_channel_language_set(tmp, language);
602  p->owner = tmp;
605 
607  ast_channel_unlock(tmp);
608 
609  if (state != AST_STATE_DOWN) {
610  if (ast_pbx_start(tmp)) {
611  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
612  ast_hangup(tmp);
613  tmp = NULL;
614  }
615  }
616 
617  return tmp;
618 }
struct ast_channel * owner
Definition: chan_alsa.c:126
Main Channel structure associated with a channel.
static struct ast_channel_tech alsa_tech
Definition: chan_alsa.c:158
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
#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
static struct ast_jb_conf global_jbconf
Definition: chan_alsa.c:79
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
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
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
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_set_readformat(struct ast_channel *chan, struct ast_format *format)
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:117
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:128
char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:127
struct ast_format_cap * capabilities
Definition: channel.h:633
static char indevname[50]
Definition: chan_alsa.c:105
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_channel_unlock(chan)
Definition: channel.h:2838
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2523
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
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
const char * ast_channel_name(const struct ast_channel *chan)
#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
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
static int readdev
Definition: chan_alsa.c:140
#define ast_module_ref(mod)
Hold a reference to the module.
Definition: module.h:443

◆ alsa_read()

static struct ast_frame * alsa_read ( struct ast_channel chan)
static

Definition at line 443 of file chan_alsa.c.

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.

444 {
445  static struct ast_frame f;
446  static short __buf[FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
447  short *buf;
448  static int readpos = 0;
449  static int left = FRAME_SIZE;
450  snd_pcm_state_t state;
451  int r = 0;
452 
454  f.frametype = AST_FRAME_NULL;
455  f.subclass.integer = 0;
456  f.samples = 0;
457  f.datalen = 0;
458  f.data.ptr = NULL;
459  f.offset = 0;
460  f.src = "Console";
461  f.mallocd = 0;
462  f.delivery.tv_sec = 0;
463  f.delivery.tv_usec = 0;
464 
465  if (noaudiocapture) {
466  /* Return null frame to asterisk*/
468  return &f;
469  }
470 
471  state = snd_pcm_state(alsa.icard);
472  if ((state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING)) {
473  snd_pcm_prepare(alsa.icard);
474  }
475 
476  buf = __buf + AST_FRIENDLY_OFFSET / 2;
477 
478  r = snd_pcm_readi(alsa.icard, buf + readpos, left);
479  if (r == -EPIPE) {
480 #if DEBUG
481  ast_log(LOG_ERROR, "XRUN read\n");
482 #endif
483  snd_pcm_prepare(alsa.icard);
484  } else if (r == -ESTRPIPE) {
485  ast_log(LOG_ERROR, "-ESTRPIPE\n");
486  snd_pcm_prepare(alsa.icard);
487  } else if (r < 0) {
488  ast_log(LOG_ERROR, "Read error: %s\n", snd_strerror(r));
489  }
490 
491  /* Return NULL frame on error */
492  if (r < 0) {
494  return &f;
495  }
496 
497  /* Update positions */
498  readpos += r;
499  left -= r;
500 
501  if (readpos >= FRAME_SIZE) {
502  /* A real frame */
503  readpos = 0;
504  left = FRAME_SIZE;
505  if (ast_channel_state(chan) != AST_STATE_UP) {
506  /* Don't transmit unless it's up */
508  return &f;
509  }
510  if (mute) {
511  /* Don't transmit if muted */
513  return &f;
514  }
515 
516  f.frametype = AST_FRAME_VOICE;
517  f.subclass.format = ast_format_slin;
518  f.samples = FRAME_SIZE;
519  f.datalen = FRAME_SIZE * 2;
520  f.data.ptr = buf;
521  f.offset = AST_FRIENDLY_OFFSET;
522  f.src = "Console";
523  f.mallocd = 0;
524 
525  }
527 
528  return &f;
529 }
enum sip_cc_notify_state state
Definition: chan_sip.c:956
#define FRAME_SIZE
Definition: chan_alsa.c:88
snd_pcm_t * icard
Definition: chan_alsa.c:129
static struct chan_alsa_pvt alsa
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int noaudiocapture
Definition: chan_alsa.c:145
ast_channel_state
ast_channel states
Definition: channelstate.h:35
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static int mute
Definition: chan_alsa.c:144
#define ast_log
Definition: astobj2.c:42
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
#define LOG_ERROR
Definition: logger.h:285
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
Data structure associated with a single frame of data.
#define ESTRPIPE
Definition: chan_alsa.c:44
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
#define ast_mutex_unlock(a)
Definition: lock.h:188

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

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().

621 {
622  struct ast_channel *tmp = NULL;
623 
625  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
626  ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_format_cap_get_names(cap, &codec_buf));
627  return NULL;
628  }
629 
631 
632  if (alsa.owner) {
633  ast_log(LOG_NOTICE, "Already have a call on the ALSA channel\n");
634  *cause = AST_CAUSE_BUSY;
635  } else if (!(tmp = alsa_new(&alsa, AST_STATE_DOWN, assignedids, requestor))) {
636  ast_log(LOG_WARNING, "Unable to create new ALSA channel\n");
637  }
638 
640 
641  return tmp;
642 }
struct ast_channel * owner
Definition: chan_alsa.c:126
Main Channel structure associated with a channel.
static struct chan_alsa_pvt alsa
#define LOG_WARNING
Definition: logger.h:274
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
static int tmp()
Definition: bt_open.c:389
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:580
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_str_alloca(init_len)
Definition: strings.h:800
#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
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#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
#define AST_CAUSE_BUSY
Definition: causes.h:148
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_text()

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

Definition at line 309 of file chan_alsa.c.

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

310 {
312  ast_verbose(" << Console Received text %s >> \n", text);
314 
315  return 0;
316 }
#define ast_mutex_lock(a)
Definition: lock.h:187
char * text
Definition: app_queue.c:1511
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ alsa_write()

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

Definition at line 391 of file chan_alsa.c.

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.

392 {
393  static char sizbuf[8000];
394  static int sizpos = 0;
395  int len = sizpos;
396  int res = 0;
397  /* size_t frames = 0; */
398  snd_pcm_state_t state;
399 
401 
402  /* We have to digest the frame in 160-byte portions */
403  if (f->datalen > sizeof(sizbuf) - sizpos) {
404  ast_log(LOG_WARNING, "Frame too large\n");
405  res = -1;
406  } else {
407  memcpy(sizbuf + sizpos, f->data.ptr, f->datalen);
408  len += f->datalen;
409  state = snd_pcm_state(alsa.ocard);
410  if (state == SND_PCM_STATE_XRUN)
411  snd_pcm_prepare(alsa.ocard);
412  while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
413  usleep(1);
414  }
415  if (res == -EPIPE) {
416 #if DEBUG
417  ast_debug(1, "XRUN write\n");
418 #endif
419  snd_pcm_prepare(alsa.ocard);
420  while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
421  usleep(1);
422  }
423  if (res != len / 2) {
424  ast_log(LOG_ERROR, "Write error: %s\n", snd_strerror(res));
425  res = -1;
426  } else if (res < 0) {
427  ast_log(LOG_ERROR, "Write error %s\n", snd_strerror(res));
428  res = -1;
429  }
430  } else {
431  if (res == -ESTRPIPE)
432  ast_log(LOG_ERROR, "You've got some big problems\n");
433  else if (res < 0)
434  ast_log(LOG_NOTICE, "Error %d on write\n", res);
435  }
436  }
438 
439  return res >= 0 ? 0 : res;
440 }
enum sip_cc_notify_state state
Definition: chan_sip.c:956
snd_pcm_t * ocard
Definition: chan_alsa.c:129
static struct chan_alsa_pvt alsa
#define LOG_WARNING
Definition: logger.h:274
#define ast_mutex_lock(a)
Definition: lock.h:187
union ast_frame::@255 data
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define LOG_NOTICE
Definition: logger.h:263
#define ESTRPIPE
Definition: chan_alsa.c:44
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 1043 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 680 of file chan_alsa.c.

References alsa, alsalock, ast_cli_args::argc, 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, ast_cli_args::fd, grab_owner(), hookstate, chan_alsa_pvt::icard, mute, noaudiocapture, NULL, chan_alsa_pvt::owner, and ast_cli_entry::usage.

681 {
682  char *res = CLI_SUCCESS;
683 
684  switch (cmd) {
685  case CLI_INIT:
686  e->command = "console answer";
687  e->usage =
688  "Usage: console answer\n"
689  " Answers an incoming call on the console (ALSA) channel.\n";
690 
691  return NULL;
692  case CLI_GENERATE:
693  return NULL;
694  }
695 
696  if (a->argc != 2)
697  return CLI_SHOWUSAGE;
698 
700 
701  if (!alsa.owner) {
702  ast_cli(a->fd, "No one is calling us\n");
703  res = CLI_FAILURE;
704  } else {
705  if (mute) {
706  ast_verbose( " << Muted >> \n" );
707  }
708  hookstate = 1;
709  grab_owner();
710  if (alsa.owner) {
713  }
714  }
715 
716  if (!noaudiocapture) {
717  snd_pcm_prepare(alsa.icard);
718  snd_pcm_start(alsa.icard);
719  }
720 
722 
723  return res;
724 }
struct ast_channel * owner
Definition: chan_alsa.c:126
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1227
snd_pcm_t * icard
Definition: chan_alsa.c:129
static struct chan_alsa_pvt alsa
const int argc
Definition: cli.h:160
static int noaudiocapture
Definition: chan_alsa.c:145
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
static int mute
Definition: chan_alsa.c:144
const int fd
Definition: cli.h:159
#define CLI_SHOWUSAGE
Definition: cli.h:45
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_channel_unlock(chan)
Definition: channel.h:2838
#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
static void grab_owner(void)
Definition: chan_alsa.c:318
static int hookstate
Definition: chan_alsa.c:121
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ console_autoanswer()

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

Definition at line 644 of file chan_alsa.c.

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

645 {
646  char *res = CLI_SUCCESS;
647 
648  switch (cmd) {
649  case CLI_INIT:
650  e->command = "console autoanswer [on|off]";
651  e->usage =
652  "Usage: console autoanswer [on|off]\n"
653  " Enables or disables autoanswer feature. If used without\n"
654  " argument, displays the current on/off status of autoanswer.\n"
655  " The default value of autoanswer is in 'alsa.conf'.\n";
656  return NULL;
657  case CLI_GENERATE:
658  return NULL;
659  }
660 
661  if ((a->argc != 2) && (a->argc != 3))
662  return CLI_SHOWUSAGE;
663 
665  if (a->argc == 2) {
666  ast_cli(a->fd, "Auto answer is %s.\n", autoanswer ? "on" : "off");
667  } else {
668  if (!strcasecmp(a->argv[2], "on"))
669  autoanswer = -1;
670  else if (!strcasecmp(a->argv[2], "off"))
671  autoanswer = 0;
672  else
673  res = CLI_SHOWUSAGE;
674  }
676 
677  return res;
678 }
const int argc
Definition: cli.h:160
static int autoanswer
Definition: chan_alsa.c:143
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#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
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ console_dial()

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

Definition at line 813 of file chan_alsa.c.

References alsa, alsa_new(), alsalock, ast_cli_args::argc, ast_cli_args::argv, 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, chan_alsa_pvt::context, d, chan_alsa_pvt::exten, ast_cli_args::fd, ast_frame::frametype, hookstate, NULL, chan_alsa_pvt::owner, strsep(), tmp(), and ast_cli_entry::usage.

814 {
815  char tmp[256], *tmp2;
816  char *mye, *myc;
817  const char *d;
818  char *res = CLI_SUCCESS;
819 
820  switch (cmd) {
821  case CLI_INIT:
822  e->command = "console dial";
823  e->usage =
824  "Usage: console dial [extension[@context]]\n"
825  " Dials a given extension (and context if specified)\n";
826  return NULL;
827  case CLI_GENERATE:
828  return NULL;
829  }
830 
831  if ((a->argc != 2) && (a->argc != 3))
832  return CLI_SHOWUSAGE;
833 
835 
836  if (alsa.owner) {
837  if (a->argc == 3) {
838  if (alsa.owner) {
839  for (d = a->argv[2]; *d; d++) {
840  struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = *d };
841 
843  }
844  }
845  } else {
846  ast_cli(a->fd, "You're already in a call. You can use this only to dial digits until you hangup\n");
847  res = CLI_FAILURE;
848  }
849  } else {
850  mye = exten;
851  myc = context;
852  if (a->argc == 3) {
853  char *stringp = NULL;
854 
855  ast_copy_string(tmp, a->argv[2], sizeof(tmp));
856  stringp = tmp;
857  strsep(&stringp, "@");
858  tmp2 = strsep(&stringp, "@");
859  if (!ast_strlen_zero(tmp))
860  mye = tmp;
861  if (!ast_strlen_zero(tmp2))
862  myc = tmp2;
863  }
864  if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
865  ast_copy_string(alsa.exten, mye, sizeof(alsa.exten));
866  ast_copy_string(alsa.context, myc, sizeof(alsa.context));
867  hookstate = 1;
869  } else
870  ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
871  }
872 
874 
875  return res;
876 }
struct ast_channel * owner
Definition: chan_alsa.c:126
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
static struct chan_alsa_pvt alsa
const int argc
Definition: cli.h:160
static struct test_val d
static int tmp()
Definition: bt_open.c:389
Definition: cli.h:152
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:580
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define AST_FRAME_DTMF
const int fd
Definition: cli.h:159
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
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:128
char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:127
#define ast_strlen_zero(a)
Definition: muted.c:73
#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
char * strsep(char **str, const char *delims)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static int hookstate
Definition: chan_alsa.c:121
Data structure associated with a single frame of data.
enum ast_frame_type frametype
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ console_hangup()

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

Definition at line 775 of file chan_alsa.c.

References alsa, alsalock, ast_cli_args::argc, 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, ast_cli_args::fd, grab_owner(), hookstate, NULL, chan_alsa_pvt::owner, and ast_cli_entry::usage.

776 {
777  char *res = CLI_SUCCESS;
778 
779  switch (cmd) {
780  case CLI_INIT:
781  e->command = "console hangup";
782  e->usage =
783  "Usage: console hangup\n"
784  " Hangs up any call currently placed on the console.\n";
785  return NULL;
786  case CLI_GENERATE:
787  return NULL;
788  }
789 
790 
791  if (a->argc != 2)
792  return CLI_SHOWUSAGE;
793 
795 
796  if (!alsa.owner && !hookstate) {
797  ast_cli(a->fd, "No call to hangup\n");
798  res = CLI_FAILURE;
799  } else {
800  hookstate = 0;
801  grab_owner();
802  if (alsa.owner) {
805  }
806  }
807 
809 
810  return res;
811 }
struct ast_channel * owner
Definition: chan_alsa.c:126
static struct chan_alsa_pvt alsa
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#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
const int fd
Definition: cli.h:159
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
#define CLI_SHOWUSAGE
Definition: cli.h:45
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_channel_unlock(chan)
Definition: channel.h:2838
#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
static void grab_owner(void)
Definition: chan_alsa.c:318
static int hookstate
Definition: chan_alsa.c:121
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ console_mute()

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

Definition at line 878 of file chan_alsa.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, mute, NULL, and ast_cli_entry::usage.

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

Definition at line 726 of file chan_alsa.c.

References alsa, alsalock, ast_cli_args::argc, ast_cli_args::argv, 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, ast_cli_args::fd, grab_owner(), NULL, chan_alsa_pvt::owner, ast_frame::ptr, and ast_cli_entry::usage.

727 {
728  int tmparg = 3;
729  char *res = CLI_SUCCESS;
730 
731  switch (cmd) {
732  case CLI_INIT:
733  e->command = "console send text";
734  e->usage =
735  "Usage: console send text <message>\n"
736  " Sends a text message for display on the remote terminal.\n";
737  return NULL;
738  case CLI_GENERATE:
739  return NULL;
740  }
741 
742  if (a->argc < 3)
743  return CLI_SHOWUSAGE;
744 
746 
747  if (!alsa.owner) {
748  ast_cli(a->fd, "No channel active\n");
749  res = CLI_FAILURE;
750  } else {
751  struct ast_frame f = { AST_FRAME_TEXT };
752  char text2send[256] = "";
753 
754  while (tmparg < a->argc) {
755  strncat(text2send, a->argv[tmparg++], sizeof(text2send) - strlen(text2send) - 1);
756  strncat(text2send, " ", sizeof(text2send) - strlen(text2send) - 1);
757  }
758 
759  text2send[strlen(text2send) - 1] = '\n';
760  f.data.ptr = text2send;
761  f.datalen = strlen(text2send) + 1;
762  grab_owner();
763  if (alsa.owner) {
767  }
768  }
769 
771 
772  return res;
773 }
struct ast_channel * owner
Definition: chan_alsa.c:126
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1227
static struct chan_alsa_pvt alsa
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
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
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_channel_unlock(chan)
Definition: channel.h:2838
#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
static void grab_owner(void)
Definition: chan_alsa.c:318
Data structure associated with a single frame of data.
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ grab_owner()

static void grab_owner ( void  )
static

Definition at line 318 of file chan_alsa.c.

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

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

319 {
320  while (alsa.owner && ast_channel_trylock(alsa.owner)) {
322  }
323 }
struct ast_channel * owner
Definition: chan_alsa.c:126
static struct chan_alsa_pvt alsa
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:477
static ast_mutex_t alsalock
Definition: chan_alsa.c:111
#define ast_channel_trylock(chan)
Definition: channel.h:2839

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

References ARRAY_LEN, ast_channel_register(), ast_cli_register_multiple, ast_config_destroy(), ast_config_load, ast_copy_string(), ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_slin, ast_jb_read_conf(), ast_log, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DRIVER, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_EXTENDED, ast_true(), ast_variable_browse(), ast_verb, ASTERISK_GPL_KEY, autoanswer, ast_channel_tech::capabilities, config, CONFIG_STATUS_FILEINVALID, chan_alsa_pvt::context, chan_alsa_pvt::exten, global_jbconf, indevname, language, LOG_ERROR, mohinterpret, mute, ast_variable::name, ast_variable::next, noaudiocapture, outdevname, silencesuppression, silencethreshold, soundcard_init(), unload_module(), and ast_variable::value.

962 {
963  struct ast_config *cfg;
964  struct ast_variable *v;
965  struct ast_flags config_flags = { 0 };
966 
969  }
971 
972  /* Copy the default jb config over global_jbconf */
973  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
974 
975  strcpy(mohinterpret, "default");
976 
977  if (!(cfg = ast_config_load(config, config_flags))) {
978  ast_log(LOG_ERROR, "Unable to read ALSA configuration file %s. Aborting.\n", config);
980  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
981  ast_log(LOG_ERROR, "%s is in an invalid format. Aborting.\n", config);
983  }
984 
985  v = ast_variable_browse(cfg, "general");
986  for (; v; v = v->next) {
987  /* handle jb conf */
988  if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
989  continue;
990  }
991 
992  if (!strcasecmp(v->name, "autoanswer")) {
993  autoanswer = ast_true(v->value);
994  } else if (!strcasecmp(v->name, "mute")) {
995  mute = ast_true(v->value);
996  } else if (!strcasecmp(v->name, "noaudiocapture")) {
998  } else if (!strcasecmp(v->name, "silencesuppression")) {
1000  } else if (!strcasecmp(v->name, "silencethreshold")) {
1001  silencethreshold = atoi(v->value);
1002  } else if (!strcasecmp(v->name, "context")) {
1003  ast_copy_string(context, v->value, sizeof(context));
1004  } else if (!strcasecmp(v->name, "language")) {
1005  ast_copy_string(language, v->value, sizeof(language));
1006  } else if (!strcasecmp(v->name, "extension")) {
1007  ast_copy_string(exten, v->value, sizeof(exten));
1008  } else if (!strcasecmp(v->name, "input_device")) {
1009  ast_copy_string(indevname, v->value, sizeof(indevname));
1010  } else if (!strcasecmp(v->name, "output_device")) {
1012  } else if (!strcasecmp(v->name, "mohinterpret")) {
1014  }
1015  }
1016  ast_config_destroy(cfg);
1017 
1018  if (soundcard_init() < 0) {
1019  ast_verb(2, "No sound card detected -- console channel will be unavailable\n");
1020  ast_verb(2, "Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf\n");
1021  unload_module();
1022 
1023  return AST_MODULE_LOAD_DECLINE;
1024  }
1025 
1027  ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
1028  unload_module();
1029 
1030  return AST_MODULE_LOAD_DECLINE;
1031  }
1032 
1034 
1035  return AST_MODULE_LOAD_SUCCESS;
1036 }
struct ast_variable * next
static char mohinterpret[MAX_MUSICCLASS]
Definition: chan_alsa.c:119
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_channel_tech alsa_tech
Definition: chan_alsa.c:158
static int silencethreshold
Definition: chan_alsa.c:109
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
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 CONFIG_STATUS_FILEINVALID
static struct ast_jb_conf global_jbconf
Definition: chan_alsa.c:79
Structure for variables, used for configurations and for channel variables.
static int noaudiocapture
Definition: chan_alsa.c:145
static int autoanswer
Definition: chan_alsa.c:143
#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
#define ast_verb(level,...)
Definition: logger.h:455
static int mute
Definition: chan_alsa.c:144
#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
static int soundcard_init(void)
Definition: chan_alsa.c:279
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:117
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
#define LOG_ERROR
Definition: logger.h:285
static char outdevname[50]
Definition: chan_alsa.c:106
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1821
struct ast_format_cap * capabilities
Definition: channel.h:633
static char indevname[50]
Definition: chan_alsa.c:105
static struct ast_cli_entry cli_alsa[]
Definition: chan_alsa.c:922
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
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static const char config[]
Definition: chan_alsa.c:114
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
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 default_jbconf
Definition: chan_alsa.c:72
static int silencesuppression
Definition: chan_alsa.c:108
static int unload_module(void)
Definition: chan_alsa.c:931

◆ soundcard_init()

static int soundcard_init ( void  )
static

Definition at line 279 of file chan_alsa.c.

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

Referenced by load_module().

280 {
281  if (!noaudiocapture) {
282  alsa.icard = alsa_card_init(indevname, SND_PCM_STREAM_CAPTURE);
283  if (!alsa.icard) {
284  ast_log(LOG_ERROR, "Problem opening alsa capture device\n");
285  return -1;
286  }
287  }
288 
289  alsa.ocard = alsa_card_init(outdevname, SND_PCM_STREAM_PLAYBACK);
290 
291  if (!alsa.ocard) {
292  ast_log(LOG_ERROR, "Problem opening ALSA playback device\n");
293  return -1;
294  }
295 
296  return writedev;
297 }
snd_pcm_t * icard
Definition: chan_alsa.c:129
snd_pcm_t * ocard
Definition: chan_alsa.c:129
static struct chan_alsa_pvt alsa
static int noaudiocapture
Definition: chan_alsa.c:145
static int writedev
Definition: chan_alsa.c:141
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
static char outdevname[50]
Definition: chan_alsa.c:106
static char indevname[50]
Definition: chan_alsa.c:105
static snd_pcm_t * alsa_card_init(char *dev, snd_pcm_stream_t stream)
Definition: chan_alsa.c:173

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 931 of file chan_alsa.c.

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

Referenced by load_module().

932 {
935 
936  if (alsa.icard)
937  snd_pcm_close(alsa.icard);
938  if (alsa.ocard)
939  snd_pcm_close(alsa.ocard);
940  if (alsa.owner)
942  if (alsa.owner)
943  return -1;
944 
947 
948  return 0;
949 }
struct ast_channel * owner
Definition: chan_alsa.c:126
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_channel_tech alsa_tech
Definition: chan_alsa.c:158
snd_pcm_t * icard
Definition: chan_alsa.c:129
snd_pcm_t * ocard
Definition: chan_alsa.c:129
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct chan_alsa_pvt alsa
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
struct ast_format_cap * capabilities
Definition: channel.h:633
static struct ast_cli_entry cli_alsa[]
Definition: chan_alsa.c:922
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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_EXTENDED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, }
static

Definition at line 1043 of file chan_alsa.c.

◆ alsa

struct chan_alsa_pvt alsa
static

◆ alsa_tech

struct ast_channel_tech alsa_tech
static

Definition at line 158 of file chan_alsa.c.

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

◆ autoanswer

int autoanswer = 1
static

Definition at line 143 of file chan_alsa.c.

Referenced by alsa_call(), console_autoanswer(), and load_module().

◆ cli_alsa

struct ast_cli_entry cli_alsa[]
static

Definition at line 922 of file chan_alsa.c.

◆ config

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

Definition at line 114 of file chan_alsa.c.

Referenced by load_module().

◆ context

char context[AST_MAX_CONTEXT] = "default"
static
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 116 of file chan_alsa.c.

Referenced by __ast_channel_alloc_ap(), __ast_goto_if_exists(), __sip_alloc(), acf_isexten_exec(), acf_vm_info(), action_atxfer(), action_blind_transfer(), action_dialplan_exec(), action_extensionstate(), action_originate(), action_redirect(), add_action_to_menu_entry(), advanced_options(), append_mailbox_mapping(), ast_ari_channels_continue_in_dialplan(), ast_bridge_setup_after_goto(), ast_cdr_fork(), ast_channel_by_exten_cb(), ast_channel_yank(), ast_compile_ael2(), ast_get_enum(), ast_log(), ast_msg_alloc(), ast_msg_set_context(), ast_res_pjsip_initialize_configuration(), ast_sip_cli_print_sorcery_objectset(), ast_vm_msg_play(), ast_walk_context_includes(), ast_xml_query(), attended_transfer_exec(), base_process_party_a(), blind_transfer_exec(), bridge_exec(), build_peer(), cdr_object_create_and_append(), channel_snapshot_dialplan_create(), check_access(), check_peer_ok(), 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_body(), cli_endpoint_print_header(), cli_print_body(), cli_print_header(), cli_unid_print_body(), cli_unid_print_header(), complete_dialplan_add_include(), complete_dialplan_remove_extension(), complete_dialplan_remove_include(), conf_run(), config_parse_variables(), create_addr_from_peer(), create_queue_member(), delete_existing_cb(), disa_exec(), dns_system_resolver_add_record(), dns_system_resolver_set_response(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_exec(), dundi_helper(), dundi_show_cache(), dundi_show_hints(), ebl_callback(), enum_callback(), extenspy_exec(), extstate_read(), find_label_in_current_db(), free_zone(), get_also_info(), get_cid_name(), get_destination(), get_transfer_context(), handle_blind_transfer(), handle_cli_dialplan_remove_extension(), handle_request_bye(), handle_request_invite(), handle_request_options(), handle_request_refer(), has_voicemail(), hint_read(), iax2_call(), iax2_transfer(), inboxcount2(), init_queue(), inprocess_count(), ip_identify_match_srv_lookup(), isexten_function_read(), launch_ha_netscript(), leave_voicemail(), load_module(), local_alloc(), local_devicestate(), log_exec(), lua_pbx_exec(), lua_register_hints(), lua_register_switches(), lua_sort_extensions(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), manager_show_dialplan(), mb_poll_thread(), messagecount(), mwi_to_event(), orig_exten(), pbx_builtin_background(), pbx_find_extension(), pbx_parseable_goto(), pickup_exec(), play_message(), print_uri_debug(), process_ast_dsp(), publish_mwi_to_stasis(), pubsub_on_rx_mwi_notify_request(), pvalGotoSetTarget(), queue_mwi_event(), queue_set_param(), readexten_exec(), receive_message(), refer_incoming_attended_request(), refer_incoming_blind_request(), register_exten(), register_peer_exten(), reload(), reload_config(), retrydial_exec(), rx_data_to_ast_msg(), set_peer_defaults(), setup_peer_after_bridge_goto(), socket_process_helper(), str2tech(), try_redirect(), txt_callback(), unregister_exten(), vm_allocate_dh(), vm_sayname(), vmsayname_exec(), and wait_for_answer().

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

◆ exten

char exten[AST_MAX_EXTENSION] = "s"
static
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 118 of file chan_alsa.c.

Referenced by __analog_ss_thread(), __ast_channel_alloc_ap(), action_atxfer(), action_blind_transfer(), action_dialplan_exec(), action_extensionstate(), action_originate(), action_redirect(), add_action_to_menu_entry(), analog_ss_thread(), ast_ari_channels_continue_in_dialplan(), ast_bridge_setup_after_goto(), ast_cdr_fork(), ast_channel_by_exten_cb(), ast_channel_yank(), ast_compile_ael2(), ast_ivr_menu_run_internal(), ast_log(), ast_msg_set_exten(), AST_TEST_DEFINE(), ast_walk_extension_priorities(), attended_transfer_exec(), base_process_party_a(), blind_transfer_exec(), cdr_object_create_and_append(), channel_snapshot_dialplan_create(), check_access(), check_user_full(), complete_dialplan_remove_extension(), complete_dpreply(), config_parse_variables(), context_used(), copy_plain_file(), create_queue_member(), delete_existing_cb(), dialandactivatesub(), disa_exec(), expand_gosub_args(), extenspy_exec(), extstate_read(), feature_attended_transfer(), find_label_in_current_context(), find_label_in_current_db(), gen_prios(), get_cid_name(), get_destination(), get_rdnis(), handle_blind_transfer(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_remove_extension(), handle_request_invite(), hint_read(), initreqprep(), isexten_function_read(), leave_voicemail(), linkprio(), local_devicestate(), lua_pbx_exec(), lua_sort_extensions(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), mgcp_ss(), my_new_analog_ast_channel(), my_on_hook(), new_iax(), onedigit_goto(), options_on_rx_request(), orig_exten(), originate_exec(), osplookup_exec(), pbx_builtin_background(), pickup_exec(), pp_each_extension_helper(), readexten_exec(), refer_incoming_blind_request(), register_verify(), reload(), rx_data_to_ast_msg(), session_inv_on_redirected(), sip_new(), sip_request_call(), sla_build_station(), sla_station_destructor(), socket_process_helper(), test_vm_api_destroy_mailbox_voicemails(), test_vm_api_test_setup(), test_vm_api_update_test_snapshots(), transmit_notify_with_mwi(), transmit_register(), user_destructor(), vm_msg_snapshot_create(), and waitstream_core().

◆ format

snd_pcm_format_t format = SND_PCM_FORMAT_S16_BE
static
Examples:
/tmp/asterisk-shallow/include/asterisk/strings.h.

Definition at line 102 of file chan_alsa.c.

Referenced by acf_sprintf(), acf_strftime(), acf_strptime(), FaxPcap::add(), add_format_information_cb(), add_sdp(), alsa_card_init(), ao2_container_unregister(), apply_cap_to_bundled(), ast_add_profile(), ast_ari_recordings_get_stored_file(), ast_format_attribute_set(), ast_format_create_named(), ast_monitor_stop(), ast_openvstream(), ast_rtp_codecs_get_payload_format(), ast_rtp_codecs_payload_replace_format(), ast_rtp_write(), ast_strftime_locale(), AST_TEST_DEFINE(), build_peer(), build_profile(), build_user(), check_header(), check_header_fmt(), configure_local_rtp(), create_addr(), create_outgoing_sdp_stream(), dialog_unlink_all(), does_id_conflict(), file_count_line(), file_read(), file_write(), format_destroy(), format_hash_cb(), get_codecs(), get_soxmix_format(), handle_clear_alarms(), handle_saydatetime(), iax2_codec_choose(), iax2_codec_pref_best_bitfield2cap(), iax2_codec_pref_from_bitfield(), iax2_format_compatibility_bitfield2cap(), iax2_format_compatibility_cap2bitfield(), iax2_request(), jingle_add_payloads_to_description(), spandspflow2pcap::main(), minivm_notify_exec(), multicast_rtp_write(), ooh323c_set_capability(), ooh323c_set_capability_for_call(), process_sdp_a_audio(), process_sdp_a_video(), reload_config(), say_digit_str_full(), sayunixtime_exec(), sendmail(), set_config(), set_format(), show_sound_info_cb(), socket_process_helper(), start_monitor_action(), start_monitor_exec(), AllowableRange::to_wiki(), AllowableList::to_wiki(), transmit_connect_with_sdp(), transmit_modify_request(), transmit_modify_with_sdp(), update_logchannels(), fe6592859b85_fix_mwi_subscribe_replaces_::upgrade(), and vm_allocate_dh().

◆ global_jbconf

struct ast_jb_conf global_jbconf
static

Definition at line 79 of file chan_alsa.c.

Referenced by alsa_new(), and load_module().

◆ hookstate

int hookstate = 0
static

Definition at line 121 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 105 of file chan_alsa.c.

Referenced by alsa_new(), load_module(), 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 106 of file chan_alsa.c.

Referenced by load_module(), and soundcard_init().

◆ readdev

int readdev = -1
static

Definition at line 140 of file chan_alsa.c.

Referenced by alsa_card_init(), and alsa_new().

◆ silencesuppression

int silencesuppression = 0
static

Definition at line 108 of file chan_alsa.c.

Referenced by load_module().

◆ silencethreshold

int silencethreshold = 1000
static

Definition at line 109 of file chan_alsa.c.

Referenced by load_module().

◆ tdesc

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

Definition at line 113 of file chan_alsa.c.

◆ writedev

int writedev = -1
static

Definition at line 141 of file chan_alsa.c.

Referenced by alsa_card_init(), and soundcard_init().