2 * Copyright (C) 2010-2021 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "PipewireProxy.h"
11 #include "PipewireRegistry.h"
12 #include "ServiceBroker.h"
13 #include "cores/AudioEngine/Interfaces/AE.h"
14 #include "utils/log.h"
19 using namespace PIPEWIRE
;
21 CPipewireProxy::CPipewireProxy(CPipewireRegistry
& registry
,
25 : m_registry(registry
), m_proxyEvents(CreateProxyEvents())
28 reinterpret_cast<pw_proxy
*>(pw_registry_bind(registry
.Get(), id
, type
, version
, 0)));
31 CLog::Log(LOGERROR
, "CPipewireProxy: failed to create proxy: {}", strerror(errno
));
32 throw std::runtime_error("CPipewireProxy: failed to create proxy");
35 pw_proxy_add_listener(m_proxy
.get(), &m_proxyListener
, &m_proxyEvents
, this);
38 CPipewireProxy::~CPipewireProxy()
40 spa_hook_remove(&m_proxyListener
);
43 void CPipewireProxy::Bound(void* userdata
, uint32_t id
)
45 CLog::Log(LOGDEBUG
, "CPipewireProxy::{} - id={}", __FUNCTION__
, id
);
47 auto AE
= CServiceBroker::GetActiveAE();
49 AE
->DeviceCountChange("PIPEWIRE");
52 void CPipewireProxy::Removed(void* userdata
)
54 CLog::Log(LOGDEBUG
, "CPipewireProxy::{}", __FUNCTION__
);
56 auto AE
= CServiceBroker::GetActiveAE();
58 AE
->DeviceCountChange("PIPEWIRE");
61 pw_proxy_events
CPipewireProxy::CreateProxyEvents()
63 pw_proxy_events proxyEvents
= {};
64 proxyEvents
.version
= PW_VERSION_PROXY_EVENTS
;
65 proxyEvents
.bound
= Bound
;
66 proxyEvents
.removed
= Removed
;