--- a/main/file.c.orig 2011-12-09 11:32:05.000000000 +0200 +++ b/main/file.c 2011-12-09 11:35:22.000000000 +0200 @@ -1005,6 +1005,7 @@ struct ast_filestream *fs; struct ast_filestream *vfs=NULL; char fmt[256]; + off_t pos; int seekattempt; int res; @@ -1017,12 +1018,14 @@ /* check to see if there is any data present (not a zero length file), * done this way because there is no where for ast_openstream_full to * return the file had no data. */ - seekattempt = fseek(fs->f, -1, SEEK_END); + pos = ftello(fs->f); + seekattempt = fseeko(fs->f, -1, SEEK_END); if (seekattempt && errno == EINVAL) { /* Zero-length file, as opposed to a pipe */ return 0; - } else { - ast_seekstream(fs, 0, SEEK_SET); + } + if (seekattempt == 0) { + fseeko(fs->f, pos, SEEK_SET); } vfs = ast_openvstream(chan, filename, preflang);