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
a57b503d
Commit
a57b503d
authored
Oct 12, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
module_list_cap(): sorts modules for a certain capability
parent
5c843e8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
2 deletions
+53
-2
src/modules/bank.c
src/modules/bank.c
+51
-2
src/modules/modules.h
src/modules/modules.h
+2
-0
No files found.
src/modules/bank.c
View file @
a57b503d
...
...
@@ -216,8 +216,6 @@ void module_list_free (module_t **list)
*/
module_t
**
module_list_get
(
size_t
*
n
)
{
/* TODO: this whole module lookup is quite inefficient */
/* Remove this and improve module_need */
module_t
**
tab
=
NULL
;
size_t
i
=
0
;
...
...
@@ -243,6 +241,57 @@ module_t **module_list_get (size_t *n)
return
tab
;
}
static
int
modulecmp
(
const
void
*
a
,
const
void
*
b
)
{
const
module_t
*
const
*
ma
=
a
,
*
const
*
mb
=
b
;
/* Note that qsort() uses _ascending_ order,
* so the smallest module is the one with the biggest score. */
return
(
*
mb
)
->
i_score
-
(
*
ma
)
->
i_score
;
}
/**
* Builds a sorted list of all VLC modules with a given capability.
* The list is sorted from the highest module score to the lowest.
* @param list pointer to the table of modules [OUT]
* @param cap capability of modules to look for
* @return the number of matching found, or -1 on error (*list is then NULL).
* @note *list must be freed with module_list_free().
*/
ssize_t
module_list_cap
(
module_t
***
restrict
list
,
const
char
*
cap
)
{
/* TODO: This is quite inefficient. List should be sorted by capability. */
ssize_t
n
=
0
;
assert
(
list
!=
NULL
);
for
(
module_t
*
mod
=
modules
.
head
;
mod
!=
NULL
;
mod
=
mod
->
next
)
{
if
(
module_provides
(
mod
,
cap
))
n
++
;
for
(
module_t
*
subm
=
mod
->
submodule
;
subm
!=
NULL
;
subm
=
subm
->
next
)
if
(
module_provides
(
subm
,
cap
))
n
++
;
}
module_t
**
tab
=
malloc
(
sizeof
(
*
tab
)
*
n
);
*
list
=
tab
;
if
(
unlikely
(
tab
==
NULL
))
return
-
1
;
for
(
module_t
*
mod
=
modules
.
head
;
mod
!=
NULL
;
mod
=
mod
->
next
)
{
if
(
module_provides
(
mod
,
cap
))
*
(
tab
++
)
=
mod
;
for
(
module_t
*
subm
=
mod
->
submodule
;
subm
!=
NULL
;
subm
=
subm
->
next
)
if
(
module_provides
(
subm
,
cap
))
*
(
tab
++
)
=
subm
;
}
assert
(
tab
==
*
list
+
n
);
qsort
(
*
list
,
n
,
sizeof
(
*
tab
),
modulecmp
);
return
n
;
}
#ifdef HAVE_DYNAMIC_PLUGINS
typedef
enum
{
CACHE_USE
,
CACHE_RESET
,
CACHE_IGNORE
}
cache_mode_t
;
...
...
src/modules/modules.h
View file @
a57b503d
...
...
@@ -110,6 +110,8 @@ size_t module_LoadPlugins( vlc_object_t * );
void
module_EndBank
(
bool
);
int
module_Map
(
vlc_object_t
*
,
module_t
*
);
ssize_t
module_list_cap
(
module_t
***
,
const
char
*
);
int
vlc_bindtextdomain
(
const
char
*
);
/* Low-level OS-dependent handler */
...
...
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