mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-07 10:28:32 +00:00
Fix choppy audio with > 20ms audio frames (bug #5697)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7542 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -263,14 +263,17 @@ static char *istalking(int x)
|
|||||||
return "(not talking)";
|
return "(not talking)";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int careful_write(int fd, unsigned char *data, int len)
|
static int careful_write(int fd, unsigned char *data, int len, int block)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT;
|
if (block) {
|
||||||
res = ioctl(fd, ZT_IOMUX, &x);
|
x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT;
|
||||||
|
res = ioctl(fd, ZT_IOMUX, &x);
|
||||||
|
} else
|
||||||
|
res = 0;
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
res = write(fd, data, len);
|
res = write(fd, data, len);
|
||||||
if (res < 1) {
|
if (res < 1) {
|
||||||
@@ -423,7 +426,7 @@ static void conf_play(struct ast_channel *chan, struct ast_conference *conf, int
|
|||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
if (data)
|
if (data)
|
||||||
careful_write(conf->fd, data, len);
|
careful_write(conf->fd, data, len, 1);
|
||||||
|
|
||||||
ast_mutex_unlock(&conflock);
|
ast_mutex_unlock(&conflock);
|
||||||
|
|
||||||
@@ -1308,7 +1311,11 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
|||||||
audio frames (in which case carefully writing would only
|
audio frames (in which case carefully writing would only
|
||||||
have delayed the audio even further).
|
have delayed the audio even further).
|
||||||
*/
|
*/
|
||||||
write(fd, f->data, f->datalen);
|
/* As it turns out, we do want to use careful write. We just
|
||||||
|
don't want to block, but we do want to at least *try*
|
||||||
|
to write out all the samples.
|
||||||
|
*/
|
||||||
|
careful_write(fd, f->data, f->datalen, 0);
|
||||||
}
|
}
|
||||||
} else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) {
|
} else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) {
|
||||||
char tmp[2];
|
char tmp[2];
|
||||||
|
|||||||
Reference in New Issue
Block a user