Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
8e20684f
Commit
8e20684f
authored
Oct 01, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the missing function to allocate and get the object event OS pipe
parent
b2dc803b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
3 deletions
+47
-3
include/vlc_objects.h
include/vlc_objects.h
+2
-0
src/misc/objects.c
src/misc/objects.c
+45
-3
No files found.
include/vlc_objects.h
View file @
8e20684f
...
...
@@ -186,3 +186,5 @@ static inline void __vlc_object_signal( vlc_object_t *obj )
VLC_EXPORT
(
void
,
__vlc_object_kill
,
(
vlc_object_t
*
)
);
#define vlc_object_kill(a) \
__vlc_object_kill( VLC_OBJECT(a) )
int
vlc_object_waitpipe
(
vlc_object_t
*
obj
);
src/misc/objects.c
View file @
8e20684f
...
...
@@ -59,6 +59,12 @@
#include "vlc_meta.h"
#include "variables.h"
#ifndef WIN32
# include <unistd.h>
#else
# include <io.h>
# include <fcntl.h>
#endif
/*****************************************************************************
* Local prototypes
...
...
@@ -460,6 +466,43 @@ void __vlc_object_unlock( vlc_object_t *obj )
vlc_mutex_unlock
(
&
obj
->
object_lock
);
}
/**
* Returns the readable end of a pipe that becomes readable whenever
* an object is signaled. This can be used to wait for VLC object events
* inside select(), poll() loops or frameworks providing an event loop.
*
* Note that the pipe will remain the same for the lifetime of the object.
* DO NOT close it yourself. Ever.
*
* DO NOT try to read from the pipe either: call vlc_object_wait() instead.
* Assuming the pipe is readable, vlc_object_wait() will not block.
* Also note that, as with vlc_object_wait(), there may be spurious wakeups.
*
* @param obj object that would be signaled (object lock MUST hold)
* @return a readable pipe descriptor, or -1 on error.
*/
int
vlc_object_waitpipe
(
vlc_object_t
*
obj
)
{
int
*
pipes
=
obj
->
p_internals
->
pipes
;
vlc_assert_locked
(
&
obj
->
object_lock
);
if
(
pipes
[
1
]
==
-
1
)
{
/* This can only ever happen if someone killed us without locking */
assert
(
pipes
[
0
]
==
-
1
);
#ifndef WIN32
if
(
pipe
(
pipes
)
)
#else
if
(
_pipe
(
pipes
,
1
,
_O_BINARY
)
)
#endif
return
-
1
;
}
return
pipes
[
0
];
}
/**
* Waits for the object to be signaled (using vlc_object_signal()).
* If the object already has a signal pending, this function will return
...
...
@@ -528,17 +571,16 @@ void __vlc_object_signal_unlocked( vlc_object_t *obj )
void
__vlc_object_kill
(
vlc_object_t
*
p_this
)
{
vlc_mutex_lock
(
&
p_this
->
object_lock
);
p_this
->
b_die
=
VLC_TRUE
;
if
(
p_this
->
i_object_type
==
VLC_OBJECT_LIBVLC
)
for
(
int
i
=
0
;
i
<
p_this
->
i_children
;
i
++
)
vlc_object_kill
(
p_this
->
pp_children
[
i
]
);
p_this
->
b_die
=
VLC_TRUE
;
int
fd
=
p_this
->
p_internals
->
pipes
[
1
];
if
(
fd
!=
-
1
)
{
close
(
fd
);
close
(
fd
);
/* closing a pipe makes it readable too */
p_this
->
p_internals
->
pipes
[
1
]
=
-
1
;
}
...
...
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