waver : bump version to v1.3.2

- single-threaded app
- new message indicator
- audio capture indicator
- emscripten compatibility
This commit is contained in:
Georgi Gerganov
2021-01-07 19:19:35 +02:00
parent 8421bdd186
commit 3484bd11c2
6 changed files with 74 additions and 96 deletions

View File

@@ -1,6 +1,15 @@
#include "ggwave-common.h"
#include <dlfcn.h>
#include <unistd.h>
#include <cstring>
#include <fstream>
#include <iterator>
namespace {
void dummy() {}
}
std::map<std::string, std::string> parseCmdArguments(int argc, char ** argv) {
int last = argc;
@@ -15,3 +24,53 @@ std::map<std::string, std::string> parseCmdArguments(int argc, char ** argv) {
return res;
}
std::vector<char> readFile(const char* filename) {
std::ifstream file(filename, std::ios::binary);
if (!file.is_open() || !file.good()) return {};
file.unsetf(std::ios::skipws);
std::streampos fileSize;
file.seekg(0, std::ios::end);
fileSize = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<char> vec;
vec.reserve(fileSize);
vec.insert(vec.begin(),
std::istream_iterator<char>(file),
std::istream_iterator<char>());
return vec;
}
std::string getBinaryPath() {
#ifdef __EMSCRIPTEN__
return "";
#endif
std::string result;
void* p = reinterpret_cast<void*>(dummy);
Dl_info info;
dladdr(p, &info);
if (*info.dli_fname == '/') {
result = info.dli_fname;
} else {
char buff[2048];
auto len = readlink("/proc/self/exe", buff, sizeof(buff) - 1);
if (len > 0) {
buff[len] = 0;
result = buff;
}
}
auto slash = result.rfind('/');
if (slash != std::string::npos) {
result.erase(slash + 1);
}
return result;
}

View File

@@ -3,6 +3,7 @@
#include <chrono>
#include <string>
#include <map>
#include <vector>
// some basic helper methods for the examples
@@ -11,4 +12,8 @@ float getTime_ms(const T & tStart, const T & tEnd) {
return ((float)(std::chrono::duration_cast<std::chrono::microseconds>(tEnd - tStart).count()))/1000.0;
}
std::vector<char> readFile(const char* filename);
std::string getBinaryPath();
std::map<std::string, std::string> parseCmdArguments(int argc, char ** argv);

View File

@@ -14,12 +14,10 @@
#include <SDL.h>
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstdio>
#include <string>
#include <ctime>
#include <mutex>
#include <thread>
#include <vector>
#include <sstream>
@@ -188,8 +186,6 @@ struct Input {
};
struct Buffer {
std::mutex mutex;
State stateCore;
Input inputCore;
@@ -197,9 +193,9 @@ struct Buffer {
Input inputUI;
};
bool g_isRunning;
GGWave * g_ggWave;
Buffer g_buffer;
std::atomic<bool> g_isRunning;
// file send data
struct BroadcastInfo {
@@ -497,7 +493,7 @@ void updateCore() {
static GGWave::TxRxData lastRxData;
{
std::lock_guard<std::mutex> lock(g_buffer.mutex);
//std::lock_guard<std::mutex> lock(g_buffer.mutex);
if (g_buffer.inputCore.update) {
inputCurrent = std::move(g_buffer.inputCore);
g_buffer.inputCore.update = false;
@@ -565,23 +561,11 @@ void updateCore() {
}
{
std::lock_guard<std::mutex> lock(g_buffer.mutex);
//std::lock_guard<std::mutex> lock(g_buffer.mutex);
g_buffer.stateCore.apply(g_buffer.stateUI);
}
}
std::thread initMainAndRunCore() {
initMain();
return std::thread([&]() {
while (g_isRunning) {
updateCore();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
});
}
void renderMain() {
g_fileServer.update();
@@ -642,7 +626,7 @@ void renderMain() {
static State stateCurrent;
{
std::lock_guard<std::mutex> lock(g_buffer.mutex);
//std::lock_guard<std::mutex> lock(g_buffer.mutex);
g_buffer.stateUI.apply(stateCurrent);
}
@@ -814,7 +798,7 @@ void renderMain() {
ImGui::BeginChild("Settings:main", ImGui::GetContentRegionAvail(), true);
ImGui::Text("%s", "");
ImGui::Text("%s", "");
ImGui::Text("Waver v1.3.1");
ImGui::Text("Waver v1.3.2");
ImGui::Separator();
ImGui::Text("%s", "");
@@ -1521,7 +1505,7 @@ void renderMain() {
ImGui::GetIO().KeysDown[ImGui::GetIO().KeyMap[ImGuiKey_Enter]] = false;
{
std::lock_guard<std::mutex> lock(g_buffer.mutex);
//std::lock_guard<std::mutex> lock(g_buffer.mutex);
if (g_buffer.inputUI.update) {
g_buffer.inputCore = std::move(g_buffer.inputUI);
g_buffer.inputUI.update = false;
@@ -1529,7 +1513,6 @@ void renderMain() {
}
}
void deinitMain(std::thread & worker) {
void deinitMain() {
g_isRunning = false;
worker.join();
}

View File

@@ -2,14 +2,12 @@
#include "ggwave-common-sdl2.h"
#include <thread>
#include <vector>
std::thread initMainAndRunCore();
void initMain();
void updateCore();
void renderMain();
void deinitMain(std::thread & worker);
void deinitMain();
// share info

View File

@@ -180,7 +180,7 @@
window.onerror = function() {
console.log("onerror: " + JSON.stringify(event));
if (checkSharedArrayBuffer() == false) {
document.getElementById('container_status').innerHTML = "It seems your browser does not have SharedArrayBuffer support enabled.<br><br>Try openning this page on a PC with latest Chrome browser.";
document.getElementById('container_status').innerHTML = "Failed to load the WebAssembly module.<br><br>Try openning this page on a PC with latest Chrome browser.";
document.getElementById('container_status').style.color = "#ff0000";
document.getElementById('container_button').hidden = true;
}

View File

@@ -14,69 +14,9 @@
#include <SDL.h>
#include <SDL_opengl.h>
#include <dlfcn.h>
#include <unistd.h>
#include <fstream>
#include <vector>
#include <iterator>
#include <functional>
namespace {
void dummy() {}
}
std::string getBinaryPath() {
#ifdef __EMSCRIPTEN__
return "";
#endif
std::string result;
void* p = reinterpret_cast<void*>(dummy);
Dl_info info;
dladdr(p, &info);
if (*info.dli_fname == '/') {
result = info.dli_fname;
} else {
char buff[2048];
auto len = readlink("/proc/self/exe", buff, sizeof(buff) - 1);
if (len > 0) {
buff[len] = 0;
result = buff;
}
}
auto slash = result.rfind('/');
if (slash != std::string::npos) {
result.erase(slash + 1);
}
return result;
}
std::vector<char> readFile(const char* filename) {
std::ifstream file(filename, std::ios::binary);
if (!file.is_open() || !file.good()) return {};
file.unsetf(std::ios::skipws);
std::streampos fileSize;
file.seekg(0, std::ios::end);
fileSize = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<char> vec;
vec.reserve(fileSize);
vec.insert(vec.begin(),
std::istream_iterator<char>(file),
std::istream_iterator<char>());
return vec;
}
// ImGui helpers
bool ImGui_BeginFrame(SDL_Window * window) {
@@ -289,7 +229,6 @@ int main(int argc, char** argv) {
//addFile("test2.mpv", "test0.mov", std::vector<char>(1024*1024*234 + 53827));
bool isInitialized = false;
std::thread worker;
g_doInit = [&]() {
if (GGWave_init(playbackId, captureId) == false) {
@@ -297,11 +236,7 @@ int main(int argc, char** argv) {
return false;
}
#ifdef __EMSCRIPTEN__
initMain();
#else
worker = initMainAndRunCore();
#endif
isInitialized = true;
@@ -323,9 +258,7 @@ int main(int argc, char** argv) {
renderMain();
updateMain();
#ifdef __EMSCRIPTEN__
updateCore();
#endif
ImGui_EndFrame(window);
@@ -344,7 +277,7 @@ int main(int argc, char** argv) {
if (g_mainUpdate() == false) break;
}
deinitMain(worker);
deinitMain();
GGWave_deinit();
// Cleanup