summaryrefslogtreecommitdiff
path: root/formats/format_g729.c
diff options
context:
space:
mode:
Diffstat (limited to 'formats/format_g729.c')
-rw-r--r--formats/format_g729.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/formats/format_g729.c b/formats/format_g729.c
index 042977728..477883f17 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -113,10 +113,19 @@ static int g729_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
static int g729_trunc(struct ast_filestream *fs)
{
- /* Truncate file to current length */
- if (ftruncate(fileno(fs->f), ftello(fs->f)) < 0)
+ int fd;
+ off_t cur;
+
+ if ((fd = fileno(fs->f)) < 0) {
+ ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for g729 filestream %p: %s\n", fs, strerror(errno));
return -1;
- return 0;
+ }
+ if ((cur = ftello(fs->f) < 0)) {
+ ast_log(AST_LOG_WARNING, "Unable to determine current position in g729 filestream %p: %s\n", fs, strerror(errno));
+ return -1;
+ }
+ /* Truncate file to current length */
+ return ftruncate(fd, cur);
}
static off_t g729_tell(struct ast_filestream *fs)