Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqnxmediaeventthread.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 QNX Software Systems. All rights reserved.
2
// Copyright (C) 2021 The Qt Company
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5
#
include
"qqnxmediaeventthread_p.h"
6
7
#
include
<
QtCore
/
QDebug
>
8
9
#
include
<
errno
.
h
>
10
#
include
<
mm
/
renderer
/
types
.
h
>
11
#
include
<
sys
/
neutrino
.
h
>
12
13
extern
"C"
{
14
// ### Include mm/renderer/events.h once we have it
15
int
mmr_event_arm
(
mmr_context_t
*ctxt,
16
struct
sigevent
const
*sev);
17
}
18
19
QT_BEGIN_NAMESPACE
20
21
static
const
int
c_mmrCode
= _PULSE_CODE_MINAVAIL + 0;
22
static
const
int
c_readCode
= _PULSE_CODE_MINAVAIL + 1;
23
static
const
int
c_quitCode
= _PULSE_CODE_MINAVAIL + 2;
24
25
QQnxMediaEventThread
::QQnxMediaEventThread(
mmr_context_t
*context)
26
: QThread(),
27
m_mmrContext(context)
28
{
29
if
(Q_UNLIKELY((m_channelId = ChannelCreate(_NTO_CHF_DISCONNECT
30
| _NTO_CHF_UNBLOCK
31
| _NTO_CHF_PRIVATE)) == -1)) {
32
qFatal(
"QQnxMediaEventThread: Can't continue without a channel"
);
33
}
34
35
if
(Q_UNLIKELY((m_connectionId = ConnectAttach(0, 0, m_channelId,
36
_NTO_SIDE_CHANNEL, 0)) == -1)) {
37
ChannelDestroy(m_channelId);
38
qFatal(
"QQnxMediaEventThread: Can't continue without a channel connection"
);
39
}
40
41
SIGEV_PULSE_INIT(&m_mmrEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_mmrCode, 0);
42
}
43
44
QQnxMediaEventThread
::~
QQnxMediaEventThread
()
45
{
46
// block until thread terminates
47
shutdown();
48
49
ConnectDetach(m_connectionId);
50
ChannelDestroy(m_channelId);
51
}
52
53
void
QQnxMediaEventThread
::
run
()
54
{
55
int
armResult = mmr_event_arm(m_mmrContext, &m_mmrEvent);
56
if
(armResult > 0)
57
Q_EMIT eventPending();
58
59
while
(1) {
60
struct
_pulse msg;
61
memset(&msg, 0,
sizeof
(msg));
62
int
receiveId = MsgReceive(m_channelId, &msg,
sizeof
(msg),
nullptr
);
63
if
(receiveId == 0) {
64
if
(msg.code == c_mmrCode) {
65
Q_EMIT eventPending();
66
}
else
if
(msg.code ==
c_readCode
) {
67
armResult = mmr_event_arm(m_mmrContext, &m_mmrEvent);
68
if
(armResult > 0)
69
Q_EMIT eventPending();
70
}
else
if
(msg.code ==
c_quitCode
) {
71
break
;
72
}
else
{
73
qWarning() << Q_FUNC_INFO <<
"Unexpected pulse"
<< msg.code;
74
}
75
}
else
if
(receiveId > 0) {
76
qWarning() << Q_FUNC_INFO <<
"Unexpected message"
<< msg.code;
77
}
else
{
78
qWarning() << Q_FUNC_INFO <<
"MsgReceive error"
<< strerror(errno);
79
}
80
}
81
}
82
83
void
QQnxMediaEventThread
::
signalRead
()
84
{
85
MsgSendPulse(m_connectionId, SIGEV_PULSE_PRIO_INHERIT,
c_readCode
, 0);
86
}
87
88
void
QQnxMediaEventThread
::shutdown()
89
{
90
MsgSendPulse(m_connectionId, SIGEV_PULSE_PRIO_INHERIT,
c_quitCode
, 0);
91
92
// block until thread terminates
93
wait();
94
}
95
96
QT_END_NAMESPACE
97
98
#
include
"moc_qqnxmediaeventthread_p.cpp"
QQnxMediaEventThread
Definition
qqnxmediaeventthread_p.h:29
QQnxMediaEventThread::run
void run() override
Definition
qqnxmediaeventthread.cpp:53
QQnxMediaEventThread::signalRead
void signalRead()
Definition
qqnxmediaeventthread.cpp:83
QQnxMediaEventThread::~QQnxMediaEventThread
~QQnxMediaEventThread() override
Definition
qqnxmediaeventthread.cpp:44
c_quitCode
static const int c_quitCode
Definition
qqnxmediaeventthread.cpp:23
c_readCode
static const int c_readCode
Definition
qqnxmediaeventthread.cpp:22
mmr_event_arm
int mmr_event_arm(mmr_context_t *ctxt, struct sigevent const *sev)
c_mmrCode
static QT_BEGIN_NAMESPACE const int c_mmrCode
Definition
qqnxmediaeventthread.cpp:21
mmr_context_t
typedefQT_BEGIN_NAMESPACE struct mmr_context mmr_context_t
Definition
qqnxmediaeventthread_p.h:26
qtmultimedia
src
plugins
multimedia
qnx
common
qqnxmediaeventthread.cpp
Generated on
for Qt by
1.18.0