整理代码

This commit is contained in:
蒲爽 2026-09-28 21:33:04 +08:00
commit c7b4e178ec
364 changed files with 59691 additions and 0 deletions

83
video/alsa/SoundCard.h Normal file
View file

@ -0,0 +1,83 @@
#ifndef A83739DB_6BC9_4B7C_8FA0_11DC60C05AA3
#define A83739DB_6BC9_4B7C_8FA0_11DC60C05AA3
/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include <alsa/asoundlib.h>
#include <Poco/SharedPtr.h>
#include <string>
#include <vector>
namespace Video
{
namespace ALSA
{
/*
*******************************************************************************
* CLASS DECLARE
*******************************************************************************
*/
class SoundCard
{
public:
struct Info
{
std::string id;
std::string device;
std::string name;
std::string longname;
std::string driver;
std::string components;
std::string mixername;
bool access[SND_PCM_ACCESS_LAST + 1];
std::vector<snd_pcm_format_t> formats;
int channels;
std::vector<uint32_t> sampleRates;
std::vector<uint32_t> bufferSizes;
bool supportCapture;
bool supportPlayback;
bool operator==(const Info& other)
{
return components == other.components;
}
};
using Ptr = Poco::SharedPtr<SoundCard>;
using SoundCards = std::vector<Ptr>;
private:
SoundCard(int index);
void initialize();
public:
~SoundCard();
Info& info();
private:
int _index;
Info _info;
public:
static SoundCards getSoundCards();
template <class F> static SoundCards getSoundCards(F&& filter);
};
template <class F> inline SoundCard::SoundCards SoundCard::getSoundCards(F&& filter)
{
SoundCard::SoundCards cards;
for (auto& card : ALSA::SoundCard::getSoundCards())
{
if (filter(card))
cards.push_back(card);
}
return cards;
}
}
}
#endif