summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/MadDecoderPlugin.cxx7
-rw-r--r--src/lib/sqlite/meson.build7
-rw-r--r--src/sticker/Database.cxx3
-rw-r--r--src/zeroconf/avahi/Poll.cxx28
4 files changed, 37 insertions, 8 deletions
diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx
index 8fb99a0cd..7b6c98eec 100644
--- a/src/decoder/plugins/MadDecoderPlugin.cxx
+++ b/src/decoder/plugins/MadDecoderPlugin.cxx
@@ -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;
}
diff --git a/src/lib/sqlite/meson.build b/src/lib/sqlite/meson.build
index 6a5d07ef5..2db7fc8ae 100644
--- a/src/lib/sqlite/meson.build
+++ b/src/lib/sqlite/meson.build
@@ -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,
+ ],
)
diff --git a/src/sticker/Database.cxx b/src/sticker/Database.cxx
index 860b40dd3..a39cfc93a 100644
--- a/src/sticker/Database.cxx
+++ b/src/sticker/Database.cxx
@@ -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());
diff --git a/src/zeroconf/avahi/Poll.cxx b/src/zeroconf/avahi/Poll.cxx
index 0cec88f17..1d0f39895 100644
--- a/src/zeroconf/avahi/Poll.cxx
+++ b/src/zeroconf/avahi/Poll.cxx
@@ -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);
}