Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
376ecc67
Commit
376ecc67
authored
Feb 02, 2010
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist: refactor a bit and fix a crash
parent
2531d514
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
40 deletions
+52
-40
src/playlist/item.c
src/playlist/item.c
+51
-39
src/playlist/playlist_internal.h
src/playlist/playlist_internal.h
+1
-1
No files found.
src/playlist/item.c
View file @
376ecc67
...
@@ -38,6 +38,11 @@ static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item );
...
@@ -38,6 +38,11 @@ static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item );
static
playlist_item_t
*
ItemToNode
(
playlist_t
*
,
playlist_item_t
*
,
bool
);
static
playlist_item_t
*
ItemToNode
(
playlist_t
*
,
playlist_item_t
*
,
bool
);
static
int
RecursiveAddIntoParent
(
playlist_t
*
p_playlist
,
playlist_item_t
*
p_parent
,
input_item_node_t
*
p_node
,
int
i_pos
,
bool
b_flat
,
playlist_item_t
**
pp_first_leaf
);
/*****************************************************************************
/*****************************************************************************
* An input item has gained subitems (Event Callback)
* An input item has gained subitems (Event Callback)
*****************************************************************************/
*****************************************************************************/
...
@@ -95,6 +100,7 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
...
@@ -95,6 +100,7 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
p_item
=
playlist_InsertInputItemTree
(
p_playlist
,
p_item
,
p_item
=
playlist_InsertInputItemTree
(
p_playlist
,
p_item
,
p_new_root
,
0
,
false
);
p_new_root
,
0
,
false
);
if
(
b_stop
)
if
(
b_stop
)
{
{
PL_UNLOCK
;
PL_UNLOCK
;
...
@@ -456,49 +462,12 @@ playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
...
@@ -456,49 +462,12 @@ playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
* \param b_flat TRUE if the new tree contents should be flattened into a list
* \param b_flat TRUE if the new tree contents should be flattened into a list
* \return the first new leaf inserted (in playing order)
* \return the first new leaf inserted (in playing order)
*/
*/
playlist_item_t
*
playlist_InsertInputItemTree
(
playlist_item_t
*
playlist_InsertInputItemTree
(
playlist_t
*
p_playlist
,
playlist_item_t
*
p_parent
,
playlist_t
*
p_playlist
,
playlist_item_t
*
p_parent
,
input_item_node_t
*
p_node
,
int
i_pos
,
bool
b_flat
)
input_item_node_t
*
p_node
,
int
i_pos
,
bool
b_flat
)
{
{
playlist_item_t
*
p_first_leaf
=
NULL
;
playlist_item_t
*
p_first_leaf
=
NULL
;
RecursiveAddIntoParent
(
p_playlist
,
p_parent
,
p_node
,
i_pos
,
b_flat
,
&
p_first_leaf
);
if
(
p_parent
->
i_children
==
-
1
)
ChangeToNode
(
p_playlist
,
p_parent
);
if
(
i_pos
==
PLAYLIST_END
)
i_pos
=
p_parent
->
i_children
;
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
,
i_pos
++
)
{
playlist_item_t
*
p_child
=
NULL
;
if
(
b_flat
?
p_node
->
pp_children
[
i
]
->
i_children
==
0
:
1
)
{
printf
(
"creating a leaf: %i
\n
"
,
i_pos
);
p_child
=
playlist_NodeAddInput
(
p_playlist
,
p_node
->
pp_children
[
i
]
->
p_item
,
p_parent
,
PLAYLIST_INSERT
,
i_pos
,
pl_Locked
);
printf
(
"leaf done
\n
"
);
}
if
(
p_node
->
pp_children
[
i
]
->
i_children
>
0
)
{
if
(
b_flat
)
{
printf
(
"flat -> subnode into parent
\n
"
);
p_child
=
playlist_InsertInputItemTree
(
p_playlist
,
p_parent
,
p_node
->
pp_children
[
i
],
i_pos
,
true
);
i_pos
+=
p_node
->
i_children
-
1
;
/* i_pos += 1 on loop */
}
else
{
printf
(
"tree -> subnode on its own
\n
"
);
p_child
=
playlist_InsertInputItemTree
(
p_playlist
,
p_child
,
p_node
->
pp_children
[
i
],
0
,
false
);
}
}
if
(
i
==
0
)
p_first_leaf
=
p_child
;
}
printf
(
"leaving a node
\n
"
);
return
p_first_leaf
;
return
p_first_leaf
;
}
}
...
@@ -843,3 +812,46 @@ int playlist_DeleteItem( playlist_t * p_playlist, playlist_item_t *p_item,
...
@@ -843,3 +812,46 @@ int playlist_DeleteItem( playlist_t * p_playlist, playlist_item_t *p_item,
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
RecursiveAddIntoParent
(
playlist_t
*
p_playlist
,
playlist_item_t
*
p_parent
,
input_item_node_t
*
p_node
,
int
i_pos
,
bool
b_flat
,
playlist_item_t
**
pp_first_leaf
)
{
if
(
p_parent
->
i_children
==
-
1
)
ChangeToNode
(
p_playlist
,
p_parent
);
if
(
i_pos
==
PLAYLIST_END
)
i_pos
=
p_parent
->
i_children
;
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
)
{
playlist_item_t
*
p_child
=
NULL
;
if
(
b_flat
?
p_node
->
pp_children
[
i
]
->
i_children
==
0
:
1
)
{
p_child
=
playlist_NodeAddInput
(
p_playlist
,
p_node
->
pp_children
[
i
]
->
p_item
,
p_parent
,
PLAYLIST_INSERT
,
i_pos
,
pl_Locked
);
i_pos
++
;
}
if
(
p_node
->
pp_children
[
i
]
->
i_children
>
0
)
{
if
(
b_flat
)
{
i_pos
=
RecursiveAddIntoParent
(
p_playlist
,
p_parent
,
p_node
->
pp_children
[
i
],
i_pos
,
true
,
&
p_child
);
}
else
{
RecursiveAddIntoParent
(
p_playlist
,
p_child
,
p_node
->
pp_children
[
i
],
0
,
false
,
&
p_child
);
}
}
assert
(
p_child
!=
NULL
);
if
(
i
==
0
)
*
pp_first_leaf
=
p_child
;
}
return
i_pos
;
}
src/playlist/playlist_internal.h
View file @
376ecc67
...
@@ -131,7 +131,7 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
...
@@ -131,7 +131,7 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
playlist_item_t
*
playlist_NodeAddInput
(
playlist_t
*
,
input_item_t
*
,
playlist_item_t
*
playlist_NodeAddInput
(
playlist_t
*
,
input_item_t
*
,
playlist_item_t
*
,
int
,
int
,
bool
);
playlist_item_t
*
,
int
,
int
,
bool
);
playlist_item_t
*
playlist_InsertInputItemTree
(
playlist_t
*
,
playlist_item_t
*
playlist_InsertInputItemTree
(
playlist_t
*
,
playlist_item_t
*
,
input_item_node_t
*
,
int
,
bool
);
playlist_item_t
*
,
input_item_node_t
*
,
int
,
bool
);
/* Tree walking */
/* Tree walking */
...
...
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