Guest User

Untitled

a guest
Oct 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. //the modem len is 160
  2.  
  3. buffer tmp_for_readi[160 * 3 == 480];
  4. buffer tmp_for_writei[160 * 3 == 480];
  5.  
  6. update_ptr(ptr,num){
  7. if (ptr + num) > 480
  8. ptr += ( ptr+num ) - 480;
  9. else
  10. ptr += num;
  11.  
  12. }
  13.  
  14.  
  15. check_tmp_for_writei_pos(){
  16. if (readptr + 160 > writeptr);
  17. //push writeptr ahread because of collision
  18. if (writeptr + 160 > readptr);
  19. //push readptr ahread because of collision
  20. else if (readptr > writeptr+160)
  21. handle_xruns();
  22. }
  23.  
  24.  
  25. readi_callback(){
  26. check_tmp_for_readi_pos();
  27. if ( (readptr - writeptr) < N )
  28. //buffer overrun
  29. fill_with_silence();
  30. return;
  31. else
  32. N = readi(audiobuf);
  33. Memory.copy(audiobuf,tmp_for_readi)
  34. update_ptr(writeptr,N);
  35. return;
  36. }
  37.  
  38. writei_callback(){
  39. check_tmp_for_writei_pos();
  40. if ( (writeptr-readptr) < N )
  41. //buffer underrun
  42. fill_with_silence();
  43. return;
  44. else
  45. N = writei(tmp_for_writei,card);
  46. update_prt(readptr, N);
  47. return;
  48. }
  49.  
  50.  
  51. write_to_modem(){
  52. Memory.copy(modem_write,tmp_for_readi,160);
  53. update_ptr(readptr,160);
  54. }
  55.  
  56. read_from_modem(){
  57. Memory.copy(tmp_for_writei,modem_read,160);
  58. update_prt(writeptr,160);
  59. }
Add Comment
Please, Sign In to add comment