summaryrefslogtreecommitdiff
path: root/main/file.c
diff options
context:
space:
mode:
authorJeff Peeler <jpeeler@digium.com>2008-11-20 17:37:31 +0000
committerJeff Peeler <jpeeler@digium.com>2008-11-20 17:37:31 +0000
commitd12263a16a2eb4e3877a12a63b5531395d34ad4b (patch)
treea989baa292d97e3a80582d64136e2e65191b0e9e /main/file.c
parentcea9924353a6c5c29bcfed85c36f5a4a16c069db (diff)
(closes issue #12929)
Reported by: snyfer This handles the case for a zero length file to attempt to be streamed. Instead of failing from not playing any data, go ahead and return success as ast_streamfile should consider playing nothing a success when there is nothing to play. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@158062 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/file.c')
-rw-r--r--main/file.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/main/file.c b/main/file.c
index f6bdd7cf5..f94d1c19a 100644
--- a/main/file.c
+++ b/main/file.c
@@ -407,6 +407,9 @@ static int ast_filehelper(const char *filename, const void *arg2, const char *fm
ast_free(s);
continue; /* cannot run open on file */
}
+ if (st.st_size == 0) {
+ ast_log(LOG_WARNING, "File %s detected to have zero size.\n", fn);
+ }
/* ok this is good for OPEN */
res = 1; /* found */
s->lasttimeout = -1;
@@ -872,8 +875,19 @@ 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];
+ int seekattempt;
fs = ast_openstream(chan, filename, preflang);
+
+ /* 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)
+ fseek(fs->f, 0, SEEK_SET);
+ else
+ return 0;
+
if (fs)
vfs = ast_openvstream(chan, filename, preflang);
if (vfs) {