small adjustments, many enhancements to rktplayer
This commit is contained in:
2
main.cpp
2
main.cpp
@@ -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,
|
||||
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));
|
||||
|
||||
if (!(shm_size > 0 && cmd_slot > 0 && res_slot > 0 && evt_slot > 0 && alive_slot > 0 && alive_ack_slot > 0)) {
|
||||
|
||||
@@ -165,7 +165,10 @@ bool runRktWebview(Handle_t *handler)
|
||||
}
|
||||
return r;
|
||||
#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());
|
||||
const char *homedir = pw->pw_dir;
|
||||
|
||||
@@ -62,7 +62,8 @@ int main(int argc, char *argv[])
|
||||
#ifdef _WIN32
|
||||
Sleep(30000);
|
||||
#else
|
||||
sleep(10);
|
||||
sleep(30
|
||||
);
|
||||
#endif
|
||||
d = rkt_webview_info();
|
||||
rkt_webview_free_data(d);
|
||||
|
||||
32
shm.cpp
32
shm.cpp
@@ -256,6 +256,8 @@ public:
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
class ShmApi : public ShmApiBase
|
||||
@@ -338,22 +340,41 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#define TIME_NS_IN_MSEC 1000000ULL
|
||||
|
||||
class ShmSemApi {
|
||||
private:
|
||||
sem_t *_sem;
|
||||
char *_name;
|
||||
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:
|
||||
void post() {
|
||||
sem_post(_sem);
|
||||
}
|
||||
|
||||
void wait() {
|
||||
int r = sem_wait(_sem);
|
||||
bool wait(int ms) {
|
||||
struct timespec ts;
|
||||
makeSemTimeoutTime(&ts, ms);
|
||||
int r = sem_timedwait(_sem, &ts);
|
||||
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() {
|
||||
@@ -365,6 +386,11 @@ class ShmSemApi {
|
||||
return (r == 0);
|
||||
}
|
||||
|
||||
public:
|
||||
void takeOwnership() {
|
||||
_owner = true;
|
||||
}
|
||||
|
||||
public:
|
||||
ShmSemApi(const char *n, bool owner) {
|
||||
_name = strdup(n);
|
||||
|
||||
Reference in New Issue
Block a user