Index: main/app.c =================================================================== --- main/app.c (revision 87041) +++ main/app.c (working copy) @@ -689,8 +689,6 @@ } else { ast_frfree(f); } - if (end == start) - end = time(NULL); } else { ast_log(LOG_WARNING, "Error creating writestream '%s', format '%s'\n", recordfile, sfmt[x]); } @@ -699,8 +697,18 @@ if (silgen) ast_channel_stop_silence_generator(chan, silgen); } - *duration = end - start; + /*!\note + * Instead of asking how much time passed (end - start), calculate the number + * of seconds of audio which actually went into the file. This fixes a + * problem where audio is stopped up on the network and never gets to us. + * + * Note that we still want to use the number of seconds passed for the max + * message, otherwise we could get a situation where this stream is never + * closed (which would create a resource leak). + */ + *duration = ast_tellstream(others[0]) / 8000; + if (!prepend) { for (x = 0; x < fmtcnt; x++) { if (!others[x])