dac.c 819 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <rtthread.h>
  2. #include "dac.h"
  3. short dac_buffer[MAX_BUFFERS][DAC_BUFFER_MAX_SIZE];
  4. int dac_buffer_size[MAX_BUFFERS];
  5. int stopped;
  6. unsigned long current_srate;
  7. unsigned int underruns;
  8. void dac_reset()
  9. {
  10. stopped = 1;
  11. underruns = 0;
  12. dac_set_srate(44100);
  13. }
  14. // return the index of the next writeable buffer or -1 on failure
  15. int dac_get_writeable_buffer()
  16. {
  17. return 0;
  18. }
  19. // returns -1 if there is no free DMA buffer
  20. int dac_fill_dma()
  21. {
  22. return 0;
  23. }
  24. int dac_set_srate(unsigned long srate)
  25. {
  26. if (current_srate == srate)
  27. return 0;
  28. rt_kprintf("setting rate %lu\n", srate);
  29. switch(srate) {
  30. case 8000:
  31. case 8021:
  32. case 32000:
  33. case 44100:
  34. case 48000:
  35. case 88200:
  36. case 96000:
  37. break;
  38. default:
  39. return -1;
  40. }
  41. current_srate = srate;
  42. return 0;
  43. }
  44. void dac_init(void)
  45. {
  46. dac_reset();
  47. }