[asterisk-dev] Question about zt_read() in chan_zap

Tony Mountifield tony at softins.clara.co.uk
Wed Jan 17 11:22:20 MST 2007


Hi, I'm making a mod to zt_read() in order to test something here, and
I've come across on oddity in the code for that function.

The code that reads the audio data from the zap device is:

readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
res = read(p->subs[index].zfd, readbuf, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);

So the audio data is put at AST_FRIENDLY_OFFSET from the start of the
buffer in the pvt.

However, further down when constructing the voice frame, the code is:

p->subs[index].f.frametype = AST_FRAME_VOICE;
p->subs[index].f.subclass = ast->rawreadformat;
p->subs[index].f.samples = READ_SIZE;
p->subs[index].f.mallocd = 0;
p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET/2;

It is this last line I don't understand. Why *half* of AST_FRIENDLY_OFFSET?

To me it looks like the frame will point to 32 rubbish (or zero) bytes
before the correct data, and will miss off 32 bytes of real data at the end.

Is it wrong, or am I confused?

Cheers
Tony

-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org


More information about the asterisk-dev mailing list