diff --git a/main/file.c b/main/file.c index 1d871fde22e189b46c60d26469b8837bc5a2876c..70b971cb3a33b2860438386ea662455ec30adf68 100644 --- a/main/file.c +++ b/main/file.c @@ -1012,6 +1012,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p struct ast_filestream *fs; struct ast_filestream *vfs=NULL; char fmt[256]; + off_t pos; int seekattempt; int res; @@ -1024,12 +1025,17 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p /* 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); - if (seekattempt && errno == EINVAL) { - /* Zero-length file, as opposed to a pipe */ - return 0; + pos = ftello(fs->f); + seekattempt = fseeko(fs->f, -1, SEEK_END); + if (seekattempt) { + if (errno == EINVAL) { + /* Zero-length file, as opposed to a pipe */ + return 0; + } else { + ast_seekstream(fs, 0, SEEK_SET); + } } else { - ast_seekstream(fs, 0, SEEK_SET); + fseeko(fs->f, pos, SEEK_SET); } vfs = ast_openvstream(chan, filename, preflang);