[asterisk-commits] file: branch file/bridging r79084 - /team/file/bridging/bridges/bridge_zaptel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Aug 10 14:09:07 CDT 2007
Author: file
Date: Fri Aug 10 14:09:07 2007
New Revision: 79084
URL: http://svn.digium.com/view/asterisk?view=rev&rev=79084
Log:
Even more tweaking! We don't need a list of the channels involved here and we don't need a separate structure just to contain the conference file descriptor.
Modified:
team/file/bridging/bridges/bridge_zaptel.c
Modified: team/file/bridging/bridges/bridge_zaptel.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/bridges/bridge_zaptel.c?view=diff&rev=79084&r1=79083&r2=79084
==============================================================================
--- team/file/bridging/bridges/bridge_zaptel.c (original)
+++ team/file/bridging/bridges/bridge_zaptel.c Fri Aug 10 14:09:07 2007
@@ -55,12 +55,6 @@
struct zaptel_mixer {
int fd; /*!< File descriptor for the pseudo channel */
int conf; /*!< Zaptel conference number */
- AST_LIST_HEAD_NOLOCK(, zaptel_mixer_channel) channels;
-};
-
-struct zaptel_mixer_channel {
- int fd; /*!< File descriptor for our listening/talking channel */
- AST_LIST_ENTRY(zaptel_mixer_channel) list;
};
static int careful_write(int fd, unsigned char *data, int len)
@@ -128,25 +122,18 @@
static int zaptel_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
struct zaptel_mixer *zm = bridge->bridge_pvt;
- struct zaptel_mixer_channel *zmc = NULL;
+ int fd = -1;
struct zt_confinfo ztc = { 0, };
int flags = 0, x = 1;
ZT_BUFFERINFO bi;
- /* Boom! Need another structure */
- if (!(zmc = ast_calloc(1, sizeof(*zmc))))
- return -1;
-
/* Attempt to open the pseudo channel */
- if ((zmc->fd = open("/dev/zap/pseudo", O_RDWR)) < 0) {
- free(zmc);
- return -1;
- }
+ if ((fd = open("/dev/zap/pseudo", O_RDWR)) < 0)
+ return -1;
/* Switch to non-blocking */
- if (((flags = fcntl(zmc->fd, F_GETFL)) < 0) || (fcntl(zmc->fd, F_SETFL, flags | O_NONBLOCK))) {
- close(zmc->fd);
- free(zmc);
+ if (((flags = fcntl(fd, F_GETFL)) < 0) || (fcntl(fd, F_SETFL, flags | O_NONBLOCK))) {
+ close(fd);
return -1;
}
@@ -158,65 +145,52 @@
bi.numbufs = 32;
/* Apply the above */
- if (ioctl(zmc->fd, ZT_SET_BUFINFO, &bi)) {
- close(zmc->fd);
- free(zmc);
+ if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+ close(fd);
return -1;
}
/* Set linear mode */
- if (ioctl(zmc->fd, ZT_SETLINEAR, &x)) {
- close(zmc->fd);
- free(zmc);
+ if (ioctl(fd, ZT_SETLINEAR, &x)) {
+ close(fd);
return -1;
}
/* Add us to the conference */
ztc.confno = zm->conf;
ztc.confmode = ZT_CONF_CONF | ZT_CONF_TALKER | ZT_CONF_LISTENER;
- if (ioctl(zmc->fd, ZT_SETCONF, &ztc)) {
- close(zmc->fd);
- free(zmc);
- return -1;
- }
-
- /* Add ourselves to the zaptel mixer structure */
- AST_LIST_INSERT_TAIL(&zm->channels, zmc, list);
-
+ if (ioctl(fd, ZT_SETCONF, &ztc)) {
+ close(fd);
+ return -1;
+ }
+
/* We "should" be a go */
- bridge_channel->fds[0] = zmc->fd;
- bridge_channel->bridge_pvt = zmc;
+ bridge_channel->fds[0] = fd;
+ bridge_channel->bridge_pvt = (void*)(long)fd;
return 0;
}
static int zaptel_bridge_leave(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
- struct zaptel_mixer *zm = bridge->bridge_pvt;
- struct zaptel_mixer_channel *zmc = bridge_channel->bridge_pvt;
+ int fd = (int)(long)bridge_channel->bridge_pvt;
struct zt_confinfo ztc = { 0, };
- /* Take ourselves out of the zaptel mixer structure */
- AST_LIST_REMOVE(&zm->channels, zmc, list);
-
/* Take ourselves out of the conference */
- ioctl(zmc->fd, ZT_SETCONF, &ztc);
+ ioctl(fd, ZT_SETCONF, &ztc);
/* Close down the open file descriptor */
- close(zmc->fd);
-
- /* Free the memory and go on our merry way */
- free(zmc);
+ close(fd);
return 0;
}
static int zaptel_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
{
- struct zaptel_mixer_channel *zmc = bridge_channel->bridge_pvt;
+ int fd = (int)(long)bridge_channel->bridge_pvt;
/* Write audio into zaptel conference */
- careful_write(zmc->fd, frame->data, frame->datalen);
+ careful_write(fd, frame->data, frame->datalen);
return 0;
}
More information about the asterisk-commits
mailing list