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
0859ce7f
Commit
0859ce7f
authored
Mar 11, 2013
by
Martin Storsjö
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
omxil: Factorize event queue handling to a separate struct
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
9cc68b95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
39 deletions
+54
-39
modules/codec/omxil/omxil.c
modules/codec/omxil/omxil.c
+10
-13
modules/codec/omxil/omxil.h
modules/codec/omxil/omxil.h
+1
-5
modules/codec/omxil/omxil_utils.h
modules/codec/omxil/omxil_utils.h
+14
-3
modules/codec/omxil/utils.c
modules/codec/omxil/utils.c
+29
-18
No files found.
modules/codec/omxil/omxil.c
View file @
0859ce7f
...
...
@@ -501,7 +501,7 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec,
CHECK_ERROR
(
omx_error
,
"OMX_CommandStateSet Idle failed (%x)"
,
omx_error
);
while
(
1
)
{
OMX_U32
cmd
,
state
;
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
&
cmd
,
&
state
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
&
cmd
,
&
state
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for Idle failed (%x)"
,
omx_error
);
// The event queue can contain other OMX_EventCmdComplete items,
// such as for OMX_CommandFlush
...
...
@@ -552,7 +552,7 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec,
}
}
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for Loaded failed (%x)"
,
omx_error
);
}
...
...
@@ -704,7 +704,7 @@ static OMX_ERRORTYPE InitialiseComponent(decoder_t *p_dec,
p_port
->
i_port_index
,
NULL
);
CHECK_ERROR
(
omx_error
,
"OMX_CommandPortEnable on %i failed (%x)"
,
(
int
)
p_port
->
i_port_index
,
omx_error
);
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for PortEnable on %i failed (%x)"
,
(
int
)
p_port
->
i_port_index
,
omx_error
);
}
...
...
@@ -789,9 +789,7 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode )
p_dec
->
fmt_out
.
i_codec
=
0
;
}
p_sys
->
b_enc
=
b_encode
;
p_sys
->
pp_last_event
=
&
p_sys
->
p_events
;
vlc_mutex_init
(
&
p_sys
->
mutex
);
vlc_cond_init
(
&
p_sys
->
cond
);
InitOmxEventQueue
(
&
p_sys
->
event_queue
);
vlc_mutex_init
(
&
p_sys
->
in
.
fifo
.
lock
);
vlc_cond_init
(
&
p_sys
->
in
.
fifo
.
wait
);
p_sys
->
in
.
fifo
.
offset
=
offsetof
(
OMX_BUFFERHEADERTYPE
,
pOutputPortPrivate
)
/
sizeof
(
void
*
);
...
...
@@ -908,13 +906,13 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode )
omx_error
,
(
int
)
p_port
->
i_port_index
,
j
);
}
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for Idle failed (%x)"
,
omx_error
);
omx_error
=
OMX_SendCommand
(
p_sys
->
omx_handle
,
OMX_CommandStateSet
,
OMX_StateExecuting
,
0
);
CHECK_ERROR
(
omx_error
,
"OMX_CommandStateSet Executing failed (%x)"
,
omx_error
);
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for Executing failed (%x)"
,
omx_error
);
/* Send codec configuration data */
...
...
@@ -1053,7 +1051,7 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port)
CHECK_ERROR
(
omx_error
,
"OMX_FreeBuffer failed (%x, %i, %i)"
,
omx_error
,
(
int
)
p_port
->
i_port_index
,
i
);
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for PortDisable failed (%x)"
,
omx_error
);
/* Get the new port definition */
...
...
@@ -1114,7 +1112,7 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port)
CHECK_ERROR
(
omx_error
,
"OMX_UseBuffer failed (%x, %i, %i)"
,
omx_error
,
(
int
)
p_port
->
i_port_index
,
i
);
omx_error
=
WaitForSpecificOmxEvent
(
p_dec
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
omx_error
=
WaitForSpecificOmxEvent
(
&
p_sys
->
event_queue
,
OMX_EventCmdComplete
,
0
,
0
,
0
);
CHECK_ERROR
(
omx_error
,
"Wait for PortEnable failed (%x)"
,
omx_error
);
PrintOmx
(
p_dec
,
p_sys
->
omx_handle
,
p_dec
->
p_sys
->
in
.
i_port_index
);
...
...
@@ -1543,8 +1541,7 @@ static void CloseGeneric( vlc_object_t *p_this )
DeinitOmxCore
();
vlc_mutex_destroy
(
&
p_sys
->
mutex
);
vlc_cond_destroy
(
&
p_sys
->
cond
);
DeinitOmxEventQueue
(
&
p_sys
->
event_queue
);
vlc_mutex_destroy
(
&
p_sys
->
in
.
fifo
.
lock
);
vlc_cond_destroy
(
&
p_sys
->
in
.
fifo
.
wait
);
vlc_mutex_destroy
(
&
p_sys
->
out
.
fifo
.
lock
);
...
...
@@ -1601,7 +1598,7 @@ static OMX_ERRORTYPE OmxEventHandler( OMX_HANDLETYPE omx_handle,
break
;
}
PostOmxEvent
(
p_dec
,
event
,
data_1
,
data_2
,
event_data
);
PostOmxEvent
(
&
p_sys
->
event_queue
,
event
,
data_1
,
data_2
,
event_data
);
return
OMX_ErrorNone
;
}
...
...
modules/codec/omxil/omxil.h
View file @
0859ce7f
...
...
@@ -81,11 +81,7 @@ struct decoder_sys_t
char
ppsz_components
[
MAX_COMPONENTS_LIST_SIZE
][
OMX_MAX_STRINGNAME_SIZE
];
unsigned
int
components
;
struct
OmxEvent
*
p_events
;
struct
OmxEvent
**
pp_last_event
;
vlc_mutex_t
mutex
;
vlc_cond_t
cond
;
OmxEventQueue
event_queue
;
OmxPort
*
p_ports
;
unsigned
int
ports
;
...
...
modules/codec/omxil/omxil_utils.h
View file @
0859ce7f
...
...
@@ -151,11 +151,22 @@ typedef struct OmxEvent
struct
OmxEvent
*
next
;
}
OmxEvent
;
OMX_ERRORTYPE
PostOmxEvent
(
decoder_t
*
p_dec
,
OMX_EVENTTYPE
event
,
typedef
struct
OmxEventQueue
{
OmxEvent
*
p_events
;
OmxEvent
**
pp_last_event
;
vlc_mutex_t
mutex
;
vlc_cond_t
cond
;
}
OmxEventQueue
;
void
InitOmxEventQueue
(
OmxEventQueue
*
queue
);
void
DeinitOmxEventQueue
(
OmxEventQueue
*
queue
);
OMX_ERRORTYPE
PostOmxEvent
(
OmxEventQueue
*
queue
,
OMX_EVENTTYPE
event
,
OMX_U32
data_1
,
OMX_U32
data_2
,
OMX_PTR
event_data
);
OMX_ERRORTYPE
WaitForOmxEvent
(
decoder_t
*
p_dec
,
OMX_EVENTTYPE
*
event
,
OMX_ERRORTYPE
WaitForOmxEvent
(
OmxEventQueue
*
queue
,
OMX_EVENTTYPE
*
event
,
OMX_U32
*
data_1
,
OMX_U32
*
data_2
,
OMX_PTR
*
event_data
);
OMX_ERRORTYPE
WaitForSpecificOmxEvent
(
decoder_t
*
p_dec
,
OMX_ERRORTYPE
WaitForSpecificOmxEvent
(
OmxEventQueue
*
queue
,
OMX_EVENTTYPE
specific_event
,
OMX_U32
*
data_1
,
OMX_U32
*
data_2
,
OMX_PTR
*
event_data
);
void
PrintOmxEvent
(
vlc_object_t
*
p_this
,
OMX_EVENTTYPE
event
,
OMX_U32
data_1
,
...
...
modules/codec/omxil/utils.c
View file @
0859ce7f
...
...
@@ -40,10 +40,22 @@
/*****************************************************************************
* Events utility functions
*****************************************************************************/
OMX_ERRORTYPE
PostOmxEvent
(
decoder_t
*
p_dec
,
OMX_EVENTTYPE
event
,
void
InitOmxEventQueue
(
OmxEventQueue
*
queue
)
{
queue
->
pp_last_event
=
&
queue
->
p_events
;
vlc_mutex_init
(
&
queue
->
mutex
);
vlc_cond_init
(
&
queue
->
cond
);
}
void
DeinitOmxEventQueue
(
OmxEventQueue
*
queue
)
{
vlc_mutex_destroy
(
&
queue
->
mutex
);
vlc_cond_destroy
(
&
queue
->
cond
);
}
OMX_ERRORTYPE
PostOmxEvent
(
OmxEventQueue
*
queue
,
OMX_EVENTTYPE
event
,
OMX_U32
data_1
,
OMX_U32
data_2
,
OMX_PTR
event_data
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
OmxEvent
*
p_event
;
p_event
=
malloc
(
sizeof
(
OmxEvent
));
...
...
@@ -55,33 +67,32 @@ OMX_ERRORTYPE PostOmxEvent(decoder_t *p_dec, OMX_EVENTTYPE event,
p_event
->
event_data
=
event_data
;
p_event
->
next
=
0
;
vlc_mutex_lock
(
&
p_sys
->
mutex
);
*
p_sys
->
pp_last_event
=
p_event
;
p_sys
->
pp_last_event
=
&
p_event
->
next
;
vlc_cond_signal
(
&
p_sys
->
cond
);
vlc_mutex_unlock
(
&
p_sys
->
mutex
);
vlc_mutex_lock
(
&
queue
->
mutex
);
*
queue
->
pp_last_event
=
p_event
;
queue
->
pp_last_event
=
&
p_event
->
next
;
vlc_cond_signal
(
&
queue
->
cond
);
vlc_mutex_unlock
(
&
queue
->
mutex
);
return
OMX_ErrorNone
;
}
OMX_ERRORTYPE
WaitForOmxEvent
(
decoder_t
*
p_dec
,
OMX_EVENTTYPE
*
event
,
OMX_ERRORTYPE
WaitForOmxEvent
(
OmxEventQueue
*
queue
,
OMX_EVENTTYPE
*
event
,
OMX_U32
*
data_1
,
OMX_U32
*
data_2
,
OMX_PTR
*
event_data
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
OmxEvent
*
p_event
;
vlc_mutex_lock
(
&
p_sys
->
mutex
);
vlc_mutex_lock
(
&
queue
->
mutex
);
if
(
!
p_sys
->
p_events
)
vlc_cond_timedwait
(
&
p_sys
->
cond
,
&
p_sys
->
mutex
,
mdate
()
+
CLOCK_FREQ
);
if
(
!
queue
->
p_events
)
vlc_cond_timedwait
(
&
queue
->
cond
,
&
queue
->
mutex
,
mdate
()
+
CLOCK_FREQ
);
p_event
=
p_sys
->
p_events
;
p_event
=
queue
->
p_events
;
if
(
p_event
)
{
p_sys
->
p_events
=
p_event
->
next
;
if
(
!
p_sys
->
p_events
)
p_sys
->
pp_last_event
=
&
p_sys
->
p_events
;
queue
->
p_events
=
p_event
->
next
;
if
(
!
queue
->
p_events
)
queue
->
pp_last_event
=
&
queue
->
p_events
;
}
vlc_mutex_unlock
(
&
p_sys
->
mutex
);
vlc_mutex_unlock
(
&
queue
->
mutex
);
if
(
p_event
)
{
...
...
@@ -96,7 +107,7 @@ OMX_ERRORTYPE WaitForOmxEvent(decoder_t *p_dec, OMX_EVENTTYPE *event,
return
OMX_ErrorTimeout
;
}
OMX_ERRORTYPE
WaitForSpecificOmxEvent
(
decoder_t
*
p_dec
,
OMX_ERRORTYPE
WaitForSpecificOmxEvent
(
OmxEventQueue
*
queue
,
OMX_EVENTTYPE
specific_event
,
OMX_U32
*
data_1
,
OMX_U32
*
data_2
,
OMX_PTR
*
event_data
)
{
...
...
@@ -106,7 +117,7 @@ OMX_ERRORTYPE WaitForSpecificOmxEvent(decoder_t *p_dec,
while
(
1
)
{
status
=
WaitForOmxEvent
(
p_dec
,
&
event
,
data_1
,
data_2
,
event_data
);
status
=
WaitForOmxEvent
(
queue
,
&
event
,
data_1
,
data_2
,
event_data
);
if
(
status
!=
OMX_ErrorNone
)
return
status
;
if
(
event
==
specific_event
)
break
;
...
...
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