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
f40816e0
Commit
f40816e0
authored
Dec 09, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/wavpack: add WavpackOpen() wrappers which throw exception
parent
3759f298
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
34 deletions
+32
-34
WavpackDecoderPlugin.cxx
src/decoder/plugins/WavpackDecoderPlugin.cxx
+32
-34
No files found.
src/decoder/plugins/WavpackDecoderPlugin.cxx
View file @
f40816e0
...
@@ -24,11 +24,10 @@
...
@@ -24,11 +24,10 @@
#include "CheckAudioFormat.hxx"
#include "CheckAudioFormat.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagHandler.hxx"
#include "fs/Path.hxx"
#include "fs/Path.hxx"
#include "util/Domain.hxx"
#include "util/Macros.hxx"
#include "util/Macros.hxx"
#include "util/Alloc.hxx"
#include "util/Alloc.hxx"
#include "util/ScopeExit.hxx"
#include "util/ScopeExit.hxx"
#include "
Log
.hxx"
#include "
util/RuntimeError
.hxx"
#include <wavpack/wavpack.h>
#include <wavpack/wavpack.h>
...
@@ -39,8 +38,6 @@
...
@@ -39,8 +38,6 @@
#define ERRORLEN 80
#define ERRORLEN 80
static
constexpr
Domain
wavpack_domain
(
"wavpack"
);
#ifdef OPEN_DSD_AS_PCM
#ifdef OPEN_DSD_AS_PCM
/* libWavPack supports DSD since version 5 */
/* libWavPack supports DSD since version 5 */
#ifdef ENABLE_DSD
#ifdef ENABLE_DSD
...
@@ -53,6 +50,33 @@ static constexpr int OPEN_DSD_FLAG = OPEN_DSD_AS_PCM;
...
@@ -53,6 +50,33 @@ static constexpr int OPEN_DSD_FLAG = OPEN_DSD_AS_PCM;
static
constexpr
int
OPEN_DSD_FLAG
=
0
;
static
constexpr
int
OPEN_DSD_FLAG
=
0
;
#endif
#endif
static
WavpackContext
*
WavpackOpenInput
(
Path
path
,
int
flags
,
int
norm_offset
)
{
char
error
[
ERRORLEN
];
auto
*
wpc
=
WavpackOpenFileInput
(
path
.
c_str
(),
error
,
flags
,
norm_offset
);
if
(
wpc
==
nullptr
)
throw
FormatRuntimeError
(
"failed to open WavPack file
\"
%s
\"
: %s"
,
path
.
c_str
(),
error
);
return
wpc
;
}
static
WavpackContext
*
WavpackOpenInput
(
WavpackStreamReader
*
reader
,
void
*
wv_id
,
void
*
wvc_id
,
int
flags
,
int
norm_offset
)
{
char
error
[
ERRORLEN
];
auto
*
wpc
=
WavpackOpenFileInputEx
(
reader
,
wv_id
,
wvc_id
,
error
,
flags
,
norm_offset
);
if
(
wpc
==
nullptr
)
throw
FormatRuntimeError
(
"failed to open WavPack stream: %s"
,
error
);
return
wpc
;
}
gcc_pure
gcc_pure
static
SignedSongTime
static
SignedSongTime
GetDuration
(
WavpackContext
*
wpc
)
GetDuration
(
WavpackContext
*
wpc
)
...
@@ -428,17 +452,8 @@ wavpack_streamdecode(DecoderClient &client, InputStream &is)
...
@@ -428,17 +452,8 @@ wavpack_streamdecode(DecoderClient &client, InputStream &is)
WavpackInput
isp
(
client
,
is
);
WavpackInput
isp
(
client
,
is
);
char
error
[
ERRORLEN
];
auto
*
wpc
=
WavpackOpenInput
(
&
mpd_is_reader
,
&
isp
,
wvc
.
get
(),
WavpackContext
*
wpc
=
open_flags
,
0
);
WavpackOpenFileInputEx
(
&
mpd_is_reader
,
&
isp
,
wvc
.
get
(),
error
,
open_flags
,
0
);
if
(
wpc
==
nullptr
)
{
FormatError
(
wavpack_domain
,
"failed to open WavPack stream: %s"
,
error
);
return
;
}
AtScopeExit
(
wpc
)
{
AtScopeExit
(
wpc
)
{
WavpackCloseFile
(
wpc
);
WavpackCloseFile
(
wpc
);
};
};
...
@@ -452,17 +467,9 @@ wavpack_streamdecode(DecoderClient &client, InputStream &is)
...
@@ -452,17 +467,9 @@ wavpack_streamdecode(DecoderClient &client, InputStream &is)
static
void
static
void
wavpack_filedecode
(
DecoderClient
&
client
,
Path
path_fs
)
wavpack_filedecode
(
DecoderClient
&
client
,
Path
path_fs
)
{
{
char
error
[
ERRORLEN
];
auto
*
wpc
=
WavpackOpenInput
(
path_fs
,
WavpackContext
*
wpc
=
WavpackOpenFileInput
(
path_fs
.
c_str
(),
error
,
OPEN_DSD_FLAG
|
OPEN_NORMALIZE
|
OPEN_WVC
,
OPEN_DSD_FLAG
|
OPEN_NORMALIZE
|
OPEN_WVC
,
0
);
0
);
if
(
wpc
==
nullptr
)
{
FormatWarning
(
wavpack_domain
,
"failed to open WavPack file
\"
%s
\"
: %s"
,
path_fs
.
c_str
(),
error
);
return
;
}
AtScopeExit
(
wpc
)
{
AtScopeExit
(
wpc
)
{
WavpackCloseFile
(
wpc
);
WavpackCloseFile
(
wpc
);
};
};
...
@@ -477,16 +484,7 @@ static bool
...
@@ -477,16 +484,7 @@ static bool
wavpack_scan_file
(
Path
path_fs
,
wavpack_scan_file
(
Path
path_fs
,
const
TagHandler
&
handler
,
void
*
handler_ctx
)
const
TagHandler
&
handler
,
void
*
handler_ctx
)
{
{
char
error
[
ERRORLEN
];
auto
*
wpc
=
WavpackOpenInput
(
path_fs
,
OPEN_DSD_FLAG
,
0
);
WavpackContext
*
wpc
=
WavpackOpenFileInput
(
path_fs
.
c_str
(),
error
,
OPEN_DSD_FLAG
,
0
);
if
(
wpc
==
nullptr
)
{
FormatError
(
wavpack_domain
,
"failed to open WavPack file
\"
%s
\"
: %s"
,
path_fs
.
c_str
(),
error
);
return
false
;
}
AtScopeExit
(
wpc
)
{
AtScopeExit
(
wpc
)
{
WavpackCloseFile
(
wpc
);
WavpackCloseFile
(
wpc
);
};
};
...
...
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