Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
f90f3bc8
Commit
f90f3bc8
authored
Aug 24, 2012
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx/AppleRemote: optimize cookie handling to be faster and less memory intense
parent
0d00930a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
47 deletions
+37
-47
modules/gui/macosx/AppleRemote.h
modules/gui/macosx/AppleRemote.h
+4
-3
modules/gui/macosx/AppleRemote.m
modules/gui/macosx/AppleRemote.m
+33
-44
No files found.
modules/gui/macosx/AppleRemote.h
View file @
f90f3bc8
...
...
@@ -89,8 +89,8 @@ The class is not thread safe
@interface
AppleRemote
:
NSObject
{
IOHIDDeviceInterface
**
hidDeviceInterface
;
IOHIDQueueInterface
**
queue
;
NS
MutableArray
*
allCookies
;
NS
MutableDictionary
*
cookieToButtonMapping
;
NS
Array
*
_
allCookies
;
NS
Dictionary
*
_
cookieToButtonMapping
;
CFRunLoopSourceRef
eventSource
;
BOOL
_openInExclusiveMode
;
...
...
@@ -168,8 +168,9 @@ The class is not thread safe
@end
@interface
AppleRemote
(
PrivateMethods
)
@property
(
readonly
)
NSDictionary
*
cookieToButtonMapping
;
-
(
void
)
setRemoteId
:
(
int
)
aValue
;
-
(
NSDictionary
*
)
cookieToButtonMapping
;
-
(
IOHIDQueueInterface
**
)
queue
;
-
(
IOHIDDeviceInterface
**
)
hidDeviceInterface
;
-
(
void
)
handleEventWithCookieString
:
(
NSString
*
)
cookieString
sumOfValues
:
(
SInt32
)
sumOfValues
;
...
...
modules/gui/macosx/AppleRemote.m
View file @
f90f3bc8
...
...
@@ -84,45 +84,33 @@ static AppleRemote *_o_sharedInstance = nil;
_openInExclusiveMode
=
YES
;
queue
=
NULL
;
hidDeviceInterface
=
NULL
;
cookieToButtonMapping
=
[[
NSMutableDictionary
alloc
]
init
];
NSMutableDictionary
*
mutableCookieToButtonMapping
=
[[
NSMutableDictionary
alloc
]
init
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonVolume_Plus
]
forKey
:
@"33_31_30_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonVolume_Minus
]
forKey
:
@"33_32_30_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonMenu
]
forKey
:
@"33_22_21_20_2_33_22_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonPlay
]
forKey
:
@"33_23_21_20_2_33_23_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonRight
]
forKey
:
@"33_24_21_20_2_33_24_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonLeft
]
forKey
:
@"33_25_21_20_2_33_25_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonRight_Hold
]
forKey
:
@"33_21_20_14_12_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonLeft_Hold
]
forKey
:
@"33_21_20_13_12_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonMenu_Hold
]
forKey
:
@"33_21_20_2_33_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonPlay_Sleep
]
forKey
:
@"37_33_21_20_2_37_33_21_20_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
k2009RemoteButtonPlay
]
forKey
:
@"33_21_20_8_2_33_21_20_8_2_"
];
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
k2009RemoteButtonFullscreen
]
forKey
:
@"33_21_20_3_2_33_21_20_3_2_"
];
if
(
OSX_LION
)
{
/* Lion cookies */
msg_Dbg
(
VLCIntf
,
"using future AR cookies"
);
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonVolume_Plus
]
forKey
:
@"33_31_30_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonVolume_Minus
]
forKey
:
@"33_32_30_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonMenu
]
forKey
:
@"33_22_21_20_2_33_22_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonPlay
]
forKey
:
@"33_23_21_20_2_33_23_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonRight
]
forKey
:
@"33_24_21_20_2_33_24_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonLeft
]
forKey
:
@"33_25_21_20_2_33_25_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonRight_Hold
]
forKey
:
@"33_21_20_14_12_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonLeft_Hold
]
forKey
:
@"33_21_20_13_12_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonMenu_Hold
]
forKey
:
@"33_21_20_2_33_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonPlay_Sleep
]
forKey
:
@"37_33_21_20_2_37_33_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteControl_Switched
]
forKey
:
@"42_33_23_21_20_2_33_23_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
k2009RemoteButtonPlay
]
forKey
:
@"33_21_20_8_2_33_21_20_8_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
k2009RemoteButtonFullscreen
]
forKey
:
@"33_21_20_3_2_33_21_20_3_2_"
];
}
else
{
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteControl_Switched
]
forKey
:
@"42_33_23_21_20_2_33_23_21_20_2_"
];
else
/* 10.6.2+ Snow Leopard cookies */
msg_Dbg
(
VLCIntf
,
"using Snow Leopard AR cookies"
);
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonVolume_Plus
]
forKey
:
@"33_31_30_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonVolume_Minus
]
forKey
:
@"33_32_30_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonMenu
]
forKey
:
@"33_22_21_20_2_33_22_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonPlay
]
forKey
:
@"33_23_21_20_2_33_23_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonRight
]
forKey
:
@"33_24_21_20_2_33_24_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonLeft
]
forKey
:
@"33_25_21_20_2_33_25_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonRight_Hold
]
forKey
:
@"33_21_20_14_12_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonLeft_Hold
]
forKey
:
@"33_21_20_13_12_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonMenu_Hold
]
forKey
:
@"33_21_20_2_33_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteButtonPlay_Sleep
]
forKey
:
@"37_33_21_20_2_37_33_21_20_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteControl_Switched
]
forKey
:
@"19_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
k2009RemoteButtonPlay
]
forKey
:
@"33_21_20_8_2_33_21_20_8_2_"
];
[
cookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
k2009RemoteButtonFullscreen
]
forKey
:
@"33_21_20_3_2_33_21_20_3_2_"
];
}
[
mutableCookieToButtonMapping
setObject
:[
NSNumber
numberWithInt
:
kRemoteControl_Switched
]
forKey
:
@"19_"
];
_cookieToButtonMapping
=
[[
NSDictionary
alloc
]
initWithDictionary
:
mutableCookieToButtonMapping
];
[
mutableCookieToButtonMapping
release
];
/* defaults */
[
self
setSimulatesPlusMinusHold
:
YES
]
;
_simulatePlusMinusHold
=
YES
;
_maxClickTimeDifference
=
DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE
;
}
...
...
@@ -131,7 +119,7 @@ static AppleRemote *_o_sharedInstance = nil;
-
(
void
)
dealloc
{
[
self
stopListening
:
self
];
[
cookieToButtonMapping
release
];
[
_
cookieToButtonMapping
release
];
[
super
dealloc
];
}
...
...
@@ -150,7 +138,7 @@ static AppleRemote *_o_sharedInstance = nil;
}
-
(
BOOL
)
listeningToRemote
{
return
(
hidDeviceInterface
!=
NULL
&&
allCookies
!=
NULL
&&
queue
!=
NULL
);
return
(
hidDeviceInterface
!=
NULL
&&
_
allCookies
!=
NULL
&&
queue
!=
NULL
);
}
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
{
...
...
@@ -249,9 +237,9 @@ cleanup:
queue
=
NULL
;
}
if
(
allCookies
!=
nil
)
{
[
allCookies
autorelease
];
allCookies
=
nil
;
if
(
_
allCookies
!=
nil
)
{
[
_
allCookies
autorelease
];
_
allCookies
=
nil
;
}
if
(
hidDeviceInterface
!=
NULL
)
{
...
...
@@ -319,9 +307,8 @@ static AppleRemote* sharedInstance=nil;
return
hidDeviceInterface
;
}
-
(
NSDictionary
*
)
cookieToButtonMapping
{
return
cookieToButtonMapping
;
return
_
cookieToButtonMapping
;
}
-
(
NSString
*
)
validCookieSubstring
:
(
NSString
*
)
cookieString
{
...
...
@@ -576,7 +563,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS, sizeof(IOHIDElementCookie));
memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS);
*/
a
llCookies
=
[[
NSMutableArray
alloc
]
init
];
NSMutableArray
*
mutableA
llCookies
=
[[
NSMutableArray
alloc
]
init
];
NSUInteger
elementCount
=
[
elements
count
];
for
(
NSUInteger
i
=
0
;
i
<
elementCount
;
i
++
)
{
element
=
[
elements
objectAtIndex
:
i
];
...
...
@@ -597,8 +584,10 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
if
(
object
==
nil
||
!
[
object
isKindOfClass
:[
NSNumber
class
]])
continue
;
usagePage
=
[
object
longValue
];
[
a
llCookies
addObject
:
[
NSNumber
numberWithInt
:(
int
)
cookie
]];
[
mutableA
llCookies
addObject
:
[
NSNumber
numberWithInt
:(
int
)
cookie
]];
}
_allCookies
=
[[
NSArray
alloc
]
initWithArray
:
mutableAllCookies
];
[
mutableAllCookies
release
];
}
else
{
return
NO
;
}
...
...
@@ -618,9 +607,9 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
if
(
queue
)
{
result
=
(
*
queue
)
->
create
(
queue
,
0
,
12
);
//depth: maximum number of elements in queue before oldest elements in queue begin to be lost.
NSUInteger
cookieCount
=
[
allCookies
count
];
NSUInteger
cookieCount
=
[
_
allCookies
count
];
for
(
NSUInteger
i
=
0
;
i
<
cookieCount
;
i
++
)
{
IOHIDElementCookie
cookie
=
(
IOHIDElementCookie
)[[
allCookies
objectAtIndex
:
i
]
intValue
];
IOHIDElementCookie
cookie
=
(
IOHIDElementCookie
)[[
_
allCookies
objectAtIndex
:
i
]
intValue
];
(
*
queue
)
->
addElement
(
queue
,
cookie
,
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment