speed up curl connection, Play music on a new thread

This commit is contained in:
mrdude2478 2023-10-06 08:37:39 +01:00
parent db232952e0
commit 3d63a8abf6
3 changed files with 10 additions and 5 deletions

View File

@ -27,7 +27,6 @@ namespace inst::ui {
extern MainApplication* mainApp;
instPage::instPage() : Layout::Layout() {
std::string infoRect_colour = "colour.inforect"_theme;
std::string bg_colour = "colour.background"_theme;
std::string tbar_colour = "colour.topbar"_theme;

View File

@ -1,3 +1,4 @@
#include <thread>
#include <filesystem>
#include <iostream>
#include <sstream>
@ -143,7 +144,7 @@ namespace inst::ui {
SDL_Init(SDL_INIT_AUDIO);
Mix_Init(MIX_INIT_MP3); //enable mp3 support
Mix_Init(MIX_INIT_FLAC); //enable flac support
Mix_Init(MIX_INIT_OGG); //enable flac support
Mix_Init(MIX_INIT_OGG); //enable ogg support
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096);
std::string loadsound = "romfs:/bluesong.mod";
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "audio.music"_theme)) {
@ -285,7 +286,10 @@ namespace inst::ui {
}
this->Add(this->optionMenu);
this->AddRenderCallback(mainMenuThread);
if (inst::config::useMusic) playmusic();
if (inst::config::useMusic) {
std::thread t(&playmusic);
t.join();
}
}
void MainPage::installMenuItem_Click() {
@ -404,7 +408,8 @@ namespace inst::ui {
}
if (Down & Held & HidNpadButton_L) {
playmusic();
std::thread t(&playmusic);
t.join(); // main thread waits for the thread t to finish
}
if (Down & Held & HidNpadButton_R) {

View File

@ -106,7 +106,8 @@ namespace inst::curl {
curl_easy_setopt(curl_handle, CURLOPT_TCP_FASTOPEN, 1L);
curl_easy_setopt(curl_handle, CURLOPT_STREAM_WEIGHT, 256L);
curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(curl_handle, CURLOPT_MAX_RECV_SPEED_LARGE, 1L);
//https://curl.se/libcurl/c/CURLOPT_MAX_RECV_SPEED_LARGE.html
curl_easy_setopt(curl_handle, CURLOPT_MAX_RECV_SPEED_LARGE, 0L); //set to 1 slows initial network connection.
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_REFERER, url);