summaryrefslogtreecommitdiff
path: root/channels/chan_alsa.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /channels/chan_alsa.c
parent652fb64a01c7a8656697d07e606620ee0ced6929 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_alsa.c')
-rw-r--r--channels/chan_alsa.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 120987ae4..58382881e 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -133,7 +133,7 @@ static int autoanswer = 1;
static int mute = 0;
static int noaudiocapture = 0;
-static struct ast_channel *alsa_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *alsa_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause);
static int alsa_digit(struct ast_channel *c, char digit, unsigned int duration);
static int alsa_text(struct ast_channel *c, const char *text);
static int alsa_hangup(struct ast_channel *c);
@@ -144,10 +144,9 @@ static int alsa_write(struct ast_channel *chan, struct ast_frame *f);
static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen);
static int alsa_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static const struct ast_channel_tech alsa_tech = {
+static struct ast_channel_tech alsa_tech = {
.type = "Console",
.description = tdesc,
- .capabilities = AST_FORMAT_SLINEAR,
.requester = alsa_request,
.send_digit_end = alsa_digit,
.send_text = alsa_text,
@@ -502,7 +501,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
}
f.frametype = AST_FRAME_VOICE;
- f.subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR, 0);
f.samples = FRAME_SIZE;
f.datalen = FRAME_SIZE * 2;
f.data.ptr = buf;
@@ -572,9 +571,10 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state, const ch
tmp->tech = &alsa_tech;
ast_channel_set_fd(tmp, 0, readdev);
- tmp->nativeformats = AST_FORMAT_SLINEAR;
- tmp->readformat = AST_FORMAT_SLINEAR;
- tmp->writeformat = AST_FORMAT_SLINEAR;
+ ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
+ ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
+ ast_format_cap_add(tmp->nativeformats, &tmp->writeformat);
+
tmp->tech_pvt = p;
if (!ast_strlen_zero(p->context))
ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
@@ -596,14 +596,16 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state, const ch
return tmp;
}
-static struct ast_channel *alsa_request(const char *type, format_t fmt, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *alsa_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
{
- format_t oldformat = fmt;
+ struct ast_format tmpfmt;
char buf[256];
struct ast_channel *tmp = NULL;
- if (!(fmt &= AST_FORMAT_SLINEAR)) {
- ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), oldformat));
+ ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0);
+
+ if (!(ast_format_cap_iscompatible(cap, &tmpfmt))) {
+ ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
return NULL;
}
@@ -929,6 +931,12 @@ static int load_module(void)
struct ast_config *cfg;
struct ast_variable *v;
struct ast_flags config_flags = { 0 };
+ struct ast_format tmpfmt;
+
+ if (!(alsa_tech.capabilities = ast_format_cap_alloc())) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_format_cap_add(alsa_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
/* Copy the default jb config over global_jbconf */
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
@@ -1006,6 +1014,7 @@ static int unload_module(void)
if (alsa.owner)
return -1;
+ alsa_tech.capabilities = ast_format_cap_destroy(alsa_tech.capabilities);
return 0;
}