decoder/Bridge: add method OpenLocal()

This commit is contained in:
Max Kellermann 2019-05-30 17:08:09 +02:00
parent cfb678d618
commit 8fef4af7b2
3 changed files with 16 additions and 3 deletions

View File

@ -30,6 +30,8 @@
#include "tag/Tag.hxx"
#include "Log.hxx"
#include "input/InputStream.hxx"
#include "input/LocalOpen.hxx"
#include "fs/Path.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringBuffer.hxx"
@ -49,6 +51,12 @@ DecoderBridge::~DecoderBridge() noexcept
assert(current_chunk == nullptr);
}
InputStreamPtr
DecoderBridge::OpenLocal(Path path_fs)
{
return OpenLocalInputStream(path_fs, dc.mutex);
}
bool
DecoderBridge::CheckCancelRead() const noexcept
{

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@ -30,6 +30,7 @@
class PcmConvert;
struct MusicChunk;
class DecoderControl;
class Path;
struct Tag;
/**
@ -153,6 +154,11 @@ public:
std::rethrow_exception(error);
}
/**
* Open a local file.
*/
InputStreamPtr OpenLocal(Path path_fs);
/* virtual methods from DecoderClient */
void Ready(AudioFormat audio_format,
bool seekable, SignedSongTime duration) override;

View File

@ -27,7 +27,6 @@
#include "fs/AllocatedPath.hxx"
#include "DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "input/LocalOpen.hxx"
#include "input/Registry.hxx"
#include "DecoderList.hxx"
#include "system/Error.hxx"
@ -347,7 +346,7 @@ decoder_run_file(DecoderBridge &bridge, const char *uri_utf8, Path path_fs)
InputStreamPtr input_stream;
try {
input_stream = OpenLocalInputStream(path_fs, bridge.dc.mutex);
input_stream = bridge.OpenLocal(path_fs);
} catch (const std::system_error &e) {
if (IsPathNotFound(e) &&
/* ENOTDIR means this may be a path inside a