Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Martin Finkel
LibVLCSharp
Commits
8c15518c
Commit
8c15518c
authored
Mar 29, 2018
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move marshalling func to util class
parent
4e07fc09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
24 deletions
+32
-24
LibVLCSharp/Instance.cs
LibVLCSharp/Instance.cs
+4
-24
LibVLCSharp/MarshalUtils.cs
LibVLCSharp/MarshalUtils.cs
+28
-0
No files found.
LibVLCSharp/Instance.cs
View file @
8c15518c
...
...
@@ -496,7 +496,7 @@ namespace VideoLAN.LibVLC
{
get
{
return
Retrieve
(()
=>
Native
.
LibVLCAudioFilterListGet
(
NativeReference
),
return
MarshalUtils
.
Retrieve
(()
=>
Native
.
LibVLCAudioFilterListGet
(
NativeReference
),
Marshal
.
PtrToStructure
<
ModuleDescription
.
Internal
>,
intern
=>
ModuleDescription
.
__CreateInstance
(
intern
),
module
=>
module
.
Next
,
Native
.
LibVLCModuleDescriptionListRelease
);
...
...
@@ -516,7 +516,7 @@ namespace VideoLAN.LibVLC
{
get
{
return
Retrieve
(()
=>
Native
.
LibVLCVideoFilterListGet
(
NativeReference
),
return
MarshalUtils
.
Retrieve
(()
=>
Native
.
LibVLCVideoFilterListGet
(
NativeReference
),
Marshal
.
PtrToStructure
<
ModuleDescription
.
Internal
>,
intern
=>
ModuleDescription
.
__CreateInstance
(
intern
),
module
=>
module
.
Next
,
Native
.
LibVLCModuleDescriptionListRelease
);
...
...
@@ -534,7 +534,7 @@ namespace VideoLAN.LibVLC
{
get
{
return
Retrieve
(()
=>
Native
.
LibVLCAudioOutputListGet
(
NativeReference
),
return
MarshalUtils
.
Retrieve
(()
=>
Native
.
LibVLCAudioOutputListGet
(
NativeReference
),
Marshal
.
PtrToStructure
<
AudioOutputDescription
.
Internal
>,
intern
=>
AudioOutputDescription
.
__CreateInstance
(
intern
),
module
=>
module
.
Next
,
Native
.
LibVLCAudioOutputListRelease
);
...
...
@@ -565,7 +565,7 @@ namespace VideoLAN.LibVLC
public
AudioOutputDevice
[]
AudioOutputDevices
(
string
audioOutputName
)
{
return
Retrieve
(()
=>
Native
.
LibVLCAudioOutputDeviceListGet
(
NativeReference
,
audioOutputName
),
return
MarshalUtils
.
Retrieve
(()
=>
Native
.
LibVLCAudioOutputDeviceListGet
(
NativeReference
,
audioOutputName
),
Marshal
.
PtrToStructure
<
AudioOutputDevice
.
Internal
>,
s
=>
AudioOutputDevice
.
__CreateInstance
(
s
),
device
=>
device
.
Next
,
Native
.
LibVLCAudioOutputDeviceListRelease
);
...
...
@@ -659,26 +659,6 @@ namespace VideoLAN.LibVLC
public
bool
DialogHandlersSet
=>
_dialogCbsPtr
!=
IntPtr
.
Zero
;
static
TU
[]
Retrieve
<
T
,
TU
>(
Func
<
IntPtr
>
getRef
,
Func
<
IntPtr
,
T
>
retrieve
,
Func
<
T
,
TU
>
create
,
Func
<
TU
,
TU
>
next
,
Action
<
IntPtr
>
releaseRef
)
{
var
nativeRef
=
getRef
();
if
(
nativeRef
==
IntPtr
.
Zero
)
return
Array
.
Empty
<
TU
>();
var
structure
=
retrieve
(
nativeRef
);
var
obj
=
create
(
structure
);
var
resultList
=
new
List
<
TU
>();
while
(
obj
!=
null
)
{
resultList
.
Add
(
obj
);
obj
=
next
(
obj
);
}
releaseRef
(
nativeRef
);
return
resultList
.
ToArray
();
}
/// <summary>
/// Code taken from Vlc.DotNet
/// </summary>
...
...
LibVLCSharp/MarshalUtils.cs
0 → 100644
View file @
8c15518c
using
System
;
using
System.Collections.Generic
;
namespace
VideoLAN.LibVLC
{
public
static
class
MarshalUtils
{
public
static
TU
[]
Retrieve
<
T
,
TU
>(
Func
<
IntPtr
>
getRef
,
Func
<
IntPtr
,
T
>
retrieve
,
Func
<
T
,
TU
>
create
,
Func
<
TU
,
TU
>
next
,
Action
<
IntPtr
>
releaseRef
)
{
var
nativeRef
=
getRef
();
if
(
nativeRef
==
IntPtr
.
Zero
)
return
Array
.
Empty
<
TU
>();
var
structure
=
retrieve
(
nativeRef
);
var
obj
=
create
(
structure
);
var
resultList
=
new
List
<
TU
>();
while
(
obj
!=
null
)
{
resultList
.
Add
(
obj
);
obj
=
next
(
obj
);
}
releaseRef
(
nativeRef
);
return
resultList
.
ToArray
();
}
}
}
\ No newline at end of file
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