Merge branch 'jg' of https://github.com/neheb/MPD
This commit is contained in:
commit
e4cc89b2d9
|
@ -4,6 +4,7 @@
|
||||||
#include "FluidsynthDecoderPlugin.hxx"
|
#include "FluidsynthDecoderPlugin.hxx"
|
||||||
#include "../DecoderAPI.hxx"
|
#include "../DecoderAPI.hxx"
|
||||||
#include "pcm/CheckAudioFormat.hxx"
|
#include "pcm/CheckAudioFormat.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
|
@ -101,6 +102,8 @@ fluidsynth_file_decode(DecoderClient &client, Path path_fs)
|
||||||
fluid_player_t *player;
|
fluid_player_t *player;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
auto np = NarrowPath(path_fs);
|
||||||
|
|
||||||
/* set up fluid settings */
|
/* set up fluid settings */
|
||||||
|
|
||||||
settings = new_fluid_settings();
|
settings = new_fluid_settings();
|
||||||
|
@ -141,7 +144,7 @@ fluidsynth_file_decode(DecoderClient &client, Path path_fs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fluid_player_add(player, path_fs.c_str());
|
ret = fluid_player_add(player, np);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LogWarning(fluidsynth_domain, "fluid_player_add() failed");
|
LogWarning(fluidsynth_domain, "fluid_player_add() failed");
|
||||||
delete_fluid_player(player);
|
delete_fluid_player(player);
|
||||||
|
@ -200,7 +203,8 @@ static bool
|
||||||
fluidsynth_scan_file(Path path_fs,
|
fluidsynth_scan_file(Path path_fs,
|
||||||
[[maybe_unused]] TagHandler &handler) noexcept
|
[[maybe_unused]] TagHandler &handler) noexcept
|
||||||
{
|
{
|
||||||
return fluid_is_midifile(path_fs.c_str());
|
auto np = NarrowPath(path_fs);
|
||||||
|
return fluid_is_midifile(np);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const fluidsynth_suffixes[] = {
|
static const char *const fluidsynth_suffixes[] = {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "lib/fmt/PathFormatter.hxx"
|
#include "lib/fmt/PathFormatter.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
#include "tag/Handler.hxx"
|
#include "tag/Handler.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
@ -128,9 +129,10 @@ mikmod_decoder_finish() noexcept
|
||||||
static void
|
static void
|
||||||
mikmod_decoder_file_decode(DecoderClient &client, Path path_fs)
|
mikmod_decoder_file_decode(DecoderClient &client, Path path_fs)
|
||||||
{
|
{
|
||||||
|
auto np = NarrowPath(path_fs);
|
||||||
/* deconstify the path because libmikmod wants a non-const
|
/* deconstify the path because libmikmod wants a non-const
|
||||||
string pointer */
|
string pointer */
|
||||||
char *const path2 = const_cast<char *>(path_fs.c_str());
|
const auto path2 = const_cast<char *>(np.c_str());
|
||||||
|
|
||||||
MODULE *handle;
|
MODULE *handle;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -167,9 +169,10 @@ mikmod_decoder_file_decode(DecoderClient &client, Path path_fs)
|
||||||
static bool
|
static bool
|
||||||
mikmod_decoder_scan_file(Path path_fs, TagHandler &handler) noexcept
|
mikmod_decoder_scan_file(Path path_fs, TagHandler &handler) noexcept
|
||||||
{
|
{
|
||||||
|
auto np = NarrowPath(path_fs);
|
||||||
/* deconstify the path because libmikmod wants a non-const
|
/* deconstify the path because libmikmod wants a non-const
|
||||||
string pointer */
|
string pointer */
|
||||||
char *const path2 = const_cast<char *>(path_fs.c_str());
|
const auto path2 = const_cast<char *>(np.c_str());
|
||||||
|
|
||||||
MODULE *handle = Player_Load(path2, 128, 0);
|
MODULE *handle = Player_Load(path2, 128, 0);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "tag/Builder.hxx"
|
#include "tag/Builder.hxx"
|
||||||
#include "tag/ReplayGainParser.hxx"
|
#include "tag/ReplayGainParser.hxx"
|
||||||
#include "tag/MixRampParser.hxx"
|
#include "tag/MixRampParser.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
|
@ -43,14 +44,15 @@ mpd_mpg123_finish() noexcept
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
|
mpd_mpg123_open(mpg123_handle *handle, Path path_fs,
|
||||||
AudioFormat &audio_format)
|
AudioFormat &audio_format)
|
||||||
{
|
{
|
||||||
int error = mpg123_open(handle, path_fs);
|
auto np = NarrowPath(path_fs);
|
||||||
|
int error = mpg123_open(handle, np);
|
||||||
if (error != MPG123_OK) {
|
if (error != MPG123_OK) {
|
||||||
FmtWarning(mpg123_domain,
|
FmtWarning(mpg123_domain,
|
||||||
"libmpg123 failed to open {}: {}",
|
"libmpg123 failed to open {}: {}",
|
||||||
path_fs, mpg123_plain_strerror(error));
|
np.c_str(), mpg123_plain_strerror(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +181,7 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
|
||||||
AtScopeExit(handle) { mpg123_delete(handle); };
|
AtScopeExit(handle) { mpg123_delete(handle); };
|
||||||
|
|
||||||
AudioFormat audio_format;
|
AudioFormat audio_format;
|
||||||
if (!mpd_mpg123_open(handle, path_fs.c_str(), audio_format))
|
if (!mpd_mpg123_open(handle, path_fs, audio_format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const off_t num_samples = mpg123_length(handle);
|
const off_t num_samples = mpg123_length(handle);
|
||||||
|
@ -271,7 +273,7 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
|
||||||
|
|
||||||
AudioFormat audio_format;
|
AudioFormat audio_format;
|
||||||
try {
|
try {
|
||||||
if (!mpd_mpg123_open(handle, path_fs.c_str(), audio_format)) {
|
if (!mpd_mpg123_open(handle, path_fs, audio_format)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "tag/Handler.hxx"
|
#include "tag/Handler.hxx"
|
||||||
#include "tag/Builder.hxx"
|
#include "tag/Builder.hxx"
|
||||||
#include "song/DetachedSong.hxx"
|
#include "song/DetachedSong.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "lib/fmt/PathFormatter.hxx"
|
#include "lib/fmt/PathFormatter.hxx"
|
||||||
|
@ -155,10 +156,9 @@ ParseSubtuneName(const char *base) noexcept
|
||||||
static SidplayContainerPath
|
static SidplayContainerPath
|
||||||
ParseContainerPath(Path path_fs) noexcept
|
ParseContainerPath(Path path_fs) noexcept
|
||||||
{
|
{
|
||||||
const Path base = path_fs.GetBase();
|
const NarrowPath base = NarrowPath(path_fs.GetBase());
|
||||||
unsigned track;
|
unsigned track;
|
||||||
if (base.IsNull() ||
|
if (!base || (track = ParseSubtuneName(base)) < 1)
|
||||||
(track = ParseSubtuneName(base.c_str())) < 1)
|
|
||||||
return { AllocatedPath(path_fs), 1 };
|
return { AllocatedPath(path_fs), 1 };
|
||||||
|
|
||||||
return { path_fs.GetDirectoryName(), track };
|
return { path_fs.GetDirectoryName(), track };
|
||||||
|
@ -205,7 +205,8 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
|
||||||
/* load the tune */
|
/* load the tune */
|
||||||
|
|
||||||
const auto container = ParseContainerPath(path_fs);
|
const auto container = ParseContainerPath(path_fs);
|
||||||
SidTune tune(container.path.c_str());
|
auto np = NarrowPath(container.path);
|
||||||
|
auto tune = SidTune(np);
|
||||||
if (!tune.getStatus()) {
|
if (!tune.getStatus()) {
|
||||||
const char *error = tune.statusString();
|
const char *error = tune.statusString();
|
||||||
FmtWarning(sidplay_domain, "failed to load file: {}", error);
|
FmtWarning(sidplay_domain, "failed to load file: {}", error);
|
||||||
|
@ -435,7 +436,8 @@ sidplay_scan_file(Path path_fs, TagHandler &handler) noexcept
|
||||||
const auto container = ParseContainerPath(path_fs);
|
const auto container = ParseContainerPath(path_fs);
|
||||||
const unsigned song_num = container.track;
|
const unsigned song_num = container.track;
|
||||||
|
|
||||||
SidTune tune(container.path.c_str());
|
auto np = NarrowPath(container.path);
|
||||||
|
auto tune = SidTune(np);
|
||||||
if (!tune.getStatus())
|
if (!tune.getStatus())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -459,7 +461,7 @@ sidplay_container_scan(Path path_fs)
|
||||||
{
|
{
|
||||||
std::forward_list<DetachedSong> list;
|
std::forward_list<DetachedSong> list;
|
||||||
|
|
||||||
SidTune tune(path_fs.c_str());
|
auto tune = SidTune{NarrowPath(path_fs)};
|
||||||
if (!tune.getStatus())
|
if (!tune.getStatus())
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "pcm/CheckAudioFormat.hxx"
|
#include "pcm/CheckAudioFormat.hxx"
|
||||||
#include "tag/Handler.hxx"
|
#include "tag/Handler.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "lib/fmt/PathFormatter.hxx"
|
#include "lib/fmt/PathFormatter.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
|
@ -36,7 +37,8 @@ static WavpackContext *
|
||||||
WavpackOpenInput(Path path, int flags, int norm_offset)
|
WavpackOpenInput(Path path, int flags, int norm_offset)
|
||||||
{
|
{
|
||||||
char error[ERRORLEN];
|
char error[ERRORLEN];
|
||||||
auto *wpc = WavpackOpenFileInput(path.c_str(), error,
|
auto np = NarrowPath(path);
|
||||||
|
auto wpc = WavpackOpenFileInput(np, error,
|
||||||
flags, norm_offset);
|
flags, norm_offset);
|
||||||
if (wpc == nullptr)
|
if (wpc == nullptr)
|
||||||
throw FmtRuntimeError("failed to open WavPack file \"{}\": {}",
|
throw FmtRuntimeError("failed to open WavPack file \"{}\": {}",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "decoder/DecoderAPI.hxx" /* for class StopDecoder */
|
#include "decoder/DecoderAPI.hxx" /* for class StopDecoder */
|
||||||
#include "input/Init.hxx"
|
#include "input/Init.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "pcm/AudioFormat.hxx"
|
#include "pcm/AudioFormat.hxx"
|
||||||
#include "cmdline/OptionDef.hxx"
|
#include "cmdline/OptionDef.hxx"
|
||||||
|
@ -29,7 +30,7 @@ struct CommandLine {
|
||||||
const char *decoder = nullptr;
|
const char *decoder = nullptr;
|
||||||
const char *uri = nullptr;
|
const char *uri = nullptr;
|
||||||
|
|
||||||
Path config_path = nullptr;
|
FromNarrowPath config_path = nullptr;
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
};
|
};
|
||||||
|
@ -53,7 +54,7 @@ ParseCommandLine(int argc, char **argv)
|
||||||
while (auto o = option_parser.Next()) {
|
while (auto o = option_parser.Next()) {
|
||||||
switch (Option(o.index)) {
|
switch (Option(o.index)) {
|
||||||
case OPTION_CONFIG:
|
case OPTION_CONFIG:
|
||||||
c.config_path = Path::FromFS(o.value);
|
c.config_path = o.value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPTION_VERBOSE:
|
case OPTION_VERBOSE:
|
||||||
|
@ -112,7 +113,7 @@ try {
|
||||||
MyChromaprintDecoderClient client;
|
MyChromaprintDecoderClient client;
|
||||||
if (plugin->file_decode != nullptr) {
|
if (plugin->file_decode != nullptr) {
|
||||||
try {
|
try {
|
||||||
plugin->FileDecode(client, Path::FromFS(c.uri));
|
plugin->FileDecode(client, FromNarrowPath(c.uri));
|
||||||
} catch (StopDecoder) {
|
} catch (StopDecoder) {
|
||||||
}
|
}
|
||||||
} else if (plugin->stream_decode != nullptr) {
|
} else if (plugin->stream_decode != nullptr) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "archive/ArchivePlugin.hxx"
|
#include "archive/ArchivePlugin.hxx"
|
||||||
#include "archive/ArchiveFile.hxx"
|
#include "archive/ArchiveFile.hxx"
|
||||||
#include "archive/ArchiveVisitor.hxx"
|
#include "archive/ArchiveVisitor.hxx"
|
||||||
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "util/PrintException.hxx"
|
#include "util/PrintException.hxx"
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *plugin_name = argv[1];
|
const char *plugin_name = argv[1];
|
||||||
const Path path = Path::FromFS(argv[2]);
|
const Path path = FromNarrowPath(argv[2]);
|
||||||
|
|
||||||
/* initialize MPD */
|
/* initialize MPD */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue