Music Hub  ..
A session-wide music playback service
hybris_recorder_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 <hybris/media/media_recorder_layer.h>
25 
26 namespace media = lomiri::MediaHubService;
27 
29 {
30  // The fringe that we hand over to hybris.
31  static void on_media_recording_state_changed(bool started, void* context)
32  {
33  if (auto thiz = static_cast<HybrisRecorderObserver*>(context))
34  {
35  thiz->setRecordingState(started ? media::RecordingState::started : media::RecordingState::stopped);
36  }
37  }
38 
39  // TODO: We have no way of freeing the observer and thus leak
40  // an instance here.
41  MediaRecorderObserver* observer
42  {
43  android_media_recorder_observer_new()
44  };
45 };
46 
48  RecorderObserverPrivate(q),
49  d{new Private{}}
50 {
51  android_media_recorder_observer_set_cb(
52  d->observer,
54  this);
55 }
56 
58 {
59  // We first reset the context of the callback.
60  android_media_recorder_observer_set_cb(
61  d->observer,
63  nullptr);
64 }
lomiri::MediaHubService::RecordingState::stopped
@ stopped
hybris_recorder_observer.h
media::HybrisRecorderObserver::Private::observer
MediaRecorderObserver * observer
Definition: hybris_recorder_observer.cpp:42
lomiri::MediaHubService::HybrisRecorderObserver::HybrisRecorderObserver
HybrisRecorderObserver(RecorderObserver *q)
media::HybrisRecorderObserver::Private
Definition: hybris_recorder_observer.cpp:28
lomiri::MediaHubService
Definition: context.h:28
lomiri::MediaHubService::HybrisRecorderObserver::~HybrisRecorderObserver
~HybrisRecorderObserver()
media::HybrisRecorderObserver::Private::on_media_recording_state_changed
static void on_media_recording_state_changed(bool started, void *context)
Definition: hybris_recorder_observer.cpp:31