static void dump_chan_io_to_file(ftdm_channel_t *fchan, ftdm_io_dump_t *dump, FILE *file)
{
/* write the saved audio buffer */
- size_t rc = 0;
- size_t towrite = dump->size - dump->windex;
+ ftdm_size_t rc = 0;
+ ftdm_size_t towrite = 0;
+
+ if (!dump->buffer) {
+ return;
+ }
+
+ towrite = dump->size - dump->windex;
+
if (dump->wrapped) {
rc = fwrite(&dump->buffer[dump->windex], 1, towrite, file);
if (rc != towrite) {
if (!obj) {
GOTO_STATUS(done, FTDM_FAIL);
}
+ if (!ftdmchan->rxdump.buffer) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Not dumped input to file %p, input dump is not enabled\n", obj);
+ GOTO_STATUS(done, FTDM_FAIL);
+ }
dump_chan_io_to_file(ftdmchan, &ftdmchan->rxdump, obj);
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped input of size %d to file %p\n", ftdmchan->rxdump.size, obj);
GOTO_STATUS(done, FTDM_SUCCESS);
if (!obj) {
GOTO_STATUS(done, FTDM_FAIL);
}
+ if (!ftdmchan->txdump.buffer) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Not dumped output to file %p, output dump is not enabled\n", obj);
+ GOTO_STATUS(done, FTDM_FAIL);
+ }
dump_chan_io_to_file(ftdmchan, &ftdmchan->txdump, obj);
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped input of size %zd to file %p\n", ftdmchan->txdump.size, obj);
GOTO_STATUS(done, FTDM_SUCCESS);