DecoderGlobals.h 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef BELL_DISABLE_CODECS
  2. #ifndef DECODER_GLOBALS_H
  3. #define DECODER_GLOBALS_H
  4. #define AAC_READBUF_SIZE (4 * AAC_MAINBUF_SIZE * AAC_MAX_NCHANS)
  5. #define MP3_READBUF_SIZE (2 * 1024);
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <memory>
  9. #include "aacdec.h"
  10. #include "mp3dec.h"
  11. namespace bell
  12. {
  13. class DecodersInstance
  14. {
  15. public:
  16. DecodersInstance(){};
  17. ~DecodersInstance()
  18. {
  19. MP3FreeDecoder(mp3Decoder);
  20. AACFreeDecoder(aacDecoder);
  21. };
  22. HAACDecoder aacDecoder = NULL;
  23. HMP3Decoder mp3Decoder = NULL;
  24. void ensureAAC()
  25. {
  26. if (aacDecoder == NULL)
  27. {
  28. aacDecoder = AACInitDecoder();
  29. }
  30. }
  31. void ensureMP3()
  32. {
  33. if (mp3Decoder == NULL)
  34. {
  35. mp3Decoder = MP3InitDecoder();
  36. }
  37. }
  38. };
  39. extern bell::DecodersInstance* decodersInstance;
  40. void createDecoders();
  41. }
  42. #endif
  43. #endif