mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-17 02:56:16 +02:00
Rename WasapiMode to SharingMode
The mode is more general and will be applied in a second step also to other audio devices
This commit is contained in:
parent
5cc37f98f4
commit
30753f9f61
5 changed files with 17 additions and 21 deletions
|
@ -27,13 +27,11 @@
|
|||
|
||||
struct ClientSettings
|
||||
{
|
||||
#ifdef HAS_WASAPI
|
||||
enum class WasapiMode
|
||||
enum class SharingMode
|
||||
{
|
||||
SHARED,
|
||||
EXCLUSIVE
|
||||
exclusive,
|
||||
shared
|
||||
};
|
||||
#endif
|
||||
|
||||
struct ServerSettings
|
||||
{
|
||||
|
@ -47,9 +45,7 @@ struct ClientSettings
|
|||
int latency{0};
|
||||
PcmDevice pcm_device;
|
||||
SampleFormat sample_format;
|
||||
#ifdef HAS_WASAPI
|
||||
WasapiMode wasapi_mode{WasapiMode::SHARED};
|
||||
#endif
|
||||
SharingMode sharing_mode{SharingMode::shared};
|
||||
};
|
||||
|
||||
struct LoggingSettings
|
||||
|
|
|
@ -145,7 +145,7 @@ void Controller::onMessageReceived(ClientConnection* /*connection*/, const msg::
|
|||
#endif
|
||||
#ifdef HAS_WASAPI
|
||||
if (!player_ && (player_name.empty() || (player_name == "wasapi")))
|
||||
player_ = make_unique<WASAPIPlayer>(pcm_device, stream_, settings_.player.wasapi_mode);
|
||||
player_ = make_unique<WASAPIPlayer>(pcm_device, stream_, settings_.player.sharing_mode);
|
||||
#endif
|
||||
if (!player_)
|
||||
throw SnapException("No audio player support");
|
||||
|
|
|
@ -68,7 +68,7 @@ EXTERN_C const PROPERTYKEY DECLSPEC_SELECTANY PKEY_Device_FriendlyName = {{0xa45
|
|||
throw SnapException(ss.str()); \
|
||||
}
|
||||
|
||||
WASAPIPlayer::WASAPIPlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> stream, ClientSettings::WasapiMode mode) : Player(pcmDevice, stream), mode_(mode)
|
||||
WASAPIPlayer::WASAPIPlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> stream, ClientSettings::SharingMode mode) : Player(pcmDevice, stream), mode_(mode)
|
||||
{
|
||||
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
CHECK_HR(hr);
|
||||
|
@ -217,7 +217,7 @@ void WASAPIPlayer::worker()
|
|||
hr = device->Activate(IID_IAudioClient, CLSCTX_SERVER, NULL, (void**)&audioClient);
|
||||
CHECK_HR(hr);
|
||||
|
||||
if (mode_ == ClientSettings::WasapiMode::EXCLUSIVE)
|
||||
if (mode_ == ClientSettings::SharingMode::exclusive)
|
||||
{
|
||||
hr = audioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, &(waveformatExtended->Format), NULL);
|
||||
CHECK_HR(hr);
|
||||
|
@ -245,10 +245,10 @@ void WASAPIPlayer::worker()
|
|||
hr = audioClient->GetDevicePeriod(NULL, &hnsRequestedDuration);
|
||||
CHECK_HR(hr);
|
||||
|
||||
LOG(INFO, LOG_TAG) << "Initializing WASAPI in " << (mode_ == ClientSettings::WasapiMode::SHARED ? "shared" : "exclusive") << " mode\n";
|
||||
LOG(INFO, LOG_TAG) << "Initializing WASAPI in " << (mode_ == ClientSettings::SharingMode::shared ? "shared" : "exclusive") << " mode\n";
|
||||
|
||||
_AUDCLNT_SHAREMODE share_mode = mode_ == ClientSettings::WasapiMode::SHARED ? AUDCLNT_SHAREMODE_SHARED : AUDCLNT_SHAREMODE_EXCLUSIVE;
|
||||
DWORD stream_flags = mode_ == ClientSettings::WasapiMode::SHARED
|
||||
_AUDCLNT_SHAREMODE share_mode = mode_ == ClientSettings::SharingMode::shared ? AUDCLNT_SHAREMODE_SHARED : AUDCLNT_SHAREMODE_EXCLUSIVE;
|
||||
DWORD stream_flags = mode_ == ClientSettings::SharingMode::shared
|
||||
? AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
|
||||
: AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
|
||||
|
||||
|
@ -339,7 +339,7 @@ void WASAPIPlayer::worker()
|
|||
clock->GetPosition(&position, NULL);
|
||||
|
||||
UINT32 padding = 0;
|
||||
if (mode_ == ClientSettings::WasapiMode::SHARED)
|
||||
if (mode_ == ClientSettings::SharingMode::shared)
|
||||
{
|
||||
hr = audioClient->GetCurrentPadding(&padding);
|
||||
CHECK_HR(hr);
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
class WASAPIPlayer : public Player
|
||||
{
|
||||
public:
|
||||
WASAPIPlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> stream, ClientSettings::WasapiMode mode);
|
||||
WASAPIPlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> stream, ClientSettings::SharingMode mode);
|
||||
virtual ~WASAPIPlayer();
|
||||
|
||||
static std::vector<PcmDevice> pcm_list(void);
|
||||
|
@ -103,7 +103,7 @@ protected:
|
|||
|
||||
private:
|
||||
AudioSessionEventListener* audioEventListener_;
|
||||
ClientSettings::WasapiMode mode_;
|
||||
ClientSettings::SharingMode mode_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -118,7 +118,7 @@ int main(int argc, char** argv)
|
|||
auto sample_format = op.add<Value<string>>("", "sampleformat", "resample audio stream to <rate>:<bits>:<channels>", "");
|
||||
#endif
|
||||
#ifdef HAS_WASAPI
|
||||
auto wasapi_mode = op.add<Value<string>>("", "wasapimode", "WASAPI mode to use [shared/exclusive]", "shared");
|
||||
auto sharing_mode = op.add<Value<string>>("", "sharingmode", "audio mode to use [shared/exclusive]", "shared");
|
||||
#endif
|
||||
|
||||
try
|
||||
|
@ -243,10 +243,10 @@ int main(int argc, char** argv)
|
|||
#endif
|
||||
|
||||
#ifdef HAS_WASAPI
|
||||
if (wasapi_mode->is_set())
|
||||
if (sharing_mode->is_set())
|
||||
{
|
||||
settings.player.wasapi_mode =
|
||||
(strcmp(wasapi_mode->value().c_str(), "exclusive") == 0) ? ClientSettings::WasapiMode::EXCLUSIVE : ClientSettings::WasapiMode::SHARED;
|
||||
settings.player.sharing_mode =
|
||||
(sharing_mode->value() == "exclusive") ? ClientSettings::SharingMode::exclusive : ClientSettings::SharingMode::shared;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue