Summary: | ASTERISK-20984: Audible clicks when playing sox encoded au file with STREAM FILE AGI command | ||||
Reporter: | Roman S. (rolesok) | Labels: | |||
Date Opened: | 2013-01-25 08:56:01.000-0600 | Date Closed: | 2017-04-18 14:13:59 | ||
Priority: | Trivial | Regression? | |||
Status: | Closed/Complete | Components: | Formats/format_pcm | ||
Versions: | SVN 1.8.20.0 | Frequency of Occurrence | |||
Related Issues: |
| ||||
Environment: | Attachments: | ( 0) asterisk-1.8.20.0-au-clicks-2.diff | |||
Description: | This is duplicate of ASTERISK-12703 (which is closed, but doesn't solve described issue fully). Initial issue is reproduced with STREAM FILE AGI command and sox encoded au file.
Detailed description: {noformat} > soxi no.au Input File : 'no.au' Channels : 1 Sample Rate : 8000 Precision : 14-bit Duration : 00:00:00.60 = 4831 samples ~ 45.2906 CDDA sectors File Size : 4.88k Bit Rate : 64.6k Sample Encoding: 8-bit u-law Comment : 'Processed by SoX' {noformat} {noformat} > xxd no.au | head -n 5 0000000: 2e73 6e64 0000 002c 0000 12df 0000 0001 .snd...,........ 0000010: 0000 1f40 0000 0001 5072 6f63 6573 7365 ...@....Processe 0000020: 6420 6279 2053 6f58 0000 0000 ffff ff7e d by SoX.......~ 0000030: feff ffff ff7e 7e7e ffff ffff ffff ffff .....~~~........ 0000040: 7efe 7eff ffff fffe 7eff ffff ffff ffff ~.~.....~....... {noformat} formats/format_pcm.c {noformat} 282 static int check_header(FILE *f) 300 hdr_size = ltohl(header[AU_HDR_HDR_SIZE_OFF]); 301 if (hdr_size < AU_HEADER_SIZE) { 302 hdr_size = AU_HEADER_SIZE; {noformat} Header size can be larger then default AU_HEADER_SIZE (24 bytes). For mentioned no.au it's 44: {noformat} 300 hdr_size = ltohl(header[AU_HDR_HDR_SIZE_OFF]); (gdb) 301 if (hdr_size < AU_HEADER_SIZE) { (gdb) p hdr_size $6 = 44 {noformat} But au_seek() disregarding determined in check_header() value uses default size (AU_HEADER_SIZE = 24). {noformat} 399 off_t min = AU_HEADER_SIZE, max, cur; 422 if (whence == SEEK_SET) 423 offset = bytes + min; {noformat} This causes audible clicks at the beginning of each such .au file. Issue is reproduced with AGI STREAM FILE command because of: {noformat} 1933 static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]) 1959 ast_seekstream(fs, 0, SEEK_END); 1960 max_length = ast_tellstream(fs); 1961 ast_seekstream(fs, sample_offset, SEEK_SET); {noformat} Playback app. doesn't have such clicks because of direct file seeking - pos = ftello() -> fseeko(END) -> ftello() -> fseeko(pos) - file pointer returns to the same file position (44 instead of 24). | ||||
Comments: | By: Roman S. (rolesok) 2013-01-25 09:01:31.565-0600 Patch for asterisk 1.8.20.0 By: Friendly Automation (friendly-automation) 2017-04-18 14:14:00.190-0500 Change 5481 merged by George Joseph: format_pcm: Track actual header size of .au files [https://gerrit.asterisk.org/5481|https://gerrit.asterisk.org/5481] By: Friendly Automation (friendly-automation) 2017-04-18 14:14:38.125-0500 Change 5483 merged by George Joseph: format_pcm: Track actual header size of .au files [https://gerrit.asterisk.org/5483|https://gerrit.asterisk.org/5483] By: Friendly Automation (friendly-automation) 2017-04-18 14:18:56.068-0500 Change 5482 merged by George Joseph: format_pcm: Track actual header size of .au files [https://gerrit.asterisk.org/5482|https://gerrit.asterisk.org/5482] |