Index: apps/app_mixmonitor.c =================================================================== --- apps/app_mixmonitor.c (revision 403146) +++ apps/app_mixmonitor.c (working copy) @@ -559,6 +559,18 @@ ast_string_field_free_memory(&recording_data); } +static void send_mixmonitor_status_event(struct mixmonitor *mixmonitor, char *status) +{ + ast_manager_event(mixmonitor->autochan->chan, EVENT_FLAG_CALL, "MixMonitorStatus", + "Channel: %s\r\n" + "File: %s\r\n" + "Status: %s\r\n", + mixmonitor->name, + mixmonitor->filename, + status + ); +} + static void mixmonitor_save_prep(struct mixmonitor *mixmonitor, char *filename, struct ast_filestream **fs, unsigned int *oflags, int *errflag, char **ext) { /* Initialize the file if not already done so */ @@ -579,8 +591,17 @@ if (!(*fs = ast_writefile(filename, *ext, NULL, *oflags, 0, 0666))) { ast_log(LOG_ERROR, "Cannot open %s.%s\n", filename, *ext); + pbx_builtin_setvar_helper(mixmonitor->autochan->chan, "MIXMONITOR_STATUS", "ERROR"); + send_mixmonitor_status_event(mixmonitor, "ERROR"); *errflag = 1; - } else { + } else if (ast_truncstream(*fs) < 0) { + ast_log(LOG_ERROR, "Cannot open %s.%s\n", filename, *ext); + pbx_builtin_setvar_helper(mixmonitor->autochan->chan, "MIXMONITOR_STATUS", "ERROR"); + send_mixmonitor_status_event(mixmonitor, "ERROR"); + *errflag = 1; + } + else { + pbx_builtin_setvar_helper(mixmonitor->autochan->chan, "MIXMONITOR_STATUS", "OK"); struct ast_filestream *tmp = *fs; mixmonitor->mixmonitor_ds->samp_rate = MAX(mixmonitor->mixmonitor_ds->samp_rate, ast_format_rate(&tmp->fmt->format)); } @@ -671,7 +692,12 @@ struct ast_frame *cur; for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) { - ast_writestream(*fs, cur); + if(ast_writestream(*fs, cur) < 0){ + pbx_builtin_setvar_helper(mixmonitor->autochan->chan, "MIXMONITOR_STATUS", "ERROR"); + ast_log(LOG_ERROR, "Cannot write frame %s.%s\n", mixmonitor->filename, mixmonitor->name); + send_mixmonitor_status_event(mixmonitor, "ERROR"); + errflag = 1; + } } } ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);