[asterisk-commits] mjordan: trunk r396412 - /trunk/formats/format_wav_gsm.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 8 13:40:16 CDT 2013
Author: mjordan
Date: Thu Aug 8 13:40:15 2013
New Revision: 396412
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396412
Log:
Improve disk writes for wav49 format
Writing to a file in the wav49 format performs rather inefficiently. The
procedure is approximately:
(1) Write GSM frame to the end of the file
(2) Seek to the end of the file
(3) Seek to the header
(4) Update the file size
(5) Seek (again) to the end of the file
(6) Repeat
This pattern negates any attempt to use the stdio buffering setup in
ast_writefile. It also results in many small writes that require a seek going
to the disk each second which translates to poor disk performance on certain
file systems, particularly when there are multiple wav49 files being written
simultaneously.
(closes issue ASTERISK-19595)
Reported by: Byron Clark
Tested by: Byron Clark
patches:
gsm_wav_only_update_header_on_close.patch uploaded by byronclark (License 6157)
Modified:
trunk/formats/format_wav_gsm.c
Modified: trunk/formats/format_wav_gsm.c
URL: http://svnview.digium.com/svn/asterisk/trunk/formats/format_wav_gsm.c?view=diff&rev=396412&r1=396411&r2=396412
==============================================================================
--- trunk/formats/format_wav_gsm.c (original)
+++ trunk/formats/format_wav_gsm.c Thu Aug 8 13:40:15 2013
@@ -393,6 +393,17 @@
return 0;
}
+static void wav_close(struct ast_filestream *s)
+{
+ if (s->mode == O_RDONLY) {
+ return;
+ }
+
+ if (s->filename) {
+ update_header(s->f);
+ }
+}
+
static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
{
/* Send a frame from the file to the appropriate channel */
@@ -468,7 +479,6 @@
ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno));
return -1;
}
- update_header(s->f); /* XXX inefficient! */
}
return 0;
}
@@ -560,6 +570,7 @@
.trunc = wav_trunc,
.tell = wav_tell,
.read = wav_read,
+ .close = wav_close,
.buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct wavg_desc),
};
More information about the asterisk-commits
mailing list