Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
42a69687
Commit
42a69687
authored
Nov 10, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/faad: migrate from class Error to C++ exceptions
parent
cfd51db2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
19 deletions
+13
-19
FaadDecoderPlugin.cxx
src/decoder/plugins/FaadDecoderPlugin.cxx
+13
-19
No files found.
src/decoder/plugins/FaadDecoderPlugin.cxx
View file @
42a69687
...
...
@@ -26,7 +26,6 @@
#include "tag/TagHandler.hxx"
#include "util/ScopeExit.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
...
...
@@ -248,16 +247,16 @@ faad_decoder_new()
/**
* Wrapper for NeAACDecInit() which works around some API
* inconsistencies in libfaad.
*
* Throws #std::runtime_error on error.
*/
static
bool
static
void
faad_decoder_init
(
NeAACDecHandle
decoder
,
DecoderBuffer
&
buffer
,
AudioFormat
&
audio_format
,
Error
&
error
)
AudioFormat
&
audio_format
)
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
if
(
data
.
IsEmpty
())
{
error
.
Set
(
faad_decoder_domain
,
"Empty file"
);
return
false
;
}
if
(
data
.
IsEmpty
())
throw
std
::
runtime_error
(
"Empty file"
);
uint8_t
channels
;
unsigned
long
sample_rate
;
...
...
@@ -266,16 +265,13 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
const_cast
<
unsigned
char
*>
(
data
.
data
),
data
.
size
,
&
sample_rate
,
&
channels
);
if
(
nbytes
<
0
)
{
error
.
Set
(
faad_decoder_domain
,
"Not an AAC stream"
);
return
false
;
}
if
(
nbytes
<
0
)
throw
std
::
runtime_error
(
"Not an AAC stream"
);
buffer
.
Consume
(
nbytes
);
audio_format
=
CheckAudioFormat
(
sample_rate
,
SampleFormat
::
S16
,
channels
);
return
true
;
}
/**
...
...
@@ -317,9 +313,11 @@ faad_get_file_time(InputStream &is)
buffer
.
Fill
();
AudioFormat
audio_format
;
if
(
faad_decoder_init
(
decoder
,
buffer
,
audio_format
,
IgnoreError
()))
try
{
faad_decoder_init
(
decoder
,
buffer
,
audio_format
);
recognized
=
true
;
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
}
return
std
::
make_pair
(
recognized
,
duration
);
...
...
@@ -336,12 +334,8 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is,
/* initialize it */
Error
error
;
AudioFormat
audio_format
;
if
(
!
faad_decoder_init
(
decoder
,
buffer
,
audio_format
,
error
))
{
LogError
(
error
);
return
;
}
faad_decoder_init
(
decoder
,
buffer
,
audio_format
);
/* initialize the MPD core */
...
...
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