Music Hub ..
A session-wide music playback service
 
Loading...
Searching...
No Matches
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
23
24#include "logging.h"
25
26#include <hybris/media/media_codec_layer.h>
27
28#include <QPair>
29#include <QPointer>
30
32
33namespace
34{
35typedef QPair<media::Player::Client, QPointer<media::HybrisClientDeathObserver>> Holder;
36}
37
38void 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
55media::HybrisClientDeathObserver::HybrisClientDeathObserver(ClientDeathObserver *q):
57{
58}
59
60media::HybrisClientDeathObserver::~HybrisClientDeathObserver()
61{
62}
63
64void 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}