[Home]

Summary:ASTERISK-04505: [patch] (for channel.c) At monitor command in -out file written only noise when used chan-misdn.
Reporter:Mike Anikienko (mike anikienko)Labels:
Date Opened:2005-06-30 15:21:09Date Closed:2008-01-15 15:40:00.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) channel.c.patch
Description:This patch solve problem with noise in -out file at monitor command when used chan_misdn and some other channel driver.

****** ADDITIONAL INFORMATION ******

I am use chan-misdn for HFC-8s ISDN card. For record call to wav-file I use dialplan command:

exten => s,n,Monitor(wav,${CALLFILENAME})

I get 2 file: file-in.wav and file-out.wav. The file-in is Ok, but file-out contain only noise. Changing format (alaw,...) not solve this problem. I investivate this problem and I see skewness in channel.c in ast_read and ast_write. Below simplify code fom channel.c

ast_read:
f = chan->tech->read(chan);
ast_queue_spy_frame(spying, f, 0);
ast_writestream(chan->monitor->read_stream, f);
f = ast_translate(chan->readtrans, f, 1)

ast_write:
f = ast_translate(chan->writetrans, fr, 0)
res = chan->tech->write(chan, f);
ast_queue_spy_frame(spying, f, 1);
ast_writestream(chan->monitor->write_stream, f);
ast_frfree(f);

At ast_read read frame data from channel driver, write monitor stream, translate frame, but at ast_write translate frame, write to channel driver, write monitor stream and free frame. If channel driver use own conversion method frame data (straight at frame buffer) we can lost data at frame, and this noise write to monitor stream! In correct approach at ast_read we must at first read from channel driver and do other operation, but at asr_write we must at first do any operation, and at end write frame data to channel driver, and free frame.
I offer move write to channel driver command after all other operation and before free frame. My patch do this.
Comments:By: Kevin P. Fleming (kpfleming) 2005-07-05 18:13:22

Committed to CVS HEAD, thanks for the fix!

By: Digium Subversion (svnbot) 2008-01-15 15:40:00.000-0600

Repository: asterisk
Revision: 6035

U   trunk/channel.c

------------------------------------------------------------------------
r6035 | kpfleming | 2008-01-15 15:40:00 -0600 (Tue, 15 Jan 2008) | 2 lines

don't write frames out to channel until after sending them to spies and/or monitor, since the channel driver might modify the frame data in the buffer (bug ASTERISK-4505)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=6035