snd_next.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #include "quakedef.h"
  16. extern int desired_speed;
  17. extern int desired_bits;
  18. qboolean SNDDMA_Init(void)
  19. {
  20. int size;
  21. size = 16384 + sizeof(dma_t);
  22. shm = malloc (size);
  23. memset((void*)shm, 0, size);
  24. shm->buffer = (char*)shm + sizeof(dma_t);
  25. shm->channels = 2;
  26. shm->speed = desired_speed;
  27. shm->samplebits = desired_bits;
  28. shm->samples = 16384 / (desired_bits / 8);
  29. shm->submission_chunk = 1;
  30. return true;
  31. }
  32. // return the current sample position (in mono samples read)
  33. // inside the recirculating dma buffer
  34. int SNDDMA_GetDMAPos(void)
  35. {
  36. shm->samplepos = (int)(realtime*shm->speed*shm->channels) & (shm->samples-1);
  37. return shm->samplepos;
  38. }
  39. void SNDDMA_Shutdown(void)
  40. {
  41. }