small adjustments, many enhancements to rktplayer

This commit is contained in:
2026-04-16 22:22:25 +02:00
parent 59c316a1f0
commit ee33c72915
4 changed files with 36 additions and 6 deletions

View File

@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %s %s %s %s %s %s\n", me, shm_name, shm_size_str, MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %s %s %s %s %s %s\n", me, shm_name, shm_size_str,
cmd_slot_str, res_slot_str, evt_slot_str, alive_slot_str, alive_ack_slot_str)); cmd_slot_str, res_slot_str, evt_slot_str, alive_slot_str, alive_ack_slot_str));
MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %lld %d %d %d %d %d\n", me, shm_name, shm_size, MKLOGSTMT(LOG_INFO, fprintf(stderr, "%s %s %d %d %d %d %d %d\n", me, shm_name, static_cast<int>(shm_size),
cmd_slot, res_slot, evt_slot, alive_slot, alive_ack_slot)); cmd_slot, res_slot, evt_slot, alive_slot, alive_ack_slot));
if (!(shm_size > 0 && cmd_slot > 0 && res_slot > 0 && evt_slot > 0 && alive_slot > 0 && alive_ack_slot > 0)) { if (!(shm_size > 0 && cmd_slot > 0 && res_slot > 0 && evt_slot > 0 && alive_slot > 0 && alive_ack_slot > 0)) {

View File

@@ -165,7 +165,10 @@ bool runRktWebview(Handle_t *handler)
} }
return r; return r;
#else #else
char *argv[] = { rkt_webview_prg_path, const_cast<char *>(handler->name.c_str()), shm_size_str, command_slot, command_result_slot, event_slot, nullptr }; char *argv[] = { rkt_webview_prg_path, const_cast<char *>(handler->name.c_str()), shm_size_str,
command_slot, command_result_slot, event_slot,
alive_slot, alive_ack_slot,
nullptr };
struct passwd *pw = getpwuid(getuid()); struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir; const char *homedir = pw->pw_dir;

View File

@@ -62,7 +62,8 @@ int main(int argc, char *argv[])
#ifdef _WIN32 #ifdef _WIN32
Sleep(30000); Sleep(30000);
#else #else
sleep(10); sleep(30
);
#endif #endif
d = rkt_webview_info(); d = rkt_webview_info();
rkt_webview_free_data(d); rkt_webview_free_data(d);

32
shm.cpp
View File

@@ -256,6 +256,8 @@ public:
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <semaphore.h> #include <semaphore.h>
#include <time.h>
#include <assert.h>
class ShmApi : public ShmApiBase class ShmApi : public ShmApiBase
@@ -338,22 +340,41 @@ public:
} }
}; };
#define TIME_NS_IN_MSEC 1000000ULL
class ShmSemApi { class ShmSemApi {
private: private:
sem_t *_sem; sem_t *_sem;
char *_name; char *_name;
bool _owner; bool _owner;
private:
void makeSemTimeoutTime(struct timespec *ts, int ms) {
clock_gettime(CLOCK_REALTIME, ts);
ts->tv_sec += ms / 1000;
ts->tv_nsec += (ms % 1000) * TIME_NS_IN_MSEC;
if (ts->tv_nsec >= 1000000000L) {
ts->tv_sec++;
ts->tv_nsec = ts->tv_nsec - 1000000000L;
}
}
public: public:
void post() { void post() {
sem_post(_sem); sem_post(_sem);
} }
void wait() { bool wait(int ms) {
int r = sem_wait(_sem); struct timespec ts;
makeSemTimeoutTime(&ts, ms);
int r = sem_timedwait(_sem, &ts);
if (r != 0) { if (r != 0) {
ERROR2("sem_wait error: %d, %s\n", errno, strerror(errno)); if (errno != ETIMEDOUT) {
ERROR2("sem_wait error: %d, %s\n", errno, strerror(errno));
}
return false;
} }
return true;
} }
bool trywait() { bool trywait() {
@@ -365,6 +386,11 @@ class ShmSemApi {
return (r == 0); return (r == 0);
} }
public:
void takeOwnership() {
_owner = true;
}
public: public:
ShmSemApi(const char *n, bool owner) { ShmSemApi(const char *n, bool owner) {
_name = strdup(n); _name = strdup(n);