[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r302787 - /team/dvossel/fixt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 19 16:56:39 CST 2011


Author: dvossel
Date: Wed Jan 19 16:56:35 2011
New Revision: 302787

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302787
Log:
conversion of chan_usbradio

Modified:
    team/dvossel/fixtheworld_phase1_step3/channels/chan_usbradio.c

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_usbradio.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_usbradio.c?view=diff&rev=302787&r1=302786&r2=302787
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_usbradio.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_usbradio.c Wed Jan 19 16:56:35 2011
@@ -661,7 +661,7 @@
 
 static int setformat(struct chan_usbradio_pvt *o, int mode);
 
-static struct ast_channel *usbradio_request(const char *type, format_t format,
+static struct ast_channel *usbradio_request(const char *type, struct ast_format_cap *cap,
 		const struct ast_channel *requestor,
 		void *data, int *cause);
 static int usbradio_digit_begin(struct ast_channel *c, char digit);
@@ -682,10 +682,11 @@
 
 static char tdesc[] = "USB (CM108) Radio Channel Driver";
 
-static const struct ast_channel_tech usbradio_tech = {
+static struct ast_format slin;
+
+static struct ast_channel_tech usbradio_tech = {
 	.type = "Radio",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_SLINEAR,
 	.requester = usbradio_request,
 	.send_digit_begin = usbradio_digit_begin,
 	.send_digit_end = usbradio_digit_end,
@@ -2060,7 +2061,7 @@
 		return f;
 	/* ok we can build and deliver the frame to the caller */
 	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 = o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET;
@@ -2177,9 +2178,9 @@
 	if (o->sounddev < 0)
 		setformat(o, O_RDWR);
 	c->fds[0] = o->sounddev;	/* -1 if device closed, override later */
-	c->nativeformats = AST_FORMAT_SLINEAR;
-	c->readformat = AST_FORMAT_SLINEAR;
-	c->writeformat = AST_FORMAT_SLINEAR;
+	ast_format_cap_add(c->nativeformats, &slin);
+	ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
+	ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
 	c->tech_pvt = o;
 
 	if (!ast_strlen_zero(o->language))
@@ -2211,7 +2212,7 @@
 }
 /*
 */
-static struct ast_channel *usbradio_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *usbradio_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
 {
 	struct ast_channel *c;
 	struct chan_usbradio_pvt *o = find_desc(data);
@@ -2227,8 +2228,7 @@
 		/* XXX we could default to 'dsp' perhaps ? */
 		return NULL;
 	}
-	if ((format & AST_FORMAT_SLINEAR) == 0) {
-		ast_log(LOG_NOTICE, "Format 0x%" PRIx64 " unsupported\n", format);
+	if (!(ast_format_cap_iscompatible(cap, &slin))) {
 		return NULL;
 	}
 	if (o->owner) {
@@ -3932,6 +3932,11 @@
 	struct ast_flags zeroflag = {0};
 #endif
 
+	if (!(usbradio_tech.capabilities = ast_format_cap_alloc())) {
+		return AST_MODULE_LOAD_DECLINE;
+	}
+	ast_format_cap_add(usbradio_tech.capabilities, ast_format_set(&slin, AST_FORMAT_SLINEAR, 0));
+
 	if (hid_device_mklist()) {
 		ast_log(LOG_NOTICE, "Unable to make hid list\n");
 		return AST_MODULE_LOAD_DECLINE;
@@ -4016,6 +4021,8 @@
 		/* XXX what about the thread ? */
 		/* XXX what about the memory allocated ? */
 	}
+
+	usbradio_tech.capabilities = ast_format_cap_destroy(usbradio_tech.capabilities);
 	return 0;
 }
 




More information about the asterisk-commits mailing list