Merge branch 'v0.22.x'

This commit is contained in:
Max Kellermann
2021-05-26 11:57:41 +02:00
9 changed files with 92 additions and 39 deletions

View File

@@ -889,8 +889,6 @@ inline bool
MadDecoder::HandleCurrentFrame() noexcept
{
switch (mute_frame) {
DecoderCommand cmd;
case MadDecoderMuteFrame::SKIP:
mute_frame = MadDecoderMuteFrame::NONE;
break;
@@ -899,8 +897,8 @@ MadDecoder::HandleCurrentFrame() noexcept
mute_frame = MadDecoderMuteFrame::NONE;
UpdateTimerNextFrame();
break;
case MadDecoderMuteFrame::NONE:
cmd = SynthAndSubmit();
case MadDecoderMuteFrame::NONE: {
const auto cmd = SynthAndSubmit();
UpdateTimerNextFrame();
if (cmd == DecoderCommand::SEEK) {
assert(input_stream.IsSeekable());
@@ -922,6 +920,7 @@ MadDecoder::HandleCurrentFrame() noexcept
} else if (cmd != DecoderCommand::NONE)
return false;
}
}
return true;
}

View File

@@ -1,5 +1,7 @@
if enable_database
sqlite_dep = dependency('sqlite3', version: '>= 3.7.3', required: get_option('sqlite'))
sqlite_dep = dependency('sqlite3', version: '>= 3.7.3',
fallback: ['sqlite3', 'sqlite3_dep'],
required: get_option('sqlite'))
else
sqlite_dep = dependency('', required: false)
endif
@@ -21,4 +23,7 @@ sqlite = static_library(
sqlite_dep = declare_dependency(
link_with: sqlite,
dependencies: [
sqlite_dep,
],
)

View File

@@ -21,6 +21,7 @@
#include "Sticker.hxx"
#include "lib/sqlite/Util.hxx"
#include "fs/Path.hxx"
#include "fs/NarrowPath.hxx"
#include "Idle.hxx"
#include "util/StringCompare.hxx"
#include "util/ScopeExit.hxx"
@@ -82,7 +83,7 @@ static const char sticker_sql_create[] =
"";
StickerDatabase::StickerDatabase(Path path)
:db(path.c_str())
:db(NarrowPath(path))
{
assert(!path.IsNull());

View File

@@ -89,13 +89,13 @@ public:
:event(_loop, BIND_THIS_METHOD(OnTimeout)),
callback(_callback), userdata(_userdata) {
if (tv != nullptr)
event.Schedule(ToSteadyClockDuration(*tv));
Schedule(*tv);
}
static void TimeoutUpdate(AvahiTimeout *t,
const struct timeval *tv) noexcept {
if (tv != nullptr)
t->event.Schedule(ToSteadyClockDuration(*tv));
t->Schedule(*tv);
else
t->event.Cancel();
}
@@ -105,6 +105,30 @@ public:
}
private:
[[gnu::pure]]
Event::Duration AbsoluteToDuration(const struct timeval &tv) noexcept {
if (tv.tv_sec == 0)
/* schedule immediately */
return {};
struct timeval now;
if (gettimeofday(&now, nullptr) < 0)
/* shouldn't ever fail, but if it does, do
something reasonable */
return std::chrono::seconds(1);
auto d = ToSteadyClockDuration(tv)
- ToSteadyClockDuration(now);
if (d.count() < 0)
return {};
return d;
}
void Schedule(const struct timeval &tv) noexcept {
event.Schedule(AbsoluteToDuration(tv));
}
void OnTimeout() noexcept {
callback(this, userdata);
}