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
0b79f865
Commit
0b79f865
authored
May 20, 2015
by
Thomas Guillem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: add input_item_node_Sort
Sort all p_item children of the node recursively.
parent
feb2e065
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
include/vlc_input_item.h
include/vlc_input_item.h
+9
-0
src/input/item.c
src/input/item.c
+46
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
No files found.
include/vlc_input_item.h
View file @
0b79f865
...
...
@@ -113,12 +113,15 @@ enum input_item_type_e
ITEM_TYPE_NUMBER
};
typedef
int
(
*
input_item_compar_cb
)(
input_item_t
*
,
input_item_t
*
);
struct
input_item_node_t
{
input_item_t
*
p_item
;
int
i_children
;
input_item_node_t
**
pp_children
;
input_item_node_t
*
p_parent
;
input_item_compar_cb
compar_cb
;
};
VLC_API
void
input_item_CopyOptions
(
input_item_t
*
p_parent
,
input_item_t
*
p_child
);
...
...
@@ -153,6 +156,12 @@ VLC_API input_item_node_t * input_item_node_AppendItem( input_item_node_t *p_nod
*/
VLC_API
void
input_item_node_AppendNode
(
input_item_node_t
*
p_parent
,
input_item_node_t
*
p_child
);
/**
* Sort all p_item children of the node recursively.
*/
VLC_API
void
input_item_node_Sort
(
input_item_node_t
*
p_node
,
input_item_compar_cb
compar_cb
);
/**
* Delete a node created with input_item_node_Create() and all its children.
*/
...
...
src/input/item.c
View file @
0b79f865
...
...
@@ -1160,6 +1160,52 @@ void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t
p_child
->
p_parent
=
p_parent
;
}
static
int
compar_node
(
const
void
*
p1
,
const
void
*
p2
)
{
input_item_node_t
*
p_node1
=
*
((
input_item_node_t
**
)
p1
);
input_item_node_t
*
p_node2
=
*
((
input_item_node_t
**
)
p2
);
assert
(
p_node1
->
p_parent
&&
p_node1
->
p_parent
==
p_node2
->
p_parent
&&
p_node1
->
p_parent
->
compar_cb
);
input_item_compar_cb
compar_cb
=
p_node1
->
p_parent
->
compar_cb
;
return
compar_cb
(
p_node1
->
p_item
,
p_node2
->
p_item
);
}
static
void
sort_subitems
(
input_item_node_t
*
p_node
,
input_item_compar_cb
compar_cb
)
{
if
(
p_node
->
i_children
<
0
||
!
compar_cb
)
return
;
p_node
->
compar_cb
=
compar_cb
;
/* Lock first all children. This avoids to lock/unlock them from each
* compar callback call */
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
)
vlc_mutex_lock
(
&
p_node
->
pp_children
[
i
]
->
p_item
->
lock
);
/* Sort current node */
qsort
(
p_node
->
pp_children
,
p_node
->
i_children
,
sizeof
(
input_item_node_t
*
),
compar_node
);
/* Unlock all children */
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
)
vlc_mutex_unlock
(
&
p_node
->
pp_children
[
i
]
->
p_item
->
lock
);
p_node
->
compar_cb
=
NULL
;
/* Sort all children */
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
)
sort_subitems
(
p_node
->
pp_children
[
i
],
compar_cb
);
}
void
input_item_node_Sort
(
input_item_node_t
*
p_node
,
input_item_compar_cb
compar_cb
)
{
sort_subitems
(
p_node
,
compar_cb
);
}
void
input_item_node_PostAndDelete
(
input_item_node_t
*
p_root
)
{
post_subitems
(
p_root
);
...
...
src/libvlccore.sym
View file @
0b79f865
...
...
@@ -208,6 +208,7 @@ input_item_node_AppendNode
input_item_node_Create
input_item_node_Delete
input_item_node_PostAndDelete
input_item_node_Sort
input_item_PostSubItem
input_item_ReplaceInfos
input_item_SetDuration
...
...
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