iaudiomgrinterface.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #ifdef _WIN32
  3. #ifdef LIBAUDIOMGR_EXPORTS
  4. #define LIBAUDIOMGR_API __declspec(dllexport)
  5. #else
  6. #define LIBAUDIOMGR_API __declspec(dllimport)
  7. #endif
  8. # elif ( defined(__GNUC__) && __GNUC__ >= 4 )
  9. #define LIBAUDIOMGR_API __attribute__((visibility("default")))
  10. #else // RVC_OS_WIN
  11. #define LIBAUDIOMGR_API
  12. #endif // RVC_OS_WIN
  13. #include <stddef.h>
  14. #include <stdarg.h>
  15. typedef struct audiocap_param_s
  16. {
  17. /** callbacks */
  18. int ideviceid;
  19. int isamprate;
  20. int ichannels;
  21. int isampleformat;
  22. double flatency;
  23. /* called from inner thread, should not block, can be null */
  24. void (*on_audio_callback)(const void* input, unsigned long audiolen,void* userdata);
  25. void* user_data;
  26. }audiocap_param_t;
  27. typedef struct audiomgr_callback_s{
  28. void (*debug)(void* user_data, const char* fmt, va_list arg);
  29. void (*on_audio_mgr_failed)();
  30. void (*on_audio_mgr_excption)();
  31. void* user_data;
  32. }audiomgr_callback_t;
  33. class IAudioMgr
  34. {
  35. public:
  36. virtual int audio_mgr_initialize() = 0;
  37. virtual int audio_mgr_terminate() = 0;
  38. /**/
  39. virtual int audio_get_device_count(bool binput) = 0;
  40. virtual int audio_get_device_name(char* pstrbuf, size_t ulen, bool binput, int index) = 0;
  41. virtual int audio_get_device_id(const char* pstrname, bool binput) = 0;
  42. virtual int audio_get_device_volume(int* ivolume, const char* pstrname, bool binput) = 0;
  43. virtual int audio_set_device_volume(int ivolume, const char* pstrname, bool binput) = 0;
  44. virtual int set_audio_capture_params(audiocap_param_t* param) = 0;
  45. virtual int start_audio_capture() = 0;
  46. virtual int stop_audio_capture() = 0;
  47. virtual int audio_mgr_destroy() = 0;
  48. };
  49. extern "C" LIBAUDIOMGR_API IAudioMgr* CreateAudioMgrObj(audiomgr_callback_t* pCallback);
  50. extern "C" LIBAUDIOMGR_API void DestroyIAudioMgrObj(IAudioMgr* pIAudioMgr);