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
4e16ea0f
Commit
4e16ea0f
authored
Nov 10, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/flac: migrate from class Error to C++ exceptions
parent
42a69687
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
19 deletions
+18
-19
FlacCommon.cxx
src/decoder/plugins/FlacCommon.cxx
+7
-5
FlacDecoderPlugin.cxx
src/decoder/plugins/FlacDecoderPlugin.cxx
+0
-1
FlacPcm.cxx
src/decoder/plugins/FlacPcm.cxx
+6
-10
FlacPcm.hxx
src/decoder/plugins/FlacPcm.hxx
+5
-3
No files found.
src/decoder/plugins/FlacCommon.cxx
View file @
4e16ea0f
...
...
@@ -24,10 +24,11 @@
#include "config.h"
#include "FlacCommon.hxx"
#include "FlacMetadata.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "Log.hxx"
#include <stdexcept>
bool
FlacDecoder
::
Initialize
(
unsigned
sample_rate
,
unsigned
bits_per_sample
,
unsigned
channels
,
FLAC__uint64
total_frames
)
...
...
@@ -35,10 +36,11 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
assert
(
!
initialized
);
assert
(
!
unsupported
);
::
Error
error
;
if
(
!
pcm_import
.
Open
(
sample_rate
,
bits_per_sample
,
channels
,
error
))
{
LogError
(
error
);
try
{
pcm_import
.
Open
(
sample_rate
,
bits_per_sample
,
channels
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
LogError
(
e
);
unsupported
=
true
;
return
false
;
}
...
...
src/decoder/plugins/FlacDecoderPlugin.cxx
View file @
4e16ea0f
...
...
@@ -26,7 +26,6 @@
#include "OggCodec.hxx"
#include "fs/Path.hxx"
#include "fs/NarrowPath.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
...
...
src/decoder/plugins/FlacPcm.cxx
View file @
4e16ea0f
...
...
@@ -19,9 +19,8 @@
#include "config.h"
#include "FlacPcm.hxx"
#include "FlacDomain.hxx"
#include "CheckAudioFormat.hxx"
#include "util/Error.hxx"
#include "util/
Runtime
Error.hxx"
#include "util/ConstBuffer.hxx"
#include <assert.h>
...
...
@@ -47,19 +46,16 @@ flac_sample_format(unsigned bits_per_sample)
}
}
bool
void
FlacPcmImport
::
Open
(
unsigned
sample_rate
,
unsigned
bits_per_sample
,
unsigned
channels
,
Error
&
error
)
unsigned
channels
)
{
auto
sample_format
=
flac_sample_format
(
bits_per_sample
);
if
(
sample_format
==
SampleFormat
::
UNDEFINED
)
{
error
.
Format
(
flac_domain
,
"Unsupported FLAC bit depth: %u"
,
bits_per_sample
);
return
false
;
}
if
(
sample_format
==
SampleFormat
::
UNDEFINED
)
throw
FormatRuntimeError
(
"Unsupported FLAC bit depth: %u"
,
bits_per_sample
);
audio_format
=
CheckAudioFormat
(
sample_rate
,
sample_format
,
channels
);
return
true
;
}
template
<
typename
T
>
...
...
src/decoder/plugins/FlacPcm.hxx
View file @
4e16ea0f
...
...
@@ -26,7 +26,6 @@
#include <FLAC/ordinals.h>
class
Error
;
template
<
typename
T
>
struct
ConstBuffer
;
/**
...
...
@@ -39,8 +38,11 @@ class FlacPcmImport {
AudioFormat
audio_format
;
public
:
bool
Open
(
unsigned
sample_rate
,
unsigned
bits_per_sample
,
unsigned
channels
,
Error
&
error
);
/**
* Throws #std::runtime_error on error.
*/
void
Open
(
unsigned
sample_rate
,
unsigned
bits_per_sample
,
unsigned
channels
);
const
AudioFormat
&
GetAudioFormat
()
const
{
return
audio_format
;
...
...
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