chan_alsa.c File Reference

ALSA sound card channel driver. More...

#include "asterisk.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

Defines

#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 FRAME_SIZE   160
#define MAX_BUFFER_SIZE   100
#define MIN_SWITCH_TIME   600
#define PERIOD_FRAMES   80

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)
static char * autoanswer_complete (const char *line, const char *word, int pos, int state)
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.
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_MUTEX_INITIALIZER , NULL, 1 }
static 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 <creslin@digium.com>

Definition in file chan_alsa.c.


Define Documentation

#define ALSA_INDEV   "default"

Definition at line 81 of file chan_alsa.c.

#define ALSA_OUTDEV   "default"

Definition at line 82 of file chan_alsa.c.

#define ALSA_PCM_NEW_HW_PARAMS_API

Definition at line 48 of file chan_alsa.c.

#define ALSA_PCM_NEW_SW_PARAMS_API

Definition at line 49 of file chan_alsa.c.

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

Definition at line 92 of file chan_alsa.c.

#define DEBUG   0

#define DESIRED_RATE   8000

Definition at line 83 of file chan_alsa.c.

Referenced by alsa_card_init().

#define FRAME_SIZE   160

Definition at line 86 of file chan_alsa.c.

Referenced by alsa_read(), oss_read(), and soundcard_writeframe().

#define MAX_BUFFER_SIZE   100

Definition at line 135 of file chan_alsa.c.

#define MIN_SWITCH_TIME   600

Definition at line 95 of file chan_alsa.c.

#define PERIOD_FRAMES   80

Definition at line 87 of file chan_alsa.c.

Referenced by alsa_card_init().


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 1053 of file chan_alsa.c.

static void __unreg_module ( void   )  [static]

Definition at line 1053 of file chan_alsa.c.

static int alsa_answer ( struct ast_channel c  )  [static]

Definition at line 359 of file chan_alsa.c.

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

00360 {
00361    ast_mutex_lock(&alsalock);
00362    ast_verbose(" << Console call has been answered >> \n");
00363    ast_setstate(c, AST_STATE_UP);
00364    if (!noaudiocapture) {
00365       snd_pcm_prepare(alsa.icard);
00366       snd_pcm_start(alsa.icard);
00367    }
00368    ast_mutex_unlock(&alsalock);
00369 
00370    return 0;
00371 }

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

Definition at line 323 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, grab_owner(), chan_alsa_pvt::icard, ast_frame_subclass::integer, chan_alsa_pvt::owner, and ast_frame::subclass.

00324 {
00325    struct ast_frame f = { AST_FRAME_CONTROL };
00326 
00327    ast_mutex_lock(&alsalock);
00328    ast_verbose(" << Call placed to '%s' on console >> \n", dest);
00329    if (autoanswer) {
00330       ast_verbose(" << Auto-answered >> \n");
00331       if (mute) {
00332          ast_verbose( " << Muted >> \n" );
00333       }
00334       grab_owner();
00335       if (alsa.owner) {
00336          f.subclass.integer = AST_CONTROL_ANSWER;
00337          ast_queue_frame(alsa.owner, &f);
00338          ast_channel_unlock(alsa.owner);
00339       }
00340    } else {
00341       ast_verbose(" << Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
00342       grab_owner();
00343       if (alsa.owner) {
00344          f.subclass.integer = AST_CONTROL_RINGING;
00345          ast_queue_frame(alsa.owner, &f);
00346          ast_channel_unlock(alsa.owner);
00347          ast_indicate(alsa.owner, AST_CONTROL_RINGING);
00348       }
00349    }
00350    if (!noaudiocapture) {
00351       snd_pcm_prepare(alsa.icard);
00352       snd_pcm_start(alsa.icard);
00353    }
00354    ast_mutex_unlock(&alsalock);
00355 
00356    return 0;
00357 }

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

Definition at line 171 of file chan_alsa.c.

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

Referenced by soundcard_init().

00172 {
00173    int err;
00174    int direction;
00175    snd_pcm_t *handle = NULL;
00176    snd_pcm_hw_params_t *hwparams = NULL;
00177    snd_pcm_sw_params_t *swparams = NULL;
00178    struct pollfd pfd;
00179    snd_pcm_uframes_t period_size = PERIOD_FRAMES * 4;
00180    snd_pcm_uframes_t buffer_size = 0;
00181    unsigned int rate = DESIRED_RATE;
00182    snd_pcm_uframes_t start_threshold, stop_threshold;
00183 
00184    err = snd_pcm_open(&handle, dev, stream, SND_PCM_NONBLOCK);
00185    if (err < 0) {
00186       ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
00187       return NULL;
00188    } else {
00189       ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
00190    }
00191 
00192    hwparams = ast_alloca(snd_pcm_hw_params_sizeof());
00193    memset(hwparams, 0, snd_pcm_hw_params_sizeof());
00194    snd_pcm_hw_params_any(handle, hwparams);
00195 
00196    err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
00197    if (err < 0)
00198       ast_log(LOG_ERROR, "set_access failed: %s\n", snd_strerror(err));
00199 
00200    err = snd_pcm_hw_params_set_format(handle, hwparams, format);
00201    if (err < 0)
00202       ast_log(LOG_ERROR, "set_format failed: %s\n", snd_strerror(err));
00203 
00204    err = snd_pcm_hw_params_set_channels(handle, hwparams, 1);
00205    if (err < 0)
00206       ast_log(LOG_ERROR, "set_channels failed: %s\n", snd_strerror(err));
00207 
00208    direction = 0;
00209    err = snd_pcm_hw_params_set_rate_near(handle, hwparams, &rate, &direction);
00210    if (rate != DESIRED_RATE)
00211       ast_log(LOG_WARNING, "Rate not correct, requested %d, got %u\n", DESIRED_RATE, rate);
00212 
00213    direction = 0;
00214    err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction);
00215    if (err < 0)
00216       ast_log(LOG_ERROR, "period_size(%lu frames) is bad: %s\n", period_size, snd_strerror(err));
00217    else {
00218       ast_debug(1, "Period size is %d\n", err);
00219    }
00220 
00221    buffer_size = 4096 * 2;    /* period_size * 16; */
00222    err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size);
00223    if (err < 0)
00224       ast_log(LOG_WARNING, "Problem setting buffer size of %lu: %s\n", buffer_size, snd_strerror(err));
00225    else {
00226       ast_debug(1, "Buffer size is set to %d frames\n", err);
00227    }
00228 
00229    err = snd_pcm_hw_params(handle, hwparams);
00230    if (err < 0)
00231       ast_log(LOG_ERROR, "Couldn't set the new hw params: %s\n", snd_strerror(err));
00232 
00233    swparams = ast_alloca(snd_pcm_sw_params_sizeof());
00234    memset(swparams, 0, snd_pcm_sw_params_sizeof());
00235    snd_pcm_sw_params_current(handle, swparams);
00236 
00237    if (stream == SND_PCM_STREAM_PLAYBACK)
00238       start_threshold = period_size;
00239    else
00240       start_threshold = 1;
00241 
00242    err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
00243    if (err < 0)
00244       ast_log(LOG_ERROR, "start threshold: %s\n", snd_strerror(err));
00245 
00246    if (stream == SND_PCM_STREAM_PLAYBACK)
00247       stop_threshold = buffer_size;
00248    else
00249       stop_threshold = buffer_size;
00250 
00251    err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
00252    if (err < 0)
00253       ast_log(LOG_ERROR, "stop threshold: %s\n", snd_strerror(err));
00254 
00255    err = snd_pcm_sw_params(handle, swparams);
00256    if (err < 0)
00257       ast_log(LOG_ERROR, "sw_params: %s\n", snd_strerror(err));
00258 
00259    err = snd_pcm_poll_descriptors_count(handle);
00260    if (err <= 0)
00261       ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
00262    if (err != 1) {
00263       ast_debug(1, "Can't handle more than one device\n");
00264    }
00265 
00266    snd_pcm_poll_descriptors(handle, &pfd, err);
00267    ast_debug(1, "Acquired fd %d from the poll descriptor\n", pfd.fd);
00268 
00269    if (stream == SND_PCM_STREAM_CAPTURE)
00270       readdev = pfd.fd;
00271    else
00272       writedev = pfd.fd;
00273 
00274    return handle;
00275 }

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

Definition at line 297 of file chan_alsa.c.

References alsalock, ast_mutex_lock, ast_mutex_unlock, and ast_verbose.

00298 {
00299    ast_mutex_lock(&alsalock);
00300    ast_verbose(" << Console Received digit %c of duration %u ms >> \n", 
00301       digit, duration);
00302    ast_mutex_unlock(&alsalock);
00303 
00304    return 0;
00305 }

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

Definition at line 529 of file chan_alsa.c.

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

00530 {
00531    struct chan_alsa_pvt *p = ast_channel_tech_pvt(newchan);
00532 
00533    ast_mutex_lock(&alsalock);
00534    p->owner = newchan;
00535    ast_mutex_unlock(&alsalock);
00536 
00537    return 0;
00538 }

static int alsa_hangup ( struct ast_channel c  )  [static]

Definition at line 373 of file chan_alsa.c.

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

00374 {
00375    ast_mutex_lock(&alsalock);
00376    ast_channel_tech_pvt_set(c, NULL);
00377    alsa.owner = NULL;
00378    ast_verbose(" << Hangup on console >> \n");
00379    ast_module_unref(ast_module_info->self);
00380    hookstate = 0;
00381    if (!noaudiocapture) {
00382       snd_pcm_drop(alsa.icard);
00383    }
00384    ast_mutex_unlock(&alsalock);
00385 
00386    return 0;
00387 }

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

Definition at line 540 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, and LOG_WARNING.

00541 {
00542    int res = 0;
00543 
00544    ast_mutex_lock(&alsalock);
00545 
00546    switch (cond) {
00547    case AST_CONTROL_BUSY:
00548    case AST_CONTROL_CONGESTION:
00549    case AST_CONTROL_RINGING:
00550    case AST_CONTROL_INCOMPLETE:
00551    case AST_CONTROL_PVT_CAUSE_CODE:
00552    case -1:
00553       res = -1;  /* Ask for inband indications */
00554       break;
00555    case AST_CONTROL_PROGRESS:
00556    case AST_CONTROL_PROCEEDING:
00557    case AST_CONTROL_VIDUPDATE:
00558    case AST_CONTROL_SRCUPDATE:
00559       break;
00560    case AST_CONTROL_HOLD:
00561       ast_verbose(" << Console Has Been Placed on Hold >> \n");
00562       ast_moh_start(chan, data, mohinterpret);
00563       break;
00564    case AST_CONTROL_UNHOLD:
00565       ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
00566       ast_moh_stop(chan);
00567       break;
00568    default:
00569       ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, ast_channel_name(chan));
00570       res = -1;
00571    }
00572 
00573    ast_mutex_unlock(&alsalock);
00574 
00575    return res;
00576 }

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, read]

Definition at line 578 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, LOG_WARNING, NULL, chan_alsa_pvt::owner, and tmp().

Referenced by alsa_request(), and console_dial().

00579 {
00580    struct ast_channel *tmp = NULL;
00581 
00582    if (!(tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, assignedids, requestor, 0, "ALSA/%s", indevname)))
00583       return NULL;
00584 
00585    ast_channel_stage_snapshot(tmp);
00586 
00587    ast_channel_tech_set(tmp, &alsa_tech);
00588    ast_channel_set_fd(tmp, 0, readdev);
00589    ast_channel_set_readformat(tmp, ast_format_slin);
00590    ast_channel_set_writeformat(tmp, ast_format_slin);
00591    ast_channel_nativeformats_set(tmp, alsa_tech.capabilities);
00592 
00593    ast_channel_tech_pvt_set(tmp, p);
00594    if (!ast_strlen_zero(p->context))
00595       ast_channel_context_set(tmp, p->context);
00596    if (!ast_strlen_zero(p->exten))
00597       ast_channel_exten_set(tmp, p->exten);
00598    if (!ast_strlen_zero(language))
00599       ast_channel_language_set(tmp, language);
00600    p->owner = tmp;
00601    ast_module_ref(ast_module_info->self);
00602    ast_jb_configure(tmp, &global_jbconf);
00603 
00604    ast_channel_stage_snapshot_done(tmp);
00605    ast_channel_unlock(tmp);
00606 
00607    if (state != AST_STATE_DOWN) {
00608       if (ast_pbx_start(tmp)) {
00609          ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
00610          ast_hangup(tmp);
00611          tmp = NULL;
00612       }
00613    }
00614 
00615    return tmp;
00616 }

static struct ast_frame * alsa_read ( struct ast_channel chan  )  [static, read]

Definition at line 441 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, ast_frame_subclass::format, FRAME_SIZE, ast_frame::frametype, chan_alsa_pvt::icard, ast_frame_subclass::integer, LOG_ERROR, ast_frame::mallocd, NULL, ast_frame::offset, ast_frame::ptr, ast_frame::samples, ast_frame::src, and ast_frame::subclass.

00442 {
00443    static struct ast_frame f;
00444    static short __buf[FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
00445    short *buf;
00446    static int readpos = 0;
00447    static int left = FRAME_SIZE;
00448    snd_pcm_state_t state;
00449    int r = 0;
00450 
00451    ast_mutex_lock(&alsalock);
00452    f.frametype = AST_FRAME_NULL;
00453    f.subclass.integer = 0;
00454    f.samples = 0;
00455    f.datalen = 0;
00456    f.data.ptr = NULL;
00457    f.offset = 0;
00458    f.src = "Console";
00459    f.mallocd = 0;
00460    f.delivery.tv_sec = 0;
00461    f.delivery.tv_usec = 0;
00462 
00463    if (noaudiocapture) {
00464       /* Return null frame to asterisk*/
00465       ast_mutex_unlock(&alsalock);
00466       return &f;
00467    }
00468 
00469    state = snd_pcm_state(alsa.icard);
00470    if ((state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING)) {
00471       snd_pcm_prepare(alsa.icard);
00472    }
00473 
00474    buf = __buf + AST_FRIENDLY_OFFSET / 2;
00475 
00476    r = snd_pcm_readi(alsa.icard, buf + readpos, left);
00477    if (r == -EPIPE) {
00478 #if DEBUG
00479       ast_log(LOG_ERROR, "XRUN read\n");
00480 #endif
00481       snd_pcm_prepare(alsa.icard);
00482    } else if (r == -ESTRPIPE) {
00483       ast_log(LOG_ERROR, "-ESTRPIPE\n");
00484       snd_pcm_prepare(alsa.icard);
00485    } else if (r < 0) {
00486       ast_log(LOG_ERROR, "Read error: %s\n", snd_strerror(r));
00487    }
00488 
00489    /* Return NULL frame on error */
00490    if (r < 0) {
00491       ast_mutex_unlock(&alsalock);
00492       return &f;
00493    }
00494 
00495    /* Update positions */
00496    readpos += r;
00497    left -= r;
00498 
00499    if (readpos >= FRAME_SIZE) {
00500       /* A real frame */
00501       readpos = 0;
00502       left = FRAME_SIZE;
00503       if (ast_channel_state(chan) != AST_STATE_UP) {
00504          /* Don't transmit unless it's up */
00505          ast_mutex_unlock(&alsalock);
00506          return &f;
00507       }
00508       if (mute) {
00509          /* Don't transmit if muted */
00510          ast_mutex_unlock(&alsalock);
00511          return &f;
00512       }
00513 
00514       f.frametype = AST_FRAME_VOICE;
00515       f.subclass.format = ast_format_slin;
00516       f.samples = FRAME_SIZE;
00517       f.datalen = FRAME_SIZE * 2;
00518       f.data.ptr = buf;
00519       f.offset = AST_FRIENDLY_OFFSET;
00520       f.src = "Console";
00521       f.mallocd = 0;
00522 
00523    }
00524    ast_mutex_unlock(&alsalock);
00525 
00526    return &f;
00527 }

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, read]

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

00619 {
00620    struct ast_channel *tmp = NULL;
00621 
00622    if (ast_format_cap_iscompatible_format(cap, ast_format_slin) == AST_FORMAT_CMP_NOT_EQUAL) {
00623       struct ast_str *codec_buf = ast_str_alloca(64);
00624       ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_format_cap_get_names(cap, &codec_buf));
00625       return NULL;
00626    }
00627 
00628    ast_mutex_lock(&alsalock);
00629 
00630    if (alsa.owner) {
00631       ast_log(LOG_NOTICE, "Already have a call on the ALSA channel\n");
00632       *cause = AST_CAUSE_BUSY;
00633    } else if (!(tmp = alsa_new(&alsa, AST_STATE_DOWN, assignedids, requestor))) {
00634       ast_log(LOG_WARNING, "Unable to create new ALSA channel\n");
00635    }
00636 
00637    ast_mutex_unlock(&alsalock);
00638 
00639    return tmp;
00640 }

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

Definition at line 307 of file chan_alsa.c.

References alsalock, ast_mutex_lock, ast_mutex_unlock, and ast_verbose.

00308 {
00309    ast_mutex_lock(&alsalock);
00310    ast_verbose(" << Console Received text %s >> \n", text);
00311    ast_mutex_unlock(&alsalock);
00312 
00313    return 0;
00314 }

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

Definition at line 389 of file chan_alsa.c.

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

00390 {
00391    static char sizbuf[8000];
00392    static int sizpos = 0;
00393    int len = sizpos;
00394    int res = 0;
00395    /* size_t frames = 0; */
00396    snd_pcm_state_t state;
00397 
00398    ast_mutex_lock(&alsalock);
00399 
00400    /* We have to digest the frame in 160-byte portions */
00401    if (f->datalen > sizeof(sizbuf) - sizpos) {
00402       ast_log(LOG_WARNING, "Frame too large\n");
00403       res = -1;
00404    } else {
00405       memcpy(sizbuf + sizpos, f->data.ptr, f->datalen);
00406       len += f->datalen;
00407       state = snd_pcm_state(alsa.ocard);
00408       if (state == SND_PCM_STATE_XRUN)
00409          snd_pcm_prepare(alsa.ocard);
00410       while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
00411          usleep(1);
00412       }
00413       if (res == -EPIPE) {
00414 #if DEBUG
00415          ast_debug(1, "XRUN write\n");
00416 #endif
00417          snd_pcm_prepare(alsa.ocard);
00418          while ((res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2)) == -EAGAIN) {
00419             usleep(1);
00420          }
00421          if (res != len / 2) {
00422             ast_log(LOG_ERROR, "Write error: %s\n", snd_strerror(res));
00423             res = -1;
00424          } else if (res < 0) {
00425             ast_log(LOG_ERROR, "Write error %s\n", snd_strerror(res));
00426             res = -1;
00427          }
00428       } else {
00429          if (res == -ESTRPIPE)
00430             ast_log(LOG_ERROR, "You've got some big problems\n");
00431          else if (res < 0)
00432             ast_log(LOG_NOTICE, "Error %d on write\n", res);
00433       }
00434    }
00435    ast_mutex_unlock(&alsalock);
00436 
00437    return res >= 0 ? 0 : res;
00438 }

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

Definition at line 642 of file chan_alsa.c.

References ast_strdup, ast_strlen_zero, MIN, and NULL.

Referenced by console_autoanswer().

