Private
Public Access
Release 0.13.4
This commit is contained in:
1 parent
ef03258e22
commit
fcdfc4b431
21 files changed
+71
-27
No files matched your search
@@ -83,6 +83,8 @@ static int tick(void *unused) {
|
||||
capture_ctx.settling = 2;
|
||||
return 1;
|
||||
}
|
||||
if (capture_ctx.sample_at && now - capture_ctx.sample_at < target_capture_interval(&target))
|
||||
return 1;
|
||||
Histogram hist[16] = {0};
|
||||
int rc = vt_get(capture_ctx.handle, hist);
|
||||
bool populated = !rc && histogram_populated(hist);
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ int main(void) {
|
||||
service_handle = handle;
|
||||
if (!boot_enabled())
|
||||
retry_pause(&retries);
|
||||
timer(100, tick, NULL);
|
||||
timer(25, tick, NULL);
|
||||
while (!quitting) {
|
||||
iterate(NULL, 0);
|
||||
usleep(10000);
|
||||
|
||||
@@ -61,10 +61,10 @@ static bool status(void *h, void *m, void *ctx) {
|
||||
CALIBRATION_ACTIVE ? "true" : "false");
|
||||
used +=
|
||||
snprintf(json + used, sizeof(json) - used,
|
||||
"\"returnValue\":true,\"piccapPort\":%u,\"connectionTest\":{\"state\":\"%s\","
|
||||
"\"returnValue\":true,\"captureIntervalMs\":%u,\"piccapPort\":%u,\"connectionTest\":{\"state\":\"%s\","
|
||||
"\"ledCount\":%u,\"elapsedMs\":%llu,\"error\":\"%s\"},\"lastOutputAgeMs\":%"
|
||||
"lld,\"retryInMs\":%llu,\"captureState\":\"%s\",\"piccapError\":\"%s\",",
|
||||
target.piccap_port, test_stage_name(), connection_test.leds,
|
||||
target_capture_interval(&target), target.piccap_port, test_stage_name(), connection_test.leds,
|
||||
(unsigned long long)connection_test.elapsed, connection_test.error,
|
||||
capture_ctx.last_output_at ? (long long)(now - capture_ctx.last_output_at) : -1,
|
||||
(unsigned long long)(retries.due > now ? retries.due - now : 0),
|
||||
|
||||
+25
-4
@@ -15,10 +15,14 @@
|
||||
"/media/developer/apps/usr/palm/services/org.webosbrew.histogramhyperion.service/target.json"
|
||||
typedef struct {
|
||||
char host[46], receiver[16], token[257];
|
||||
unsigned port, piccap_port;
|
||||
unsigned port, piccap_port, capture_interval;
|
||||
} TargetConfig;
|
||||
static TargetConfig target = {
|
||||
.host = "127.0.0.1", .receiver = "Hyperion", .port = 19444, .piccap_port = 19400};
|
||||
.host = "127.0.0.1", .receiver = "Hyperion", .port = 19444, .piccap_port = 19400,
|
||||
.capture_interval = 50};
|
||||
static inline unsigned target_capture_interval(const TargetConfig *t) {
|
||||
return t->capture_interval ? t->capture_interval : 50;
|
||||
}
|
||||
static inline bool target_piccap_local(const TargetConfig *t) {
|
||||
return t->port == 19444 && (!strcmp(t->host, "127.0.0.1") || !strcmp(t->host, "::1"));
|
||||
}
|
||||
@@ -31,6 +35,9 @@ static inline const char *target_piccap_host(const TargetConfig *t) {
|
||||
}
|
||||
static bool target_valid(const TargetConfig *t) {
|
||||
unsigned char address[16];
|
||||
unsigned interval = target_capture_interval(t);
|
||||
if (interval < 25 || interval > 1000 || interval % 25)
|
||||
return false;
|
||||
if (inet_pton(AF_INET, t->host, address) != 1 && inet_pton(AF_INET6, t->host, address) != 1)
|
||||
return false;
|
||||
if (!t->piccap_port || t->piccap_port > 65535)
|
||||
@@ -97,6 +104,20 @@ static bool target_parse(PlaybackJson *j, const char *text, TargetConfig *out) {
|
||||
next.piccap_port = (unsigned)n;
|
||||
}
|
||||
}
|
||||
void *interval = NULL;
|
||||
if (j->type(root) == 4 && j->get(root, "captureIntervalMs", &interval)) {
|
||||
if (j->type(interval) != 3)
|
||||
valid = false;
|
||||
else {
|
||||
char *end = NULL;
|
||||
errno = 0;
|
||||
long n = strtol(j->string(interval), &end, 10);
|
||||
if (errno || !end || *end || n < 25 || n > 1000 || n % 25)
|
||||
valid = false;
|
||||
else
|
||||
next.capture_interval = (unsigned)n;
|
||||
}
|
||||
}
|
||||
void *clear = playback_field(j, root, "clearToken");
|
||||
if (clear) {
|
||||
if (j->type(clear) != 1)
|
||||
@@ -116,8 +137,8 @@ static bool target_save(const char *path, const TargetConfig *t) {
|
||||
char data[512];
|
||||
int n = snprintf(
|
||||
data, sizeof(data),
|
||||
"{\"host\":\"%s\",\"port\":%u,\"piccapPort\":%u,\"receiver\":\"%s\",\"token\":\"%s\"}\n",
|
||||
t->host, t->port, t->piccap_port, t->receiver, t->token);
|
||||
"{\"host\":\"%s\",\"port\":%u,\"piccapPort\":%u,\"receiver\":\"%s\",\"token\":\"%s\",\"captureIntervalMs\":%u}\n",
|
||||
t->host, t->port, t->piccap_port, t->receiver, t->token, target_capture_interval(t));
|
||||
return n > 0 && (size_t)n < sizeof(data) &&
|
||||
atomic_replace(path, data, (size_t)n) != SAVE_UNCHANGED;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ int main(void){
|
||||
assert(letterbox_candidate(thin_black,thin_color)==-1);
|
||||
memset(thin_color,100,sizeof(thin_color));
|
||||
assert(letterbox_candidate(thin_black,thin_color)!=1);
|
||||
memset(thin_black,15,sizeof(thin_black));
|
||||
for(unsigned i=0;i<16;i++)thin_black[i]=15;
|
||||
assert(letterbox_candidate(thin_black,thin_color)!=1);
|
||||
puts("PASS: measured wide/thin bars, full frame, one-sided/isolated edges, dark frame and low contrast");
|
||||
}
|
||||
@@ -24,8 +24,16 @@ int main(void){
|
||||
assert(!target_parse(&j,"{\"host\":\"127.0.0.1\",\"port\":19444,\"piccapPort\":null,\"receiver\":\"HyperHDR\"}",&t));
|
||||
TargetConfig v6=t;strcpy(v6.host,"2001:db8::1");assert(!target_piccap_compatible(&v6));strcpy(v6.host,"::1");assert(target_piccap_compatible(&v6) && !strcmp(target_piccap_host(&v6),"127.0.0.1"));
|
||||
const char *file="/tmp/hyperdrm-target-test.json";assert(access(file,F_OK)!=0);assert(access("/tmp/hyperdrm-target-test.json.tmp",F_OK)!=0);
|
||||
assert(target_capture_interval(&t)==50);
|
||||
assert(target_parse(&j,"{\"host\":\"::1\",\"port\":65535,\"receiver\":\"HyperHDR\",\"captureIntervalMs\":100}",&t));
|
||||
assert(t.capture_interval==100);
|
||||
const char *invalid_intervals[]={"0","24","26","1001","50.5","null","\"50\""};
|
||||
for(unsigned i=0;i<sizeof(invalid_intervals)/sizeof(*invalid_intervals);i++){
|
||||
char request[256];snprintf(request,sizeof(request),"{\"host\":\"::1\",\"port\":65535,\"receiver\":\"HyperHDR\",\"captureIntervalMs\":%s}",invalid_intervals[i]);
|
||||
TargetConfig before=t;assert(!target_parse(&j,request,&t));assert(!memcmp(&before,&t,sizeof(t)));
|
||||
}
|
||||
assert(target_save(file,&t));struct stat st;assert(stat(file,&st)==0 && (st.st_mode&0777)==0600);
|
||||
TargetConfig restored=target;assert(target_load(&j,file,&restored));assert(!strcmp(restored.host,"::1") && restored.port==65535 && !strcmp(restored.token,"test-token"));
|
||||
TargetConfig restored=target;assert(target_load(&j,file,&restored));assert(restored.capture_interval==100);assert(!strcmp(restored.host,"::1") && restored.port==65535 && !strcmp(restored.token,"test-token"));
|
||||
assert(target_parse(&j,"{\"host\":\"127.0.0.1\",\"port\":19444,\"receiver\":\"HyperHDR\",\"clearToken\":true}",&t));assert(!t.token[0]);assert(target_piccap_local(&t));unlink(file);
|
||||
int server=socket(AF_INET,SOCK_STREAM,0);assert(server>=0);struct sockaddr_in a={.sin_family=AF_INET,.sin_addr={htonl(INADDR_LOOPBACK)}};
|
||||
assert(bind(server,(void*)&a,sizeof(a))==0 && listen(server,1)==0);socklen_t length=sizeof(a);assert(getsockname(server,(void*)&a,&length)==0);t.port=ntohs(a.sin_port);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#ifndef HYPERDRM_VERSION_H
|
||||
#define HYPERDRM_VERSION_H
|
||||
#define HYPERDRM_VERSION "0.13.3"
|
||||
#define HYPERDRM_VERSION "0.13.4"
|
||||
#endif
|
||||
Reference in new issue
Block a user