Music Hub
..
A session-wide music playback service
hybris_client_death_observer.cpp
Go to the documentation of this file.
1
/*
2
* Copyright © 2014 Canonical Ltd.
3
* Copyright © 2022 UBports Foundation.
4
*
5
* Contact: Alberto Mardegan <mardy@users.sourceforge.net>
6
*
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License version 3,
9
* as published by the Free Software Foundation.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* Authored by: Thomas Voß <thomas.voss@canonical.com>
20
*/
21
22
#include "
hybris_client_death_observer.h
"
23
24
#include "
logging.h
"
25
26
#include <hybris/media/media_codec_layer.h>
27
28
#include <QPair>
29
#include <QPointer>
30
31
namespace
media
=
lomiri::MediaHubService
;
32
33
namespace
34
{
35
typedef
QPair<media::Player::Client, QPointer<media::HybrisClientDeathObserver>> Holder;
36
}
37
38
void
media::HybrisClientDeathObserver::on_client_died_cb
(
void
* context)
39
{
40
auto
holder =
static_cast<
Holder*
>
(context);
41
42
if
(not holder)
43
return
;
44
45
// We check if we are still alive or if we already got killed.
46
if
(
auto
sp = holder->second.data())
47
{
48
sp->notifyClientDeath(holder->first);
49
}
50
51
// And with that, we have reached end of life for our holder object.
52
delete
holder;
53
}
54
55
media::HybrisClientDeathObserver::HybrisClientDeathObserver
(
ClientDeathObserver
*q):
56
ClientDeathObserverPrivate
(q)
57
{
58
}
59
60
media::HybrisClientDeathObserver::~HybrisClientDeathObserver
()
61
{
62
}
63
64
void
media::HybrisClientDeathObserver::registerForDeathNotifications
(
const
media::Player::Client &client)
65
{
66
decoding_service_set_client_death_cb(
67
&
media::HybrisClientDeathObserver::on_client_died_cb
,
68
client.key,
new
Holder{client, this});
69
}
hybris_client_death_observer.h
lomiri::MediaHubService::ClientDeathObserver
Definition:
client_death_observer.h:39
lomiri::MediaHubService::HybrisClientDeathObserver::~HybrisClientDeathObserver
~HybrisClientDeathObserver()
Definition:
hybris_client_death_observer.cpp:60
lomiri::MediaHubService::ClientDeathObserverPrivate
Definition:
client_death_observer_p.h:27
lomiri::MediaHubService
Definition:
context.h:28
lomiri::MediaHubService::HybrisClientDeathObserver::HybrisClientDeathObserver
HybrisClientDeathObserver(ClientDeathObserver *q)
Definition:
hybris_client_death_observer.cpp:55
lomiri::MediaHubService::HybrisClientDeathObserver::registerForDeathNotifications
void registerForDeathNotifications(const Player::Client &) override
Definition:
hybris_client_death_observer.cpp:64
lomiri::MediaHubService::HybrisClientDeathObserver::on_client_died_cb
static void on_client_died_cb(void *context)
Definition:
hybris_client_death_observer.cpp:38
logging.h
src
service
hybris_client_death_observer.cpp
Generated on Fri Dec 16 2022 11:18:10 for Music Hub by
1.8.17