00643 {
00644    switch (state) {
00645       case 0:
00646          if (!ast_strlen_zero(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
00647             return ast_strdup("on");
00648       case 1:
00649          if (!ast_strlen_zero(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
00650             return ast_strdup("off");
00651       default:
00652          return NULL;
00653    }
00654 
00655    return NULL;
00656 }

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

Definition at line 694 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(), chan_alsa_pvt::icard, NULL, chan_alsa_pvt::owner, and ast_cli_entry::usage.

00695 {
00696    char *res = CLI_SUCCESS;
00697 
00698    switch (cmd) {
00699    case CLI_INIT:
00700       e->command = "console answer";
00701       e->usage =
00702          "Usage: console answer\n"
00703          "       Answers an incoming call on the console (ALSA) channel.\n";
00704 
00705       return NULL;
00706    case CLI_GENERATE:
00707       return NULL; 
00708    }
00709 
00710    if (a->argc != 2)
00711       return CLI_SHOWUSAGE;
00712 
00713    ast_mutex_lock(&alsalock);
00714 
00715    if (!alsa.owner) {
00716       ast_cli(a->fd, "No one is calling us\n");
00717       res = CLI_FAILURE;
00718    } else {
00719       if (mute) {
00720          ast_verbose( " << Muted >> \n" );
00721       }
00722       hookstate = 1;
00723       grab_owner();
00724       if (alsa.owner) {
00725          ast_queue_control(alsa.owner, AST_CONTROL_ANSWER);
00726          ast_channel_unlock(alsa.owner);
00727       }
00728    }
00729 
00730    if (!noaudiocapture) {
00731       snd_pcm_prepare(alsa.icard);
00732       snd_pcm_start(alsa.icard);
00733    }
00734 
00735    ast_mutex_unlock(&alsalock);
00736 
00737    return res;
00738 }

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

Definition at line 658 of file chan_alsa.c.

References alsalock, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_mutex_lock, ast_mutex_unlock, autoanswer_complete(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, ast_cli_args::line, ast_cli_args::n, NULL, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.

00659 {
00660    char *res = CLI_SUCCESS;
00661 
00662    switch (cmd) {
00663    case CLI_INIT:
00664       e->command = "console autoanswer";
00665       e->usage =
00666          "Usage: console autoanswer [on|off]\n"
00667          "       Enables or disables autoanswer feature.  If used without\n"
00668          "       argument, displays the current on/off status of autoanswer.\n"
00669          "       The default value of autoanswer is in 'alsa.conf'.\n";
00670       return NULL;
00671    case CLI_GENERATE:
00672       return autoanswer_complete(a->line, a->word, a->pos, a->n);
00673    }
00674 
00675    if ((a->argc != 2) && (a->argc != 3))
00676       return CLI_SHOWUSAGE;
00677 
00678    ast_mutex_lock(&alsalock);
00679    if (a->argc == 2) {
00680       ast_cli(a->fd, "Auto answer is %s.\n", autoanswer ? "on" : "off");
00681    } else {
00682       if (!strcasecmp(a->argv[2], "on"))
00683          autoanswer = -1;
00684       else if (!strcasecmp(a->argv[2], "off"))
00685          autoanswer = 0;
00686       else
00687          res = CLI_SHOWUSAGE;
00688    }
00689    ast_mutex_unlock(&alsalock);
00690 
00691    return res;
00692 }

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

Definition at line 827 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, NULL, chan_alsa_pvt::owner, strsep(), tmp(), and ast_cli_entry::usage.

00828 {
00829    char tmp[256], *tmp2;
00830    char *mye, *myc;
00831    const char *d;
00832    char *res = CLI_SUCCESS;
00833 
00834    switch (cmd) {
00835    case CLI_INIT:
00836       e->command = "console dial";
00837       e->usage =
00838          "Usage: console dial [extension[@context]]\n"
00839          "       Dials a given extension (and context if specified)\n";
00840       return NULL;
00841    case CLI_GENERATE:
00842       return NULL;
00843    }
00844 
00845    if ((a->argc != 2) && (a->argc != 3))
00846       return CLI_SHOWUSAGE;
00847 
00848    ast_mutex_lock(&alsalock);
00849 
00850    if (alsa.owner) {
00851       if (a->argc == 3) {
00852          if (alsa.owner) {
00853             for (d = a->argv[2]; *d; d++) {
00854                struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = *d };
00855 
00856                ast_queue_frame(alsa.owner, &f);
00857             }
00858          }
00859       } else {
00860          ast_cli(a->fd, "You're already in a call.  You can use this only to dial digits until you hangup\n");
00861          res = CLI_FAILURE;
00862       }
00863    } else {
00864       mye = exten;
00865       myc = context;
00866       if (a->argc == 3) {
00867          char *stringp = NULL;
00868 
00869          ast_copy_string(tmp, a->argv[2], sizeof(tmp));
00870          stringp = tmp;
00871          strsep(&stringp, "@");
00872          tmp2 = strsep(&stringp, "@");
00873          if (!ast_strlen_zero(tmp))
00874             mye = tmp;
00875          if (!ast_strlen_zero(tmp2))
00876             myc = tmp2;
00877       }
00878       if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
00879          ast_copy_string(alsa.exten, mye, sizeof(alsa.exten));
00880          ast_copy_string(alsa.context, myc, sizeof(alsa.context));
00881          hookstate = 1;
00882          alsa_new(&alsa, AST_STATE_RINGING, NULL, NULL);
00883       } else
00884          ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
00885    }
00886 
00887    ast_mutex_unlock(&alsalock);
00888 
00889    return res;
00890 }

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

Definition at line 789 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(), NULL, chan_alsa_pvt::owner, and ast_cli_entry::usage.

00790 {
00791    char *res = CLI_SUCCESS;
00792 
00793    switch (cmd) {
00794    case CLI_INIT:
00795       e->command = "console hangup";
00796       e->usage =
00797          "Usage: console hangup\n"
00798          "       Hangs up any call currently placed on the console.\n";
00799       return NULL;
00800    case CLI_GENERATE:
00801       return NULL; 
00802    }
00803  
00804 
00805    if (a->argc != 2)
00806       return CLI_SHOWUSAGE;
00807 
00808    ast_mutex_lock(&alsalock);
00809 
00810    if (!alsa.owner && !hookstate) {
00811       ast_cli(a->fd, "No call to hangup\n");
00812       res = CLI_FAILURE;
00813    } else {
00814       hookstate = 0;
00815       grab_owner();
00816       if (alsa.owner) {
00817          ast_queue_hangup_with_cause(alsa.owner, AST_CAUSE_NORMAL_CLEARING);
00818          ast_channel_unlock(alsa.owner);
00819       }
00820    }
00821 
00822    ast_mutex_unlock(&alsalock);
00823 
00824    return res;
00825 }

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

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

00893 {
00894    int toggle = 0;
00895    char *res = CLI_SUCCESS;
00896 
00897    switch (cmd) {
00898    case CLI_INIT:
00899       e->command = "console {mute|unmute} [toggle]";
00900       e->usage =
00901          "Usage: console {mute|unmute} [toggle]\n"
00902          "       Mute/unmute the microphone.\n";
00903       return NULL;
00904    case CLI_GENERATE:
00905       return NULL;
00906    }
00907 
00908 
00909    if (a->argc > 3) {
00910       return CLI_SHOWUSAGE;
00911    }
00912 
00913    if (a->argc == 3) {
00914       if (strcasecmp(a->argv[2], "toggle"))
00915          return CLI_SHOWUSAGE;
00916       toggle = 1;
00917    }
00918 
00919    if (a->argc < 2) {
00920       return CLI_SHOWUSAGE;
00921    }
00922 
00923    if (!strcasecmp(a->argv[1], "mute")) {
00924       mute = toggle ? !mute : 1;
00925    } else if (!strcasecmp(a->argv[1], "unmute")) {
00926       mute = toggle ? !mute : 0;
00927    } else {
00928       return CLI_SHOWUSAGE;
00929    }
00930 
00931    ast_cli(a->fd, "Console mic is %s\n", mute ? "off" : "on");
00932 
00933    return res;
00934 }

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

Definition at line 740 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.

00741 {
00742    int tmparg = 3;
00743    char *res = CLI_SUCCESS;
00744 
00745    switch (cmd) {
00746    case CLI_INIT:
00747       e->command = "console send text";
00748       e->usage =
00749          "Usage: console send text <message>\n"
00750          "       Sends a text message for display on the remote terminal.\n";
00751       return NULL;
00752    case CLI_GENERATE:
00753       return NULL; 
00754    }
00755 
00756    if (a->argc < 3)
00757       return CLI_SHOWUSAGE;
00758 
00759    ast_mutex_lock(&alsalock);
00760 
00761    if (!alsa.owner) {
00762       ast_cli(a->fd, "No channel active\n");
00763       res = CLI_FAILURE;
00764    } else {
00765       struct ast_frame f = { AST_FRAME_TEXT };
00766       char text2send[256] = "";
00767 
00768       while (tmparg < a->argc) {
00769          strncat(text2send, a->argv[tmparg++], sizeof(text2send) - strlen(text2send) - 1);
00770          strncat(text2send, " ", sizeof(text2send) - strlen(text2send) - 1);
00771       }
00772 
00773       text2send[strlen(text2send) - 1] = '\n';
00774       f.data.ptr = text2send;
00775       f.datalen = strlen(text2send) + 1;
00776       grab_owner();
00777       if (alsa.owner) {
00778          ast_queue_frame(alsa.owner, &f);
00779          ast_queue_control(alsa.owner, AST_CONTROL_ANSWER);
00780          ast_channel_unlock(alsa.owner);
00781       }
00782    }
00783 
00784    ast_mutex_unlock(&alsalock);
00785 
00786    return res;
00787 }

static void grab_owner ( void   )  [static]

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

00317 {
00318    while (alsa.owner && ast_channel_trylock(alsa.owner)) {
00319       DEADLOCK_AVOIDANCE(&alsalock);
00320    }
00321 }

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 955 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_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_true(), ast_variable_browse(), ast_verb, ast_channel_tech::capabilities, CONFIG_STATUS_FILEINVALID, global_jbconf, LOG_ERROR, ast_variable::name, ast_variable::next, soundcard_init(), and ast_variable::value.

00956 {
00957    struct ast_config *cfg;
00958    struct ast_variable *v;
00959    struct ast_flags config_flags = { 0 };
00960 
00961    if (!(alsa_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
00962       return AST_MODULE_LOAD_DECLINE;
00963    }
00964    ast_format_cap_append(alsa_tech.capabilities, ast_format_slin, 0);
00965 
00966    /* Copy the default jb config over global_jbconf */
00967    memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
00968 
00969    strcpy(mohinterpret, "default");
00970 
00971    if (!(cfg = ast_config_load(config, config_flags))) {
00972       ast_log(LOG_ERROR, "Unable to read ALSA configuration file %s.  Aborting.\n", config);
00973       return AST_MODULE_LOAD_DECLINE;
00974    } else if (cfg == CONFIG_STATUS_FILEINVALID) {
00975       ast_log(LOG_ERROR, "%s is in an invalid format.  Aborting.\n", config);
00976       return AST_MODULE_LOAD_DECLINE;
00977    }
00978 
00979    v = ast_variable_browse(cfg, "general");
00980    for (; v; v = v->next) {
00981       /* handle jb conf */
00982       if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
00983          continue;
00984       }
00985 
00986       if (!strcasecmp(v->name, "autoanswer")) {
00987          autoanswer = ast_true(v->value);
00988       } else if (!strcasecmp(v->name, "mute")) {
00989          mute = ast_true(v->value);
00990       } else if (!strcasecmp(v->name, "noaudiocapture")) {
00991          noaudiocapture = ast_true(v->value);
00992       } else if (!strcasecmp(v->name, "silencesuppression")) {
00993          silencesuppression = ast_true(v->value);
00994       } else if (!strcasecmp(v->name, "silencethreshold")) {
00995          silencethreshold = atoi(v->value);
00996       } else if (!strcasecmp(v->name, "context")) {
00997          ast_copy_string(context, v->value, sizeof(context));
00998       } else if (!strcasecmp(v->name, "language")) {
00999          ast_copy_string(language, v->value, sizeof(language));
01000       } else if (!strcasecmp(v->name, "extension")) {
01001          ast_copy_string(exten, v->value, sizeof(exten));
01002       } else if (!strcasecmp(v->name, "input_device")) {
01003          ast_copy_string(indevname, v->value, sizeof(indevname));
01004       } else if (!strcasecmp(v->name, "output_device")) {
01005          ast_copy_string(outdevname, v->value, sizeof(outdevname));
01006       } else if (!strcasecmp(v->name, "mohinterpret")) {
01007          ast_copy_string(mohinterpret, v->value, sizeof(mohinterpret));
01008       }
01009    }
01010    ast_config_destroy(cfg);
01011 
01012    if (soundcard_init() < 0) {
01013       ast_verb(2, "No sound card detected -- console channel will be unavailable\n");
01014       ast_verb(2, "Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf\n");
01015       return AST_MODULE_LOAD_DECLINE;
01016    }
01017 
01018    if (ast_channel_register(&alsa_tech)) {
01019       ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
01020       return AST_MODULE_LOAD_FAILURE;
01021    }
01022 
01023    ast_cli_register_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
01024 
01025    return AST_MODULE_LOAD_SUCCESS;
01026 }

static int soundcard_init ( void   )  [static]

Definition at line 277 of file chan_alsa.c.

References alsa, alsa_card_init(), ast_log, chan_alsa_pvt::icard, LOG_ERROR, and chan_alsa_pvt::ocard.

Referenced by load_module().

00278 {
00279    if (!noaudiocapture) {
00280       alsa.icard = alsa_card_init(indevname, SND_PCM_STREAM_CAPTURE);
00281       if (!alsa.icard) {
00282          ast_log(LOG_ERROR, "Problem opening alsa capture device\n");
00283          return -1;
00284       }
00285    }
00286 
00287    alsa.ocard = alsa_card_init(outdevname, SND_PCM_STREAM_PLAYBACK);
00288 
00289    if (!alsa.ocard) {
00290       ast_log(LOG_ERROR, "Problem opening ALSA playback device\n");
00291       return -1;
00292    }
00293 
00294    return writedev;
00295 }

static int unload_module ( void   )  [static]


Variable Documentation

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

struct chan_alsa_pvt alsa [static]

struct ast_channel_tech alsa_tech [static]

Definition at line 156 of file chan_alsa.c.

ast_mutex_t alsalock = { PTHREAD_MUTEX_INITIALIZER , NULL, 1 } [static]

Definition at line 1053 of file chan_alsa.c.

int autoanswer = 1 [static]

Definition at line 141 of file chan_alsa.c.

struct ast_cli_entry cli_alsa[] [static]

Definition at line 936 of file chan_alsa.c.

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

Definition at line 112 of file chan_alsa.c.

char context[AST_MAX_CONTEXT] = "default" [static]

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 114 of file chan_alsa.c.

Referenced by __sip_alloc(), acf_isexten_exec(), action_atxfer(), action_blind_transfer(), action_dialplan_exec(), action_extensionstate(), action_originate(), action_redirect(), add_action_to_menu_entry(), apply_outgoing(), ast_ari_channels_continue_in_dialplan(), ast_bridge_setup_after_goto(), ast_cdr_fork(), ast_channel_by_exten_cb(), ast_channel_snapshot_create(), ast_channel_yank(), ast_compile_ael2(), ast_get_enum(), ast_msg_alloc(), ast_msg_set_context(), ast_res_pjsip_initialize_configuration(), ast_sip_cli_print_sorcery_objectset(), AST_TEST_DEFINE(), base_process_party_a(), bridge_exec(), build_peer(), check_access(), check_peer_ok(), cli_aor_print_body(), cli_aor_print_header(), cli_channel_print_body(), cli_channel_print_header(), cli_contact_print_body(), cli_contact_print_header(), cli_endpoint_print_body(), cli_endpoint_print_header(), cli_print_body(), cli_print_header(), complete_dialplan_add_include(), complete_dialplan_remove_extension(), complete_dialplan_remove_include(), conf_run(), create_addr_from_peer(), delete_existing_cb(), disa_exec(), extenspy_exec(), extstate_read(), feature_blind_transfer(), get_also_info(), get_cid_name(), get_destination(), handle_cli_dialplan_remove_extension(), handle_request_bye(), handle_request_invite(), handle_request_options(), handle_request_refer(), hint_read(), hook_on(), iax2_call(), iax2_transfer(), isexten_function_read(), launch_ha_netscript(), load_config(), 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(), metermaidstate(), mwi_to_event(), orig_exten(), pickup_exec(), process_ast_dsp(), publish_mwi_to_stasis(), queue_mwi_event(), readexten_exec(), receive_message(), refer_incoming_attended_request(), refer_incoming_blind_request(), register_peer_exten(), reload_config(), retrydial_exec(), rx_data_to_ast_msg(), set_peer_defaults(), set_pvt_defaults(), setup_peer_after_bridge_goto(), sla_build_station(), sla_build_trunk(), socket_process_helper(), store_config_core(), and wait_for_answer().

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

char exten[AST_MAX_EXTENSION] = "s" [static]

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 116 of file chan_alsa.c.

Referenced by __analog_ss_thread(), action_atxfer(), action_blind_transfer(), action_dialplan_exec(), action_extensionstate(), action_originate(), action_redirect(), add_action_to_menu_entry(), apply_outgoing(), ast_ari_channels_continue_in_dialplan(), ast_bridge_setup_after_goto(), ast_cdr_fork(), ast_channel_by_exten_cb(), ast_channel_snapshot_create(), ast_channel_yank(), ast_compile_ael2(), ast_context_remove_extension_callerid2(), ast_ivr_menu_run_internal(), ast_msg_set_exten(), ast_phoneprov_add_extension(), AST_TEST_DEFINE(), base_process_party_a(), build_extension(), check_access(), check_user_full(), complete_dialplan_remove_extension(), complete_dpreply(), context_used(), copy_plain_file(), create_queue_member(), delete_existing_cb(), disa_exec(), expand_gosub_args(), extenspy_exec(), extstate_read(), feature_attended_transfer(), feature_blind_transfer(), get_cid_name(), get_destination(), get_rdnis(), handle_blind_transfer(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_remove_extension(), handle_debug_dialplan(), handle_request_invite(), handle_show_dialplan(), hint_read(), hook_on(), initreqprep(), isexten_function_read(), leave_voicemail(), local_devicestate(), lua_pbx_exec(), lua_sort_extensions(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), manager_show_dialplan(), metermaidstate(), mgcp_ss(), new_iax(), options_on_rx_request(), orig_exten(), originate_exec(), osplookup_exec(), pickup_exec(), pp_each_extension_helper(), raise_exception(), readexten_exec(), refer_incoming_blind_request(), register_verify(), rx_data_to_ast_msg(), session_inv_on_redirected(), set_pvt_defaults(), sip_new(), sip_request_call(), sla_build_station(), sla_station_destructor(), socket_process_helper(), store_config_core(), test_exten(), 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().

snd_pcm_format_t format = SND_PCM_FORMAT_S16_BE [static]

struct ast_jb_conf global_jbconf [static]

Definition at line 77 of file chan_alsa.c.

int hookstate = 0 [static]

Definition at line 119 of file chan_alsa.c.

char indevname[50] = ALSA_INDEV [static]

Definition at line 103 of file chan_alsa.c.

char language[MAX_LANGUAGE] = "" [static]

char mohinterpret[MAX_MUSICCLASS] [static]

int mute = 0 [static]

int noaudiocapture = 0 [static]

Definition at line 143 of file chan_alsa.c.

char outdevname[50] = ALSA_OUTDEV [static]

Definition at line 104 of file chan_alsa.c.

int readdev = -1 [static]

Definition at line 138 of file chan_alsa.c.

int silencesuppression = 0 [static]

Definition at line 106 of file chan_alsa.c.

int silencethreshold = 1000 [static]

Definition at line 107 of file chan_alsa.c.

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

Definition at line 111 of file chan_alsa.c.

int writedev = -1 [static]

Definition at line 139 of file chan_alsa.c.


Generated on Thu Apr 16 06:29:30 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6