diff --git a/include/dpp/discordvoiceclient.h b/include/dpp/discordvoiceclient.h index adfb37e417..e71f221e1b 100644 --- a/include/dpp/discordvoiceclient.h +++ b/include/dpp/discordvoiceclient.h @@ -662,6 +662,13 @@ class DPP_EXPORT discord_voice_client : public websocket_client */ dpp::utility::uptime get_uptime(); + /** + * @brief The time (in milliseconds) between each interval when parsing audio. + * + * @warning You should only change this if you know what you're doing. It is set to 500ms by default. + */ + uint16_t iteration_interval{500}; + /** Constructor takes shard id, max shards and token. * @param _cluster The cluster which owns this voice connection, for related logging, REST requests etc * @param _channel_id The channel id to identify the voice connection as @@ -852,6 +859,22 @@ class DPP_EXPORT discord_voice_client : public websocket_client */ discord_voice_client& stop_audio(); + /** + * @brief Change the iteration interval time. + * + * @param time The time (in milliseconds) between each interval when parsing audio. + * + * @return Reference to self. + */ + discord_voice_client& set_iteration_interval(uint16_t interval); + + /** + * @brief Get the iteration interval time (in milliseconds). + * + * @return iteration_interval + */ + uint16_t get_iteration_interval(); + /** * @brief Returns true if we are playing audio * diff --git a/src/dpp/discordvoiceclient.cpp b/src/dpp/discordvoiceclient.cpp index 058130a765..5e514d7331 100644 --- a/src/dpp/discordvoiceclient.cpp +++ b/src/dpp/discordvoiceclient.cpp @@ -164,8 +164,7 @@ void discord_voice_client::voice_courier_loop(discord_voice_client& client, cour #ifdef HAVE_VOICE utility::set_thread_name(std::string("vcourier/") + std::to_string(client.server_id)); while (true) { - constexpr std::chrono::milliseconds iteration_interval(500); - std::this_thread::sleep_for(iteration_interval); + std::this_thread::sleep_for(std::chrono::milliseconds{client.iteration_interval}); struct flush_data_t { snowflake user_id; @@ -1353,6 +1352,13 @@ std::string discord_voice_client::discover_ip() { return ""; } +discord_voice_client& discord_voice_client::set_iteration_interval(uint16_t interval) { + this->iteration_interval = interval; + return *this; +} +uint16_t discord_voice_client::get_iteration_interval() { + return this->iteration_interval; +} } // namespace dpp