Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libdvbpsi
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
libdvbpsi
Commits
481d11ab
Commit
481d11ab
authored
Sep 07, 2015
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chain.c: simplify dvbpsi_chain_del()
parent
1173b527
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
30 deletions
+27
-30
misc/test_chain.c
misc/test_chain.c
+18
-2
src/chain.c
src/chain.c
+9
-24
src/chain.h
src/chain.h
+0
-4
No files found.
misc/test_chain.c
View file @
481d11ab
...
@@ -52,6 +52,20 @@
...
@@ -52,6 +52,20 @@
#define TEST_PASSED(msg) fprintf(stderr, "test %s -- PASSED\n", (msg));
#define TEST_PASSED(msg) fprintf(stderr, "test %s -- PASSED\n", (msg));
#define TEST_FAILED(msg) fprintf(stderr, "test %s -- FAILED\n", (msg));
#define TEST_FAILED(msg) fprintf(stderr, "test %s -- FAILED\n", (msg));
/* debug */
//#define _TEST_CHAIN_DEBUG
#ifdef _TEST_CHAIN_DEBUG
/* debug */
static
void
dvbpsi_decoder_chain_dump
(
dvbpsi_t
*
p_dvbpsi
)
{
dvbpsi_decoder_t
*
p
=
(
dvbpsi_decoder_t
*
)
p_dvbpsi
->
p_decoder
;
while
(
p
)
{
dvbpsi_debug
(
p_dvbpsi
,
"dump chain"
,
"found decoder %d:%d"
,
p
->
i_table_id
,
p
->
i_extension
);
p
=
p
->
p_next
;
}
}
#endif
static
void
message
(
dvbpsi_t
*
handle
,
const
dvbpsi_msg_level_t
level
,
const
char
*
msg
)
static
void
message
(
dvbpsi_t
*
handle
,
const
dvbpsi_msg_level_t
level
,
const
char
*
msg
)
{
{
switch
(
level
)
switch
(
level
)
...
@@ -208,6 +222,10 @@ int main(int i_argc, char* pa_argv[])
...
@@ -208,6 +222,10 @@ int main(int i_argc, char* pa_argv[])
}
}
TEST_PASSED
(
"dvbpsi_decoder_chain_add with extensions"
);
TEST_PASSED
(
"dvbpsi_decoder_chain_add with extensions"
);
#ifdef _TEST_CHAIN_DEBUG
dvbpsi_decoder_chain_dump
(
p_dvbpsi
);
#endif
/* Test dvbpsi_decoder_chain_del() */
/* Test dvbpsi_decoder_chain_del() */
if
(
!
chain_release
(
p_dvbpsi
,
CHAIN_DECODERS
))
{
if
(
!
chain_release
(
p_dvbpsi
,
CHAIN_DECODERS
))
{
TEST_FAILED
(
"dvbpsi_decoder_chain_del"
);
TEST_FAILED
(
"dvbpsi_decoder_chain_del"
);
...
@@ -224,8 +242,6 @@ int main(int i_argc, char* pa_argv[])
...
@@ -224,8 +242,6 @@ int main(int i_argc, char* pa_argv[])
}
}
TEST_PASSED
(
"dvbpsi_decoder_chain_del with extensions"
);
TEST_PASSED
(
"dvbpsi_decoder_chain_del with extensions"
);
//dvbpsi_decoder_chain_dump(p_dvbpsi);
assert
(
!
p_dvbpsi
->
p_decoder
);
p_dvbpsi
->
p_decoder
=
NULL
;
p_dvbpsi
->
p_decoder
=
NULL
;
dvbpsi_delete
(
p_dvbpsi
);
dvbpsi_delete
(
p_dvbpsi
);
fprintf
(
stderr
,
"ALL CHAIN TESTS PASSED
\n
"
);
fprintf
(
stderr
,
"ALL CHAIN TESTS PASSED
\n
"
);
...
...
src/chain.c
View file @
481d11ab
...
@@ -95,23 +95,19 @@ bool dvbpsi_decoder_chain_del(dvbpsi_t *p_dvbpsi, const dvbpsi_decoder_t *p_deco
...
@@ -95,23 +95,19 @@ bool dvbpsi_decoder_chain_del(dvbpsi_t *p_dvbpsi, const dvbpsi_decoder_t *p_deco
{
{
if
(
!
p_decoder
)
return
false
;
if
(
!
p_decoder
)
return
false
;
dvbpsi_decoder_t
*
p
=
(
dvbpsi_decoder_t
*
)
p_dvbpsi
->
p_decoder
;
dvbpsi_decoder_t
**
pp_prev
=
&
p_dvbpsi
->
p_decoder
;
dvbpsi_decoder_t
*
last
=
NULL
;
while
(
pp_prev
)
{
while
(
p
)
{
if
((
p_decoder
->
i_table_id
==
(
*
pp_prev
)
->
i_table_id
)
&&
if
((
p_decoder
->
i_table_id
==
p
->
i_table_id
)
&&
(
p_decoder
->
i_extension
==
(
*
pp_prev
)
->
i_extension
))
{
(
p_decoder
->
i_extension
==
p
->
i_extension
))
{
*
pp_prev
=
p_decoder
->
p_next
;
assert
(
p
==
p_decoder
);
if
(
last
==
NULL
)
p_dvbpsi
->
p_decoder
=
p
->
p_next
;
else
last
->
p_next
=
p
->
p_next
;
/* NOTE: caller must call dvbpsi_decoder_delete(p_decoder) */
/* NOTE: caller must call dvbpsi_decoder_delete(p_decoder) */
return
true
;
return
true
;
}
}
last
=
p
;
pp_prev
=
&
(
*
pp_prev
)
->
p_next
;
p
=
p
->
p_next
;
}
}
dvbpsi_warning
(
p_dvbpsi
,
"chain"
,
"decoder not found"
);
dvbpsi_warning
(
p_dvbpsi
,
"chain"
,
"decoder (table id: %u, extension: %u) not found"
,
p_decoder
->
i_table_id
,
p_decoder
->
i_extension
);
return
false
;
return
false
;
}
}
...
@@ -134,14 +130,3 @@ dvbpsi_decoder_t *dvbpsi_decoder_chain_get(dvbpsi_t *p_dvbpsi, const uint16_t ta
...
@@ -134,14 +130,3 @@ dvbpsi_decoder_t *dvbpsi_decoder_chain_get(dvbpsi_t *p_dvbpsi, const uint16_t ta
return
NULL
;
return
NULL
;
}
}
#if 0 /* debug */
void dvbpsi_decoder_chain_dump(dvbpsi_t *p_dvbpsi)
{
dvbpsi_decoder_t *p = (dvbpsi_decoder_t *)p_dvbpsi->p_decoder;
while (p) {
dvbpsi_debug(p_dvbpsi, "dump chain", "found decoder %d:%d",
p->i_table_id, p->i_extension);
p = p->p_next;
}
}
#endif
src/chain.h
View file @
481d11ab
...
@@ -81,10 +81,6 @@ bool dvbpsi_decoder_chain_del(dvbpsi_t *p_dvbpsi, const dvbpsi_decoder_t *p_deco
...
@@ -81,10 +81,6 @@ bool dvbpsi_decoder_chain_del(dvbpsi_t *p_dvbpsi, const dvbpsi_decoder_t *p_deco
*/
*/
dvbpsi_decoder_t
*
dvbpsi_decoder_chain_get
(
dvbpsi_t
*
p_dvbpsi
,
const
uint16_t
table_id
,
const
uint16_t
extension
);
dvbpsi_decoder_t
*
dvbpsi_decoder_chain_get
(
dvbpsi_t
*
p_dvbpsi
,
const
uint16_t
table_id
,
const
uint16_t
extension
);
#if 0 /* debug code */
void dvbpsi_decoder_chain_dump(dvbpsi_t *p_dvbpsi);
#endif
#ifdef __cplusplus
#ifdef __cplusplus
};
};
#endif
#endif
...
...
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