FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jack2/common/JackMidiAsyncWaitQueue.cpp at develop · jackaudio/jack2 · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
jackaudio
/
jack2
Public
Notifications
You must be signed in to change notification settings
Fork
396
Star
2.4k
Code
Issues
332
Pull requests
38
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
jack2
/
common
/
JackMidiAsyncWaitQueue.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (70 loc) · 2.84 KB
Breadcrumbs
jack2
/
common
/
JackMidiAsyncWaitQueue.cpp
Copy path
File metadata and controls
85 lines (70 loc) · 2.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
Copyright (C) 2010 Devin Anderson
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#
include
<
new
>
#
include
"
JackMidiAsyncWaitQueue.h
"
#
include
"
JackMidiUtil.h
"
#
include
"
JackTime.h
"
using
Jack::JackMidiAsyncWaitQueue;
JackMidiAsyncWaitQueue::JackMidiAsyncWaitQueue
(
size_t
max_bytes,
size_t
max_messages):
JackMidiAsyncQueue(max_bytes, max_messages)
{
if
(semaphore.
Allocate
(
"
JackMidiAsyncWaitQueue
"
,
"
midi-thread
"
,
0
)) {
throw
std::bad_alloc
();
}
}
JackMidiAsyncWaitQueue::~JackMidiAsyncWaitQueue
()
{
semaphore.
Destroy
();
}
jack_midi_event_t
*
JackMidiAsyncWaitQueue::DequeueEvent
()
{
return
DequeueEvent
((
long
)
0
);
}
jack_midi_event_t
*
JackMidiAsyncWaitQueue::DequeueEvent
(
jack_nframes_t
frame)
{
//
XXX: I worry about timer resolution on Solaris and Windows. When the
//
resolution for the `JackSynchro` object is milliseconds, the worst-case
//
scenario for processor objects is that the wait time becomes less than a
//
millisecond, and the processor object continually calls this method,
//
expecting to wait a certain amount of microseconds, and ends up not
//
waiting at all each time, essentially busy-waiting until the current
//
frame is reached. Perhaps there should be a #define that indicates the
//
wait time resolution for `JackSynchro` objects so that we can wait a
//
little longer if necessary.
jack_time_t
frame_time =
GetTimeFromFrames
(frame);
jack_time_t
current_time =
GetMicroSeconds
();
return
DequeueEvent
((frame_time < current_time) ?
0
:
(
long
) (frame_time - current_time));
}
jack_midi_event_t
*
JackMidiAsyncWaitQueue::DequeueEvent
(
long
usec)
{
return
((usec <
0
) ? semaphore.
Wait
() : semaphore.
TimedWait
(usec)) ?
JackMidiAsyncQueue::DequeueEvent
() :
0
;
}
Jack::JackMidiWriteQueue::EnqueueResult
JackMidiAsyncWaitQueue::EnqueueEvent
(
jack_nframes_t
time,
size_t
size,
jack_midi_data_t
*buffer)
{
EnqueueResult result =
JackMidiAsyncQueue::EnqueueEvent
(time, size,
buffer);
if
(result ==
OK
) {
semaphore.
Signal
();
}
return
result;
}
Back
|
FazBrowse Home
|
New Git URL