mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Use a 32k file buffer on recordings, which increases the efficiency of file recording.
(closes issue #11962) Reported by: garlew Patches: recording.patch uploaded by garlew (license 376) bug-11962.diff uploaded by snuffy (license 35) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@112564 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -328,6 +328,11 @@ static void wav_close(struct ast_filestream *s)
|
|||||||
{
|
{
|
||||||
char zero = 0;
|
char zero = 0;
|
||||||
struct wav_desc *fs = (struct wav_desc *)s->_private;
|
struct wav_desc *fs = (struct wav_desc *)s->_private;
|
||||||
|
|
||||||
|
if (s->filename) {
|
||||||
|
update_header(s->f);
|
||||||
|
}
|
||||||
|
|
||||||
/* Pad to even length */
|
/* Pad to even length */
|
||||||
if (fs->bytes & 0x1)
|
if (fs->bytes & 0x1)
|
||||||
fwrite(&zero, 1, 1, s->f);
|
fwrite(&zero, 1, 1, s->f);
|
||||||
@@ -416,7 +421,6 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s->bytes += f->datalen;
|
s->bytes += f->datalen;
|
||||||
update_header(fs->f);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@@ -117,6 +117,7 @@ struct ast_filestream {
|
|||||||
char *buf; /*!< buffer pointed to by ast_frame; */
|
char *buf; /*!< buffer pointed to by ast_frame; */
|
||||||
void *_private; /*!< pointer to private buffer */
|
void *_private; /*!< pointer to private buffer */
|
||||||
const char *orig_chan_name;
|
const char *orig_chan_name;
|
||||||
|
char *write_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
14
main/file.c
14
main/file.c
@@ -817,17 +817,22 @@ int ast_closestream(struct ast_filestream *f)
|
|||||||
ast_safe_system(cmd);
|
ast_safe_system(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (f->fmt->close) {
|
||||||
|
f->fmt->close(f);
|
||||||
|
}
|
||||||
if (f->filename)
|
if (f->filename)
|
||||||
ast_free(f->filename);
|
ast_free(f->filename);
|
||||||
if (f->realfilename)
|
if (f->realfilename)
|
||||||
ast_free(f->realfilename);
|
ast_free(f->realfilename);
|
||||||
if (f->fmt->close)
|
|
||||||
f->fmt->close(f);
|
|
||||||
fclose(f->f);
|
fclose(f->f);
|
||||||
if (f->vfs)
|
if (f->vfs)
|
||||||
ast_closestream(f->vfs);
|
ast_closestream(f->vfs);
|
||||||
if (f->orig_chan_name)
|
if (f->orig_chan_name)
|
||||||
free((void *) f->orig_chan_name);
|
free((void *) f->orig_chan_name);
|
||||||
|
if (f->write_buffer) {
|
||||||
|
ast_free(f->write_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
ast_module_unref(f->fmt->module);
|
ast_module_unref(f->fmt->module);
|
||||||
ast_free(f);
|
ast_free(f);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1051,6 +1056,11 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
|
|||||||
}
|
}
|
||||||
fs->vfs = NULL;
|
fs->vfs = NULL;
|
||||||
/* If truncated, we'll be at the beginning; if not truncated, then append */
|
/* If truncated, we'll be at the beginning; if not truncated, then append */
|
||||||
|
|
||||||
|
if ((fs->write_buffer = ast_malloc(32768))){
|
||||||
|
setvbuf(fs->f, fs->write_buffer, _IOFBF, 32768);
|
||||||
|
}
|
||||||
|
|
||||||
f->seek(fs, 0, SEEK_END);
|
f->seek(fs, 0, SEEK_END);
|
||||||
} else if (errno != EEXIST) {
|
} else if (errno != EEXIST) {
|
||||||
ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno));
|
||||||
|
Reference in New Issue
Block a user