Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
6c2286c2
Commit
6c2286c2
authored
Feb 03, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove some exceptions in media_list
parent
67875950
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
91 deletions
+80
-91
include/vlc/libvlc_media_list.h
include/vlc/libvlc_media_list.h
+15
-19
src/control/media.c
src/control/media.c
+1
-1
src/control/media_discoverer.c
src/control/media_discoverer.c
+2
-2
src/control/media_list.c
src/control/media_list.c
+30
-35
src/control/media_list_internal.h
src/control/media_list_internal.h
+2
-3
src/control/media_list_path.h
src/control/media_list_path.h
+3
-3
test/libvlc/media_list.c
test/libvlc/media_list.c
+27
-28
No files found.
include/vlc/libvlc_media_list.h
View file @
6c2286c2
...
...
@@ -103,12 +103,10 @@ VLC_PUBLIC_API libvlc_media_t *
*
* \param p_ml a media list instance
* \param p_mi a media instance
* \
param p_e initialized exception object
* \
return 0 on success, -1 if the media list is read-only
*/
VLC_PUBLIC_API
void
libvlc_media_list_add_media
(
libvlc_media_list_t
*
,
libvlc_media_t
*
,
libvlc_exception_t
*
);
VLC_PUBLIC_API
int
libvlc_media_list_add_media
(
libvlc_media_list_t
*
,
libvlc_media_t
*
);
/**
* Insert media instance in media list on a position
...
...
@@ -117,24 +115,22 @@ VLC_PUBLIC_API void
* \param p_ml a media list instance
* \param p_mi a media instance
* \param i_pos position in array where to insert
* \
param p_e initialized exception object
* \
return 0 on success, -1 if the media list si read-only
*/
VLC_PUBLIC_API
void
libvlc_media_list_insert_media
(
libvlc_media_list_t
*
,
libvlc_media_t
*
,
int
,
libvlc_exception_t
*
);
VLC_PUBLIC_API
int
libvlc_media_list_insert_media
(
libvlc_media_list_t
*
,
libvlc_media_t
*
,
int
);
/**
* Remove media instance from media list on a position
* The libvlc_media_list_lock should be held upon entering this function.
*
* \param p_ml a media list instance
* \param i_pos position in array where to insert
* \
param p_e initialized exception object
* \
return 0 on success, -1 if the list is read-only or the item was not found
*/
VLC_PUBLIC_API
void
libvlc_media_list_remove_index
(
libvlc_media_list_t
*
,
int
,
libvlc_exception_t
*
);
VLC_PUBLIC_API
int
libvlc_media_list_remove_index
(
libvlc_media_list_t
*
,
int
);
/**
* Get count on media list items
...
...
@@ -152,12 +148,12 @@ VLC_PUBLIC_API int
*
* \param p_ml a media list instance
* \param i_pos position in array where to insert
* \param p_e initialized exception object
* \return media instance at position i_pos and libvlc_media_retain() has been called to increase the refcount on this object.
* \return media instance at position i_pos, or NULL if not found.
* In case of success, libvlc_media_retain() is called to increase the refcount
* on the media.
*/
VLC_PUBLIC_API
libvlc_media_t
*
libvlc_media_list_item_at_index
(
libvlc_media_list_t
*
,
int
,
libvlc_exception_t
*
);
libvlc_media_list_item_at_index
(
libvlc_media_list_t
*
,
int
);
/**
* Find index position of List media instance in media list.
* Warning: the function will return the first matched position.
...
...
src/control/media.c
View file @
6c2286c2
...
...
@@ -106,7 +106,7 @@ static void input_item_subitem_added( const vlc_event_t *p_event,
}
if
(
p_md
->
p_subitems
)
{
libvlc_media_list_add_media
(
p_md
->
p_subitems
,
p_md_child
,
NULL
);
libvlc_media_list_add_media
(
p_md
->
p_subitems
,
p_md_child
);
}
/* Construct the event */
...
...
src/control/media_discoverer.c
View file @
6c2286c2
...
...
@@ -118,10 +118,10 @@ static void services_discovery_item_removed( const vlc_event_t * p_event,
libvlc_media_list_lock
(
p_mdis
->
p_mlist
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
p_md
=
libvlc_media_list_item_at_index
(
p_mdis
->
p_mlist
,
i
,
NULL
);
p_md
=
libvlc_media_list_item_at_index
(
p_mdis
->
p_mlist
,
i
);
if
(
p_md
->
p_input_item
==
p_item
)
{
_libvlc_media_list_remove_index
(
p_mdis
->
p_mlist
,
i
,
NULL
);
_libvlc_media_list_remove_index
(
p_mdis
->
p_mlist
,
i
);
break
;
}
}
...
...
src/control/media_list.c
View file @
6c2286c2
...
...
@@ -124,21 +124,17 @@ notify_item_deletion( libvlc_media_list_t * p_mlist,
/**************************************************************************
* static mlist_is_writable (private)
*
* Raise exception and return 0 when the media_list instance is read-only,
* or else return 1.
**************************************************************************/
static
inline
int
mlist_is_writable
(
libvlc_media_list_t
*
p_mlist
,
libvlc_exception_t
*
p_e
)
bool
mlist_is_writable
(
libvlc_media_list_t
*
p_mlist
)
{
if
(
!
p_mlist
||
p_mlist
->
b_read_only
)
{
/* We are read-only from user side */
libvlc_exception_raise
(
p_e
);
libvlc_printerr
(
"Attempt to write a read-only media list"
);
return
0
;
return
false
;
}
return
1
;
return
true
;
}
/*
...
...
@@ -273,9 +269,11 @@ libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist,
return
;
}
libvlc_media_list_add_media
(
p_mlist
,
p_md
,
p_e
);
if
(
libvlc_exception_raised
(
p_e
)
)
if
(
libvlc_media_list_add_media
(
p_mlist
,
p_md
)
)
{
libvlc_exception_raise
(
p_e
);
return
;
}
input_Read
(
p_mlist
->
p_libvlc_instance
->
p_libvlc_int
,
p_input_item
);
...
...
@@ -334,13 +332,13 @@ int libvlc_media_list_count( libvlc_media_list_t * p_mlist )
*
* Lock should be held when entering.
**************************************************************************/
void
libvlc_media_list_add_media
(
libvlc_media_list_t
*
p_mlist
,
libvlc_media_t
*
p_md
,
libvlc_exception_t
*
p_e
)
int
libvlc_media_list_add_media
(
libvlc_media_list_t
*
p_mlist
,
libvlc_media_t
*
p_md
)
{
if
(
mlist_is_writable
(
p_mlist
,
p_e
)
)
_libvlc_media_list_add_media
(
p_mlist
,
p_md
);
if
(
!
mlist_is_writable
(
p_mlist
)
)
return
-
1
;
_libvlc_media_list_add_media
(
p_mlist
,
p_md
);
return
0
;
}
/* LibVLC internal version */
...
...
@@ -361,14 +359,14 @@ void _libvlc_media_list_add_media( libvlc_media_list_t * p_mlist,
*
* Lock should be hold when entering.
**************************************************************************/
void
libvlc_media_list_insert_media
(
libvlc_media_list_t
*
p_mlist
,
libvlc_media_t
*
p_md
,
int
index
,
libvlc_exception_t
*
p_e
)
int
libvlc_media_list_insert_media
(
libvlc_media_list_t
*
p_mlist
,
libvlc_media_t
*
p_md
,
int
index
)
{
if
(
mlist_is_writable
(
p_mlist
,
p_e
)
)
_libvlc_media_list_insert_media
(
p_mlist
,
p_md
,
index
);
if
(
!
mlist_is_writable
(
p_mlist
)
)
return
-
1
;
_libvlc_media_list_insert_media
(
p_mlist
,
p_md
,
index
);
return
0
;
}
/* LibVLC internal version */
...
...
@@ -389,26 +387,24 @@ void _libvlc_media_list_insert_media(
*
* Lock should be held when entering.
**************************************************************************/
void
libvlc_media_list_remove_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
,
libvlc_exception_t
*
p_e
)
int
libvlc_media_list_remove_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
)
{
if
(
mlist_is_writable
(
p_mlist
,
p_e
)
)
_libvlc_media_list_remove_index
(
p_mlist
,
index
,
p_e
);
if
(
!
mlist_is_writable
(
p_mlist
)
)
return
-
1
;
return
_libvlc_media_list_remove_index
(
p_mlist
,
index
);
}
/* LibVLC internal version */
void
_libvlc_media_list_remove_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
,
libvlc_exception_t
*
p_e
)
int
_libvlc_media_list_remove_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
)
{
libvlc_media_t
*
p_md
;
if
(
index
<
0
||
index
>=
vlc_array_count
(
&
p_mlist
->
items
))
{
libvlc_exception_raise
(
p_e
);
libvlc_printerr
(
"Index out of bounds"
);
return
;
return
-
1
;
}
p_md
=
vlc_array_item_at_index
(
&
p_mlist
->
items
,
index
);
...
...
@@ -418,6 +414,7 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
notify_item_deletion
(
p_mlist
,
p_md
,
index
,
EventDidHappen
);
libvlc_media_release
(
p_md
);
return
0
;
}
/**************************************************************************
...
...
@@ -427,14 +424,12 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
**************************************************************************/
libvlc_media_t
*
libvlc_media_list_item_at_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
,
libvlc_exception_t
*
p_e
)
int
index
)
{
libvlc_media_t
*
p_md
;
if
(
index
<
0
||
index
>=
vlc_array_count
(
&
p_mlist
->
items
))
{
libvlc_exception_raise
(
p_e
);
libvlc_printerr
(
"Index out of bounds"
);
return
NULL
;
}
...
...
src/control/media_list_internal.h
View file @
6c2286c2
...
...
@@ -64,8 +64,7 @@ void _libvlc_media_list_insert_media(
libvlc_media_list_t
*
p_mlist
,
libvlc_media_t
*
p_md
,
int
index
);
void
_libvlc_media_list_remove_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
,
libvlc_exception_t
*
p_e
);
int
_libvlc_media_list_remove_index
(
libvlc_media_list_t
*
p_mlist
,
int
index
);
#endif
src/control/media_list_path.h
View file @
6c2286c2
...
...
@@ -122,7 +122,7 @@ get_path_rec( const libvlc_media_list_path_t path, libvlc_media_list_t * p_curre
count
=
libvlc_media_list_count
(
p_current_mlist
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
libvlc_media_t
*
p_md
=
libvlc_media_list_item_at_index
(
p_current_mlist
,
i
,
NULL
);
libvlc_media_t
*
p_md
=
libvlc_media_list_item_at_index
(
p_current_mlist
,
i
);
if
(
p_md
==
p_searched_md
)
return
libvlc_media_list_path_copy_by_appending
(
path
,
i
);
/* Found! */
...
...
@@ -167,7 +167,7 @@ libvlc_media_list_item_at_path( libvlc_media_list_t * p_mlist, const libvlc_medi
int
i
;
for
(
i
=
0
;
path
[
i
]
!=
-
1
;
i
++
)
{
p_md
=
libvlc_media_list_item_at_index
(
p_current_mlist
,
path
[
i
]
,
NULL
);
p_md
=
libvlc_media_list_item_at_index
(
p_current_mlist
,
path
[
i
]
);
if
(
p_current_mlist
!=
p_mlist
)
libvlc_media_list_release
(
p_current_mlist
);
...
...
@@ -209,7 +209,7 @@ libvlc_media_list_parentlist_at_path( libvlc_media_list_t * p_mlist, const libvl
return
p_current_mlist
;
}
p_md
=
libvlc_media_list_item_at_index
(
p_current_mlist
,
path
[
i
]
,
NULL
);
p_md
=
libvlc_media_list_item_at_index
(
p_current_mlist
,
path
[
i
]
);
p_current_mlist
=
libvlc_media_subitems
(
p_md
);
libvlc_media_release
(
p_md
);
...
...
test/libvlc/media_list.c
View file @
6c2286c2
...
...
@@ -28,6 +28,7 @@ static void test_media_list (const char ** argv, int argc)
libvlc_instance_t
*
vlc
;
libvlc_media_t
*
md1
,
*
md2
,
*
md3
,
*
md4
;
libvlc_media_list_t
*
ml
;
int
ret
;
log
(
"Testing media_list
\n
"
);
...
...
@@ -45,30 +46,30 @@ static void test_media_list (const char ** argv, int argc)
md3
=
libvlc_media_new
(
vlc
,
"/dev/null"
);
assert
(
md3
!=
NULL
);
libvlc_media_list_add_media
(
ml
,
md1
,
&
ex
);
catch
(
);
libvlc_media_list_add_media
(
ml
,
md2
,
&
ex
);
catch
(
);
ret
=
libvlc_media_list_add_media
(
ml
,
md1
);
assert
(
!
ret
);
ret
=
libvlc_media_list_add_media
(
ml
,
md2
);
assert
(
!
ret
);
assert
(
libvlc_media_list_count
(
ml
)
==
2
);
assert
(
libvlc_media_list_index_of_item
(
ml
,
md1
)
==
0
);
assert
(
libvlc_media_list_index_of_item
(
ml
,
md2
)
==
1
);
libvlc_media_list_remove_index
(
ml
,
0
,
&
ex
);
/* removing first item */
catch
(
);
ret
=
libvlc_media_list_remove_index
(
ml
,
0
);
/* removing first item */
assert
(
!
ret
);
/* test if second item was moved on first place */
assert
(
libvlc_media_list_index_of_item
(
ml
,
md2
)
==
0
);
libvlc_media_list_add_media
(
ml
,
md1
,
&
ex
);
/* add 2 items */
catch
(
);
libvlc_media_list_add_media
(
ml
,
md1
,
&
ex
);
catch
(
);
ret
=
libvlc_media_list_add_media
(
ml
,
md1
);
/* add 2 items */
assert
(
!
ret
);
ret
=
libvlc_media_list_add_media
(
ml
,
md1
);
assert
(
!
ret
);
/* there should be 3 pieces */
assert
(
libvlc_media_list_count
(
ml
)
==
3
);
libvlc_media_list_insert_media
(
ml
,
md3
,
2
,
&
ex
);
catch
(
);
ret
=
libvlc_media_list_insert_media
(
ml
,
md3
,
2
);
assert
(
!
ret
);
/* there should be 4 pieces */
assert
(
libvlc_media_list_count
(
ml
)
==
4
);
...
...
@@ -77,33 +78,31 @@ static void test_media_list (const char ** argv, int argc)
assert
(
libvlc_media_list_index_of_item
(
ml
,
md3
)
==
2
);
/* test right returning descriptor*/
assert
(
libvlc_media_list_item_at_index
(
ml
,
0
,
&
ex
)
==
md2
);
catch
();
assert
(
libvlc_media_list_item_at_index
(
ml
,
0
)
==
md2
);
assert
(
libvlc_media_list_item_at_index
(
ml
,
2
,
&
ex
)
==
md3
);
catch
();
assert
(
libvlc_media_list_item_at_index
(
ml
,
2
)
==
md3
);
/* test if give exceptions, when it should */
/* have 4 items, so index 4 should give exception */
libvlc_media_list_remove_index
(
ml
,
4
,
&
ex
);
assert
(
have_exception
()
);
ret
=
libvlc_media_list_remove_index
(
ml
,
4
);
assert
(
ret
==
-
1
);
libvlc_media_list_remove_index
(
ml
,
100
,
&
ex
);
assert
(
have_exception
()
);
ret
=
libvlc_media_list_remove_index
(
ml
,
100
);
assert
(
ret
==
-
1
);
libvlc_media_list_remove_index
(
ml
,
-
1
,
&
ex
);
assert
(
have_exception
()
);
ret
=
libvlc_media_list_remove_index
(
ml
,
-
1
);
assert
(
ret
==
-
1
);
/* getting non valid items */
libvlc_media_t
*
p_non_exist
=
libvlc_media_list_item_at_index
(
ml
,
4
,
&
ex
);
assert
(
have_exception
()
);
libvlc_media_list_item_at_index
(
ml
,
4
);
assert
(
p_non_exist
==
NULL
);
p_non_exist
=
libvlc_media_list_item_at_index
(
ml
,
100
,
&
ex
);
assert
(
have_exception
()
);
p_non_exist
=
libvlc_media_list_item_at_index
(
ml
,
100
);
assert
(
p_non_exist
==
NULL
);
p_non_exist
=
libvlc_media_list_item_at_index
(
ml
,
-
1
,
&
ex
);
assert
(
have_exception
()
);
p_non_exist
=
libvlc_media_list_item_at_index
(
ml
,
-
1
);
assert
(
p_non_exist
==
NULL
);
md4
=
libvlc_media_new
(
vlc
,
"/dev/null"
);
assert
(
md4
!=
NULL
);
...
...
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