Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //the modem len is 160
- buffer tmp_for_readi[160 * 3 == 480];
- buffer tmp_for_writei[160 * 3 == 480];
- update_ptr(ptr,num){
- if (ptr + num) > 480
- ptr += ( ptr+num ) - 480;
- else
- ptr += num;
- }
- check_tmp_for_writei_pos(){
- if (readptr + 160 > writeptr);
- //push writeptr ahread because of collision
- if (writeptr + 160 > readptr);
- //push readptr ahread because of collision
- else if (readptr > writeptr+160)
- handle_xruns();
- }
- readi_callback(){
- check_tmp_for_readi_pos();
- if ( (readptr - writeptr) < N )
- //buffer overrun
- fill_with_silence();
- return;
- else
- N = readi(audiobuf);
- Memory.copy(audiobuf,tmp_for_readi)
- update_ptr(writeptr,N);
- return;
- }
- writei_callback(){
- check_tmp_for_writei_pos();
- if ( (writeptr-readptr) < N )
- //buffer underrun
- fill_with_silence();
- return;
- else
- N = writei(tmp_for_writei,card);
- update_prt(readptr, N);
- return;
- }
- write_to_modem(){
- Memory.copy(modem_write,tmp_for_readi,160);
- update_ptr(readptr,160);
- }
- read_from_modem(){
- Memory.copy(tmp_for_writei,modem_read,160);
- update_prt(writeptr,160);
- }
Add Comment
Please, Sign In to add comment