summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-01-05 22:11:41 +0000
committerKinsey Moore <kmoore@digium.com>2012-01-05 22:11:41 +0000
commit6fa808447b7c5e3d57e4e60861368392e51a2bee (patch)
tree4e762509109f2dc3b895bca50b565723faf8b6b7
parentfd04da511461f1d21b4166a9937e3f00696de20d (diff)
Allow playback of formats that don't support seeking
ast_streamfile previously did unconditional seeking on files that broke playback of formats that don't support that functionality. This patch avoids the seek that was causing the problem. This regression was introduced in r158062. (closes issue ASTERISK-18994) Patch-by: Timo Teras ........ Merged revisions 349731 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 349732 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@349733 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--main/file.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/main/file.c b/main/file.c
index 1d871fde2..70b971cb3 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);