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
a67197ef
Commit
a67197ef
authored
Dec 09, 2014
by
Ludovic Fauvet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpg123: simplify error handling and fix leak
parent
5bde7a82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
15 deletions
+13
-15
modules/codec/mpg123.c
modules/codec/mpg123.c
+13
-15
No files found.
modules/codec/mpg123.c
View file @
a67197ef
...
@@ -90,15 +90,13 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -90,15 +90,13 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
{
/* We've just started the stream, wait for the first PTS. */
/* We've just started the stream, wait for the first PTS. */
msg_Dbg
(
p_dec
,
"waiting for PTS"
);
msg_Dbg
(
p_dec
,
"waiting for PTS"
);
block_Release
(
p_block
);
goto
error
;
return
NULL
;
}
}
if
(
p_block
->
i_flags
&
(
BLOCK_FLAG_DISCONTINUITY
|
BLOCK_FLAG_CORRUPTED
)
)
if
(
p_block
->
i_flags
&
(
BLOCK_FLAG_DISCONTINUITY
|
BLOCK_FLAG_CORRUPTED
)
)
{
{
date_Set
(
&
p_sys
->
end_date
,
0
);
date_Set
(
&
p_sys
->
end_date
,
0
);
block_Release
(
p_block
);
goto
error
;
return
NULL
;
}
}
/* Feed mpg123 with raw data */
/* Feed mpg123 with raw data */
...
@@ -108,8 +106,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -108,8 +106,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
if
(
i_err
!=
MPG123_OK
)
if
(
i_err
!=
MPG123_OK
)
{
{
msg_Err
(
p_dec
,
"mpg123_feed failed: %s"
,
mpg123_plain_strerror
(
i_err
)
);
msg_Err
(
p_dec
,
"mpg123_feed failed: %s"
,
mpg123_plain_strerror
(
i_err
)
);
block_Release
(
p_block
);
goto
error
;
return
NULL
;
}
}
/* Get details about the stream */
/* Get details about the stream */
...
@@ -118,14 +115,12 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -118,14 +115,12 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
if
(
i_err
==
MPG123_NEED_MORE
)
if
(
i_err
==
MPG123_NEED_MORE
)
{
{
/* Need moar data */
/* Need moar data */
block_Release
(
p_block
);
goto
error
;
return
NULL
;
}
}
else
if
(
i_err
!=
MPG123_OK
)
else
if
(
i_err
!=
MPG123_OK
)
{
{
msg_Err
(
p_dec
,
"mpg123_info failed: %s"
,
mpg123_plain_strerror
(
i_err
)
);
msg_Err
(
p_dec
,
"mpg123_info failed: %s"
,
mpg123_plain_strerror
(
i_err
)
);
block_Release
(
p_block
);
goto
error
;
return
NULL
;
}
}
/* Configure the output */
/* Configure the output */
...
@@ -147,8 +142,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -147,8 +142,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
break
;
break
;
default:
default:
msg_Err
(
p_dec
,
"Unknown mode"
);
msg_Err
(
p_dec
,
"Unknown mode"
);
block_Release
(
p_block
);
goto
error
;
return
NULL
;
}
}
p_dec
->
fmt_out
.
audio
.
i_physical_channels
=
p_dec
->
fmt_out
.
audio
.
i_physical_channels
=
...
@@ -171,7 +165,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -171,7 +165,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
/* Request a new audio buffer */
/* Request a new audio buffer */
block_t
*
p_out
=
decoder_NewAudioBuffer
(
p_dec
,
p_block
->
i_nb_samples
);
block_t
*
p_out
=
decoder_NewAudioBuffer
(
p_dec
,
p_block
->
i_nb_samples
);
if
(
unlikely
(
!
p_out
)
)
if
(
unlikely
(
!
p_out
)
)
return
NULL
;
goto
error
;
/* Configure the buffer */
/* Configure the buffer */
p_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
p_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
...
@@ -185,7 +179,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -185,7 +179,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
{
msg_Err
(
p_dec
,
"could not replace buffer: %s"
,
mpg123_plain_strerror
(
i_err
)
);
msg_Err
(
p_dec
,
"could not replace buffer: %s"
,
mpg123_plain_strerror
(
i_err
)
);
block_Release
(
p_out
);
block_Release
(
p_out
);
return
NULL
;
goto
error
;
}
}
*
pp_block
=
NULL
;
/* avoid being fed the same packet again */
*
pp_block
=
NULL
;
/* avoid being fed the same packet again */
...
@@ -197,11 +191,15 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -197,11 +191,15 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
if
(
i_err
!=
MPG123_NEW_FORMAT
)
if
(
i_err
!=
MPG123_NEW_FORMAT
)
msg_Err
(
p_dec
,
"mpg123_decode_frame error: %s"
,
mpg123_plain_strerror
(
i_err
)
);
msg_Err
(
p_dec
,
"mpg123_decode_frame error: %s"
,
mpg123_plain_strerror
(
i_err
)
);
block_Release
(
p_out
);
block_Release
(
p_out
);
p_out
=
NULL
;
goto
error
;
}
}
block_Release
(
p_block
);
block_Release
(
p_block
);
return
p_out
;
return
p_out
;
error:
block_Release
(
p_block
);
return
NULL
;
}
}
/*****************************************************************************
/*****************************************************************************
...
...
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