From 3caee8cc0369674d3a60576ef7dee619ae6046e7 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 2 Dec 2018 19:22:48 +0000 Subject: wasapi: added exclusive mode support (#903) git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8481 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Output/wasapi/outputwasapi.cpp | 6 +++-- src/plugins/Output/wasapi/outputwasapi.h | 1 + src/plugins/Output/wasapi/settingsdialog.cpp | 4 +++- src/plugins/Output/wasapi/settingsdialog.ui | 34 ++++++++++++++++++++-------- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/plugins/Output/wasapi/outputwasapi.cpp b/src/plugins/Output/wasapi/outputwasapi.cpp index 88abf2780..eaa09cb54 100644 --- a/src/plugins/Output/wasapi/outputwasapi.cpp +++ b/src/plugins/Output/wasapi/outputwasapi.cpp @@ -64,6 +64,7 @@ OutputWASAPI::OutputWASAPI() : Output() instance = this; QSettings settings(Qmmp::configFile(), QSettings::IniFormat); m_id = settings.value("WASAPI/device", "default").toString(); + m_exclusive = settings.value("WASAPI/exclusive_mode", false).toBool(); } OutputWASAPI::~OutputWASAPI() @@ -162,15 +163,16 @@ bool OutputWASAPI::initialize(quint32 freq, ChannelMap map, Qmmp::AudioFormat fo wfex.dwChannelMask = mask; wfex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + AUDCLNT_SHAREMODE mode = m_exclusive ? AUDCLNT_SHAREMODE_EXCLUSIVE : AUDCLNT_SHAREMODE_SHARED; DWORD streamFlags = 0; //enable channel matrixer and a sample rate converter if format is unsupported - if(m_pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, (WAVEFORMATEX *)&wfex, 0) != S_OK) + if(m_pAudioClient->IsFormatSupported(mode, (WAVEFORMATEX *)&wfex, 0) != S_OK) { streamFlags |= AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM; qDebug("OutputWASAPI: format is not supported, using converter"); } - if((result = m_pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, streamFlags, WASAPI_BUFSIZE, 0, (WAVEFORMATEX *)&wfex, NULL)) != S_OK) + if((result = m_pAudioClient->Initialize(mode, streamFlags, WASAPI_BUFSIZE, 0, (WAVEFORMATEX *)&wfex, NULL)) != S_OK) { qWarning("OutputWASAPI: IAudioClient::Initialize failed, error code = 0x%lx", result); return false; diff --git a/src/plugins/Output/wasapi/outputwasapi.h b/src/plugins/Output/wasapi/outputwasapi.h index eddf93526..ffe07669f 100644 --- a/src/plugins/Output/wasapi/outputwasapi.h +++ b/src/plugins/Output/wasapi/outputwasapi.h @@ -69,6 +69,7 @@ private: UINT32 m_bufferFrames; int m_frameSize; QString m_id; + bool m_exclusive; typedef struct { diff --git a/src/plugins/Output/wasapi/settingsdialog.cpp b/src/plugins/Output/wasapi/settingsdialog.cpp index 35ef8ec1d..12bb0f592 100644 --- a/src/plugins/Output/wasapi/settingsdialog.cpp +++ b/src/plugins/Output/wasapi/settingsdialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Ilya Kotov * + * Copyright (C) 2017-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -39,6 +39,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QSettings settings(Qmmp::configFile(), QSettings::IniFormat); QString id = settings.value("WASAPI/device", "default").toString(); int index = m_ui.deviceComboBox->findData(id); + m_ui.exclusiveModeCheckBox->setChecked(settings.value("WASAPI/exclusive_mode", false).toBool()); m_ui.deviceComboBox->setCurrentIndex(qMax(index, 0)); } @@ -47,6 +48,7 @@ void SettingsDialog::accept() QSettings settings(Qmmp::configFile(), QSettings::IniFormat); int index = m_ui.deviceComboBox->currentIndex(); settings.setValue("WASAPI/device", m_ui.deviceComboBox->itemData(index).toString()); + settings.setValue("WASAPI/exclusive_mode", m_ui.exclusiveModeCheckBox->isChecked()); QDialog::accept(); } diff --git a/src/plugins/Output/wasapi/settingsdialog.ui b/src/plugins/Output/wasapi/settingsdialog.ui index cfe9840c9..edb1e6276 100644 --- a/src/plugins/Output/wasapi/settingsdialog.ui +++ b/src/plugins/Output/wasapi/settingsdialog.ui @@ -7,19 +7,35 @@ 0 0 276 - 68 + 90 WASAPI Plugin Settings - + + 9 + + + 9 + + + 9 + + 9 6 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + @@ -33,13 +49,6 @@ - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -53,6 +62,13 @@ + + + + Exclusive mode + + + -- cgit v1.2.3-13-gbd6f