mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-17 04:53:42 +00:00
refactoring
This commit is contained in:
@@ -216,7 +216,7 @@ static void _capture_init_workers(struct device_t *dev, struct workers_pool_t *p
|
|||||||
static void *_capture_worker_thread(void *v_ctx_ptr) {
|
static void *_capture_worker_thread(void *v_ctx_ptr) {
|
||||||
struct worker_context_t *ctx = (struct worker_context_t *)v_ctx_ptr;
|
struct worker_context_t *ctx = (struct worker_context_t *)v_ctx_ptr;
|
||||||
|
|
||||||
LOG_INFO("Hello! I am a worker #%d ^_^", ctx->index);
|
LOG_DEBUG("Hello! I am a worker #%d ^_^", ctx->index);
|
||||||
|
|
||||||
while (!*ctx->global_stop && !*ctx->workers_stop) {
|
while (!*ctx->global_stop && !*ctx->workers_stop) {
|
||||||
A_PTHREAD_M_LOCK(ctx->has_free_workers_mutex);
|
A_PTHREAD_M_LOCK(ctx->has_free_workers_mutex);
|
||||||
@@ -257,11 +257,11 @@ static void *_capture_worker_thread(void *v_ctx_ptr) {
|
|||||||
*ctx->last_comp_time = last_comp_time;
|
*ctx->last_comp_time = last_comp_time;
|
||||||
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
|
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
|
||||||
|
|
||||||
LOG_INFO("Compressed JPEG size=%ld; time=%LG (worker %d)", compressed, last_comp_time, ctx->index);
|
LOG_INFO("Compressed JPEG size=%ld; time=%LG (worker %d)", compressed, last_comp_time, ctx->index); // FIXME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Bye-bye (worker %d)", ctx->index);
|
LOG_DEBUG("Bye-bye (worker %d)", ctx->index);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ int main(int argc, char *argv[]) {
|
|||||||
struct threads_context ctx = {&dev, (sig_atomic_t *volatile)&_global_stop};
|
struct threads_context ctx = {&dev, (sig_atomic_t *volatile)&_global_stop};
|
||||||
struct sigaction sig_act;
|
struct sigaction sig_act;
|
||||||
|
|
||||||
|
device_init(&dev, &run);
|
||||||
|
_parse_options(argc, argv, &dev);
|
||||||
|
|
||||||
MEMSET_ZERO(sig_act);
|
MEMSET_ZERO(sig_act);
|
||||||
assert(!sigemptyset(&sig_act.sa_mask));
|
assert(!sigemptyset(&sig_act.sa_mask));
|
||||||
sig_act.sa_handler = _interrupt_handler;
|
sig_act.sa_handler = _interrupt_handler;
|
||||||
@@ -133,9 +136,6 @@ int main(int argc, char *argv[]) {
|
|||||||
LOG_INFO("Installing SIGTERM handler ...");
|
LOG_INFO("Installing SIGTERM handler ...");
|
||||||
assert(!sigaction(SIGTERM, &sig_act, NULL));
|
assert(!sigaction(SIGTERM, &sig_act, NULL));
|
||||||
|
|
||||||
device_init(&dev, &run);
|
|
||||||
_parse_options(argc, argv, &dev);
|
|
||||||
|
|
||||||
A_PTHREAD_CREATE(&capture_loop_tid, _capture_loop_thread, (void *)&ctx);
|
A_PTHREAD_CREATE(&capture_loop_tid, _capture_loop_thread, (void *)&ctx);
|
||||||
A_PTHREAD_JOIN(capture_loop_tid);
|
A_PTHREAD_JOIN(capture_loop_tid);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user