SoundCards.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __SOUNDCARDS_H__
  2. #define __SOUNDCARDS_H__
  3. #include "GlobalVariable.h"
  4. #include "AudioRecord.h"
  5. #include "spdlog/spdlog.h"
  6. #include <string>
  7. /**
  8. * @brief 全局的声卡信息
  9. *
  10. */
  11. #define SoundCards SoundCardManager::Instance()
  12. class SoundCardManager
  13. {
  14. SoundCardManager() = default;
  15. SoundCardManager(const SoundCardManager&) = delete;
  16. SoundCardManager& operator=(const SoundCardManager&) = delete;
  17. public:
  18. ~SoundCardManager() = default;
  19. static SoundCardManager& Instance()
  20. {
  21. static SoundCardManager instance;
  22. return instance;
  23. }
  24. /* 初始化数据,获取声卡信息 */
  25. bool InitData();
  26. /* 获取声卡信息 */
  27. // const std::list<AudioDevice_t>& getListAudioDevice() const { return m_listAudioDevice; }
  28. const std::list<AudioDeviceDesc_t>& getListAudioDeviceDesc() const { return m_listAudioDeviceDesc; }
  29. /* 获取声卡信息,将PCM通道根据规则分类 */
  30. const std::map<std::string, SoundCardPCMInfo_t>& getSoundCardInfo() { return m_mapSoundCardInfo; }
  31. private:
  32. /* 打印声卡列表 */
  33. // void printAudioDevices();
  34. /* 打印声卡描述列表 */
  35. void printAudioDeviceDesc(const std::map<std::string, SoundCardPCMInfo_t>& mapSoundCard);
  36. /* 将PCM通道分类 */
  37. void classifyPCMChannels();
  38. /* 取出dante声卡的PCM通道信息 */
  39. void getDanteSoundCardInfo(std::list<AudioDeviceDesc_t>& listPCM);
  40. /* 将剩余的PCM通道信息分类 */
  41. void classifyRemainingPCMChannels(std::list<AudioDeviceDesc_t>& listPCM);
  42. private:
  43. /* 声卡设备列表 */
  44. // std::list<AudioDevice_t> m_listAudioDevice;
  45. std::list<AudioDeviceDesc_t> m_listAudioDeviceDesc; /* 声卡字符设备列表 */
  46. std::map<std::string, SoundCardPCMInfo_t> m_mapSoundCardInfo; /* 声卡信息,key是声卡标识符 */
  47. };
  48. #endif // __SOUNDCARDS_H__