02-alsarelated.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --- unix/jkAudIO_alsa.c 2005-12-14 12:29:38.000000000 +0100
  2. +++ unix/jkAudIO_alsa.c 2008-09-01 22:51:20.000000000 +0200
  3. @@ -49,6 +49,8 @@
  4. static int minNumChan = 1;
  5. +static snd_pcm_uframes_t hw_bufsize = 0;
  6. +
  7. int
  8. SnackAudioOpen(ADesc *A, Tcl_Interp *interp, char *device, int mode, int freq,
  9. int nchannels, int encoding)
  10. @@ -135,6 +137,9 @@
  11. Tcl_AppendResult(interp, "Failed setting HW params.", NULL);
  12. return TCL_ERROR;
  13. }
  14. +
  15. + snd_pcm_hw_params_get_buffer_size (hw_params, &hw_bufsize);
  16. +
  17. snd_pcm_hw_params_free(hw_params);
  18. snd_pcm_prepare(A->handle);
  19. if (A->mode == RECORD) {
  20. @@ -202,6 +207,8 @@
  21. int i;
  22. static char buf[64];
  23. + return;
  24. +
  25. if (A->debug > 1) Snack_WriteLog(" Enter SnackAudioPost\n");
  26. for (i = 0; i < 1000; i++) {
  27. @@ -267,12 +274,14 @@
  28. long
  29. SnackAudioPlayed(ADesc *A)
  30. {
  31. - long avail = _snd_pcm_mmap_hw_ptr(A->handle);
  32. + // FIX Here, _snd_pcm_mmap_hw_ptr is deprecated in new alsalib
  33. + long played = A->nWritten - (hw_bufsize - SnackAudioWriteable(A));
  34. + // long avail = _snd_pcm_mmap_hw_ptr(A->handle);
  35. - if (avail < 0)
  36. - avail = 0;
  37. + if (played < 0)
  38. + return 0;
  39. - return (avail+A->nPlayed);
  40. + return (played);
  41. }