summaryrefslogtreecommitdiffstats
path: root/src/server/Engine.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-07-17 11:33:25 -0400
committerDavid Robillard <d@drobilla.net>2024-07-17 12:30:47 -0400
commit175c04323ad1aaaa1e0c949b8de411d5e2cece74 (patch)
treeac359693858f9ba2e619f2d9fc9b809af637a82e /src/server/Engine.cpp
parent973db12fe33bab8e6efca80deca358b4998d5eb2 (diff)
downloadingen-175c04323ad1aaaa1e0c949b8de411d5e2cece74.tar.gz
ingen-175c04323ad1aaaa1e0c949b8de411d5e2cece74.tar.bz2
ingen-175c04323ad1aaaa1e0c949b8de411d5e2cece74.zip
Avoid C-style casts and some size type conversions
Aside from the syntactic cast changes, reduces some size types to 32-bits, since they can never be so large in practice. This eliminates some type conversions and shaves a few bytes.
Diffstat (limited to 'src/server/Engine.cpp')
-rw-r--r--src/server/Engine.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index c4c492b7..cc3012d4 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -104,11 +104,14 @@ Engine::Engine(ingen::World& world)
}
for (int i = 0; i < world.conf().option("threads").get<int32_t>(); ++i) {
+ const bool is_threaded = (i > 0);
_notifications.emplace_back(
- std::make_unique<raul::RingBuffer>(uint32_t(24 * event_queue_size())));
+ std::make_unique<raul::RingBuffer>(24U * event_queue_size()));
_run_contexts.emplace_back(
- std::make_unique<RunContext>(
- *this, _notifications.back().get(), unsigned(i), i > 0));
+ std::make_unique<RunContext>(*this,
+ _notifications.back().get(),
+ static_cast<unsigned>(i),
+ is_threaded));
}
_world.lv2_features().add_feature(_worker->schedule_feature());
@@ -295,16 +298,17 @@ Engine::block_length() const
return _driver->block_length();
}
-size_t
+uint32_t
Engine::sequence_size() const
{
return _driver->seq_size();
}
-size_t
+uint32_t
Engine::event_queue_size() const
{
- return _world.conf().option("queue-size").get<int32_t>();
+ return static_cast<uint32_t>(
+ std::max(0, _world.conf().option("queue-size").get<int32_t>()));
}
void
@@ -378,7 +382,7 @@ Engine::reset_load()
}
void
-Engine::init(double sample_rate, uint32_t block_length, size_t seq_size)
+Engine::init(double sample_rate, uint32_t block_length, uint32_t seq_size)
{
set_driver(std::make_shared<DirectDriver>(
*this, sample_rate, block_length, seq_size));