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
3ccd91d3
Commit
3ccd91d3
authored
Sep 26, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interrupt: voidify vlc_interrupt_prepare and simplify
parent
cc0d8ec8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
56 deletions
+22
-56
include/vlc_interrupt.h
include/vlc_interrupt.h
+3
-8
modules/stream_filter/prefetch.c
modules/stream_filter/prefetch.c
+2
-1
src/misc/interrupt.c
src/misc/interrupt.c
+17
-47
No files found.
include/vlc_interrupt.h
View file @
3ccd91d3
...
...
@@ -196,17 +196,12 @@ VLC_API bool vlc_killed(void) VLC_USED;
* it will be forwarded to the specified other context. This is used to cross
* thread boundaries.
*
* If the calling thread already has an interruption pending, this function
* dequeues the interrupt, return an error code and does not enable forwarding.
*
* If the calling thread has no interrupt context, this function does nothing
* and returns zero.
* If the calling thread has no interrupt context, this function does nothing.
*
* @param to context to forward to
* @return 0 on success, or EINTR on error
*/
VLC_API
int
vlc_interrupt_forward_start
(
vlc_interrupt_t
*
to
,
void
*
data
[
2
])
VLC_USED
;
VLC_API
void
vlc_interrupt_forward_start
(
vlc_interrupt_t
*
to
,
void
*
data
[
2
])
;
/**
* Undoes vlc_interrupt_forward_start().
...
...
modules/stream_filter/prefetch.c
View file @
3ccd91d3
...
...
@@ -323,12 +323,13 @@ static ssize_t Read(stream_t *stream, void *buf, size_t buflen)
{
void
*
data
[
2
];
if
(
sys
->
error
||
vlc_interrupt_forward_start
(
sys
->
interrupt
,
data
)
)
if
(
sys
->
error
)
{
vlc_mutex_unlock
(
&
sys
->
lock
);
return
-
1
;
}
vlc_interrupt_forward_start
(
sys
->
interrupt
,
data
);
vlc_cond_wait
(
&
sys
->
wait_data
,
&
sys
->
lock
);
vlc_interrupt_forward_stop
(
data
);
}
...
...
src/misc/interrupt.c
View file @
3ccd91d3
...
...
@@ -154,33 +154,23 @@ vlc_interrupt_t *vlc_interrupt_set(vlc_interrupt_t *newctx)
* Prepares to enter interruptible wait.
* @param cb callback to interrupt the wait (i.e. wake up the thread)
* @param data opaque data pointer for the callback
* @return 0 on success or EINTR if an interruption is already pending
* @note Any <b>succesful</b> call <b>must</b> be paired with a call to
* vlc_interrupt_finish().
*/
static
int
vlc_interrupt_prepare
(
vlc_interrupt_t
*
ctx
,
static
void
vlc_interrupt_prepare
(
vlc_interrupt_t
*
ctx
,
void
(
*
cb
)(
void
*
),
void
*
data
)
{
int
ret
=
0
;
assert
(
ctx
!=
NULL
);
assert
(
ctx
==
vlc_threadvar_get
(
vlc_interrupt_var
));
vlc_mutex_lock
(
&
ctx
->
lock
);
assert
(
ctx
->
callback
==
NULL
);
if
(
ctx
->
interrupted
)
{
ret
=
EINTR
;
ctx
->
interrupted
=
false
;
}
else
{
ret
=
0
;
ctx
->
callback
=
cb
;
ctx
->
data
=
data
;
}
if
(
unlikely
(
ctx
->
interrupted
))
cb
(
data
);
vlc_mutex_unlock
(
&
ctx
->
lock
);
return
ret
;
}
/**
...
...
@@ -244,12 +234,7 @@ int vlc_sem_wait_i11e(vlc_sem_t *sem)
if
(
ctx
==
NULL
)
return
vlc_sem_wait
(
sem
),
0
;
int
ret
=
vlc_interrupt_prepare
(
ctx
,
vlc_interrupt_sem
,
sem
);
if
(
ret
)
{
vlc_testcancel
();
return
ret
;
}
vlc_interrupt_prepare
(
ctx
,
vlc_interrupt_sem
,
sem
);
vlc_cleanup_push
(
vlc_interrupt_cleanup
,
ctx
);
vlc_sem_wait
(
sem
);
...
...
@@ -282,13 +267,7 @@ int vlc_mwait_i11e(mtime_t deadline)
vlc_cond_t
wait
;
vlc_cond_init
(
&
wait
);
int
ret
=
vlc_interrupt_prepare
(
ctx
,
vlc_mwait_i11e_wake
,
&
wait
);
if
(
ret
)
{
vlc_cond_destroy
(
&
wait
);
vlc_testcancel
();
return
ret
;
}
vlc_interrupt_prepare
(
ctx
,
vlc_mwait_i11e_wake
,
&
wait
);
vlc_mutex_lock
(
&
ctx
->
lock
);
vlc_cleanup_push
(
vlc_mwait_i11e_cleanup
,
ctx
);
...
...
@@ -297,7 +276,7 @@ int vlc_mwait_i11e(mtime_t deadline)
vlc_cleanup_pop
();
vlc_mutex_unlock
(
&
ctx
->
lock
);
ret
=
vlc_interrupt_finish
(
ctx
);
int
ret
=
vlc_interrupt_finish
(
ctx
);
vlc_cond_destroy
(
&
wait
);
return
ret
;
}
...
...
@@ -312,18 +291,18 @@ static void vlc_interrupt_forward_wake(void *opaque)
:
vlc_interrupt_raise
)(
to
);
}
int
vlc_interrupt_forward_start
(
vlc_interrupt_t
*
to
,
void
*
data
[
2
])
void
vlc_interrupt_forward_start
(
vlc_interrupt_t
*
to
,
void
*
data
[
2
])
{
data
[
0
]
=
data
[
1
]
=
NULL
;
vlc_interrupt_t
*
from
=
vlc_threadvar_get
(
vlc_interrupt_var
);
if
(
from
==
NULL
)
return
0
;
return
;
assert
(
from
!=
to
);
data
[
0
]
=
to
;
data
[
1
]
=
from
;
return
vlc_interrupt_prepare
(
from
,
vlc_interrupt_forward_wake
,
data
);
vlc_interrupt_prepare
(
from
,
vlc_interrupt_forward_wake
,
data
);
}
int
vlc_interrupt_forward_stop
(
void
*
const
data
[
2
])
...
...
@@ -392,12 +371,7 @@ static int vlc_poll_i11e_inner(struct pollfd *restrict fds, unsigned nfds,
ufd
[
nfds
].
fd
=
fd
[
0
];
ufd
[
nfds
].
events
=
POLLIN
;
if
(
vlc_interrupt_prepare
(
ctx
,
vlc_poll_i11e_wake
,
fd
))
{
vlc_testcancel
();
errno
=
EINTR
;
goto
out
;
}
vlc_interrupt_prepare
(
ctx
,
vlc_poll_i11e_wake
,
fd
);
vlc_cleanup_push
(
vlc_poll_i11e_cleanup
,
ctx
);
ret
=
poll
(
ufd
,
nfds
+
1
,
timeout
);
...
...
@@ -419,7 +393,7 @@ static int vlc_poll_i11e_inner(struct pollfd *restrict fds, unsigned nfds,
errno
=
EINTR
;
ret
=
-
1
;
}
out:
canc
=
vlc_savecancel
();
if
(
fd
[
1
]
!=
fd
[
0
])
close
(
fd
[
1
]);
...
...
@@ -642,11 +616,7 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
return
-
1
;
}
if
(
vlc_interrupt_prepare
(
ctx
,
vlc_poll_i11e_wake
,
th
))
{
errno
=
EINTR
;
goto
out
;
}
vlc_interrupt_prepare
(
ctx
,
vlc_poll_i11e_wake
,
th
);
vlc_cleanup_push
(
vlc_poll_i11e_cleanup
,
th
);
ret
=
vlc_poll
(
fds
,
nfds
,
timeout
);
...
...
@@ -657,7 +627,7 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
errno
=
EINTR
;
ret
=
-
1
;
}
out:
CloseHandle
(
th
);
return
ret
;
}
...
...
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