Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
8e733746
Commit
8e733746
authored
Mar 29, 2013
by
Simon Morlat
Browse files
clean fd management in fileplayer
parent
d931c935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
src/audiofilters/msfileplayer.c
src/audiofilters/msfileplayer.c
+5
-4
No files found.
src/audiofilters/msfileplayer.c
View file @
8e733746
...
...
@@ -177,7 +177,7 @@ static int player_open(MSFilter *f, void *arg){
int
fd
;
const
char
*
file
=
(
const
char
*
)
arg
;
if
(
d
->
fd
>=
0
){
if
(
d
->
fd
!=-
1
){
player_close
(
f
,
NULL
);
}
if
((
fd
=
open
(
file
,
O_RDONLY
|
O_BINARY
))
==-
1
){
...
...
@@ -195,6 +195,7 @@ static int player_open(MSFilter *f, void *arg){
d
->
pcap
=
pcap_open_offline
(
file
,
err
);
if
(
d
->
pcap
==
NULL
)
{
ms_error
(
"Failed to open pcap file: %s"
,
err
);
d
->
fd
=-
1
;
close
(
fd
);
return
-
1
;
}
...
...
@@ -241,7 +242,7 @@ static int player_close(MSFilter *f, void *arg){
#ifdef HAVE_PCAP
if
(
d
->
pcap
)
pcap_close
(
d
->
pcap
);
#endif
if
(
d
->
fd
>=
0
)
close
(
d
->
fd
);
if
(
d
->
fd
!=-
1
)
close
(
d
->
fd
);
d
->
fd
=-
1
;
d
->
state
=
MSPlayerClosed
;
return
0
;
...
...
@@ -255,7 +256,7 @@ static int player_get_state(MSFilter *f, void *arg){
static
void
player_uninit
(
MSFilter
*
f
){
PlayerData
*
d
=
(
PlayerData
*
)
f
->
data
;
if
(
d
->
fd
>=
0
)
player_close
(
f
,
NULL
);
if
(
d
->
fd
!=-
1
)
player_close
(
f
,
NULL
);
ms_free
(
d
);
}
...
...
@@ -409,7 +410,7 @@ static int player_loop(MSFilter *f, void *arg){
static
int
player_eof
(
MSFilter
*
f
,
void
*
arg
){
PlayerData
*
d
=
(
PlayerData
*
)
f
->
data
;
if
(
d
->
fd
<
0
&&
d
->
state
==
MSPlayerClosed
)
if
(
d
->
fd
==-
1
&&
d
->
state
==
MSPlayerClosed
)
*
((
int
*
)
arg
)
=
TRUE
;
/* 1 */
else
*
((
int
*
)
arg
)
=
FALSE
;
/* 0 */
...
...
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