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
2f994865
Commit
2f994865
authored
May 23, 2011
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added vlc_set_priority() helper.
parent
a47715a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
src/libvlc.h
src/libvlc.h
+2
-0
src/posix/thread.c
src/posix/thread.c
+24
-0
src/win32/thread.c
src/win32/thread.c
+9
-1
No files found.
src/libvlc.h
View file @
2f994865
...
...
@@ -62,6 +62,8 @@ int vlc_thread_set_priority( vlc_object_t *, int ) VLC_DEPRECATED;
void
vlc_thread_cancel
(
vlc_object_t
*
);
int
vlc_object_waitpipe
(
vlc_object_t
*
obj
);
int
vlc_set_priority
(
vlc_thread_t
,
int
);
void
vlc_threads_setup
(
libvlc_int_t
*
);
void
vlc_trace
(
const
char
*
fn
,
const
char
*
file
,
unsigned
line
);
...
...
src/posix/thread.c
View file @
2f994865
...
...
@@ -755,6 +755,30 @@ int vlc_clone_detach (vlc_thread_t *th, void *(*entry) (void *), void *data,
return
vlc_clone_attr
(
th
,
&
attr
,
entry
,
data
,
priority
);
}
int
vlc_set_priority
(
vlc_thread_t
th
,
int
priority
)
{
#if defined (_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING >= 0) \
&& defined (_POSIX_THREAD_PRIORITY_SCHEDULING) \
&& (_POSIX_THREAD_PRIORITY_SCHEDULING >= 0)
if
(
rt_priorities
)
{
struct
sched_param
sp
=
{
.
sched_priority
=
priority
+
rt_offset
,
};
int
policy
;
if
(
sp
.
sched_priority
<=
0
)
sp
.
sched_priority
+=
sched_get_priority_max
(
policy
=
SCHED_OTHER
);
else
sp
.
sched_priority
+=
sched_get_priority_min
(
policy
=
SCHED_RR
);
if
(
pthread_setschedparam
(
th
,
policy
,
&
sp
))
return
VLC_EGENERIC
;
}
#else
(
void
)
priority
;
#endif
return
VLC_SUCCESS
;
}
/**
* Marks a thread as cancelled. Next time the target thread reaches a
* cancellation point (while not having disabled cancellation), it will
...
...
src/win32/thread.c
View file @
2f994865
...
...
@@ -634,10 +634,11 @@ static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
if
(
p_handle
!=
NULL
)
*
p_handle
=
th
;
ResumeThread
(
hThread
);
if
(
priority
)
SetThreadPriority
(
hThread
,
priority
);
ResumeThread
(
hThread
);
return
0
;
}
...
...
@@ -673,6 +674,13 @@ int vlc_clone_detach (vlc_thread_t *p_handle, void *(*entry) (void *),
return
vlc_clone_attr
(
p_handle
,
true
,
entry
,
data
,
priority
);
}
int
vlc_set_priority
(
vlc_thread_t
th
,
int
priority
)
{
if
(
!
SetThreadPriority
(
th
->
id
,
priority
))
return
VLC_EGENERIC
;
return
VLC_SUCCESS
;
}
/*** Thread cancellation ***/
/* APC procedure for thread cancellation */
...
...
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