--- app_mixmonitor.c 2013-07-08 17:25:26.000000000 +0530 +++ app_mixmonitor.c 2013-10-05 11:06:55.000000000 +0530 @@ -332,6 +332,8 @@ ext = "raw"; if (!(*fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0666))) { + /* set channel variable */ + pbx_builtin_setvar_helper(mixmonitor->autochan->chan, "MIXMONITOR_STATUS", "ERROR"); ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext); errflag = 1; } @@ -342,7 +344,13 @@ struct ast_frame *cur; for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) { - ast_writestream(*fs, cur); + /* check writestream result and set channel variable if any error */ + 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->autochan->chan->name); + errflag = 1; + } + } } ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock); @@ -488,8 +496,8 @@ return; } - - /* Initialize the file if not already done so */ + /* Initialize the file now for immediate recordings */ + if (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED)) { struct ast_filestream **fs = NULL; unsigned int oflags; @@ -506,14 +514,20 @@ else ext = "raw"; + /* check writestream result. writestram with 0bytes is successfull even if disk is full. + * ast_truncstream returns error if disk is full */ if (!(*fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0666))) { ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext); pbx_builtin_setvar_helper(chan, "MIXMONITOR_STATUS", "ERROR"); } + else if (ast_truncstream(*fs) < 0) { + ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext); + pbx_builtin_setvar_helper(chan, "MIXMONITOR_STATUS", "ERROR"); + } else pbx_builtin_setvar_helper(chan, "MIXMONITOR_STATUS", "OK"); - } + ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor); }