Do not use optionals when they are not needed
This commit is contained in:
parent
26b7482263
commit
6e8abd75e8
4 changed files with 6 additions and 7 deletions
|
@ -26,7 +26,7 @@ MprisControlPlugin::MprisControlPlugin(QObject *parent, const QVariantList &args
|
|||
: KdeConnectPlugin(parent, args)
|
||||
, sessionManager(GlobalSystemMediaTransportControlsSessionManager::RequestAsync().get())
|
||||
{
|
||||
sessionManager->SessionsChanged([this](GlobalSystemMediaTransportControlsSessionManager, SessionsChangedEventArgs) {
|
||||
sessionManager.SessionsChanged([this](GlobalSystemMediaTransportControlsSessionManager, SessionsChangedEventArgs) {
|
||||
this->updatePlayerList();
|
||||
});
|
||||
this->updatePlayerList();
|
||||
|
@ -158,7 +158,7 @@ void MprisControlPlugin::updatePlayerList()
|
|||
mediaPropertiesChangedHandlers.clear();
|
||||
timelinePropertiesChangedHandlers.clear();
|
||||
|
||||
auto sessions = sessionManager->GetSessions();
|
||||
auto sessions = sessionManager.GetSessions();
|
||||
playbackInfoChangedHandlers.resize(sessions.Size());
|
||||
mediaPropertiesChangedHandlers.resize(sessions.Size());
|
||||
timelinePropertiesChangedHandlers.resize(sessions.Size());
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
bool receivePacket(const NetworkPacket &np) override;
|
||||
|
||||
private:
|
||||
std::optional<GlobalSystemMediaTransportControlsSessionManager> sessionManager;
|
||||
GlobalSystemMediaTransportControlsSessionManager sessionManager;
|
||||
QHash<QString, GlobalSystemMediaTransportControlsSession> playerList;
|
||||
|
||||
std::vector<GlobalSystemMediaTransportControlsSession::PlaybackInfoChanged_revoker> playbackInfoChangedHandlers;
|
||||
|
|
|
@ -16,6 +16,7 @@ K_PLUGIN_CLASS_WITH_JSON(PauseMusicPlugin, "kdeconnect_pausemusic.json")
|
|||
|
||||
PauseMusicPlugin::PauseMusicPlugin(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPlugin(parent, args)
|
||||
, sessionManager(GlobalSystemMediaTransportControlsSessionManager::RequestAsync().get())
|
||||
{
|
||||
CoInitialize(nullptr);
|
||||
deviceEnumerator = nullptr;
|
||||
|
@ -25,8 +26,6 @@ PauseMusicPlugin::PauseMusicPlugin(QObject *parent, const QVariantList &args)
|
|||
qWarning("Initialization failed: Failed to create MMDeviceEnumerator");
|
||||
qWarning("Error Code: %lx", hr);
|
||||
}
|
||||
|
||||
sessionManager = GlobalSystemMediaTransportControlsSessionManager::RequestAsync().get();
|
||||
}
|
||||
|
||||
bool PauseMusicPlugin::updateSinksList()
|
||||
|
@ -86,7 +85,7 @@ bool PauseMusicPlugin::updateSinksList()
|
|||
void PauseMusicPlugin::updatePlayersList()
|
||||
{
|
||||
playersList.clear();
|
||||
auto sessions = sessionManager->GetSessions();
|
||||
auto sessions = sessionManager.GetSessions();
|
||||
for (uint32_t i = 0; i < sessions.Size(); i++) {
|
||||
const auto player = sessions.GetAt(i);
|
||||
auto playerName = player.SourceAppUserModelId();
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
IMMDeviceEnumerator *deviceEnumerator;
|
||||
QHash<QString, IAudioEndpointVolume *> sinksList;
|
||||
|
||||
std::optional<GlobalSystemMediaTransportControlsSessionManager> sessionManager;
|
||||
GlobalSystemMediaTransportControlsSessionManager sessionManager;
|
||||
QHash<QString, GlobalSystemMediaTransportControlsSession> playersList;
|
||||
|
||||
QSet<QString> pausedSources;
|
||||
|
|
Loading…
Reference in a new issue