Projects
Multimedia
dvswitch-git
title_hup.diff
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File title_hup.diff of Package dvswitch-git
--- src/dvsource-file.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) Index: dvswitch-0.9-1-da15ba4/src/dvsource-file.c =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/dvsource-file.c +++ dvswitch-0.9-1-da15ba4/src/dvsource-file.c @@ -74,21 +74,33 @@ static unsigned int get_file_size_bytes( static void usage(const char * progname) { fprintf(stderr, "\ -Usage: %s [-R] [-h HOST] [-p PORT] [--loop] [-t] FILE\n", +Usage: %s [-R] [-h HOST] [-p PORT] [--loop] [-t] DVFILE\n", progname); + + fprintf(stderr, "\n\ +To replace the DVFILE while --loop is running:\n\ + rm DVFILE; NEWSOURCE ... > DVFILE; kill -hup MYPID\n"); + } struct transfer_params { int file; + const char * filename; int sock; bool opt_loop; bool timings; }; +static int sighup_seen = 0; +static void sighup() +{ + sighup_seen = 1; +} + static ssize_t read_retry(int fd, void * buf, size_t count) { ssize_t chunk, total = 0; do @@ -139,10 +151,18 @@ static void transfer_frames(struct trans fflush(stdout); } return; } + if (sighup_seen && params->filename) + { + sighup_seen = 0; + close(params->file); + params->file = open(params->filename, O_RDONLY, 0); + printf("INFO: Reloading %s\n", params->filename); + } + if (lseek(params->file, 0, 0) == 0) { file_size = get_file_size_bytes(params->file); frame_number = 0; num_frames = 0; @@ -156,12 +176,18 @@ static void transfer_frames(struct trans if (size != (ssize_t)DIF_SEQUENCE_SIZE) { if (size < 0) perror("ERROR: read"); else - fputs("ERROR: Failed to read complete frame\n", stderr); - if (retry_connect) return; + fputs("ERROR: Failed to read complete frame...\n", stderr); + if (retry_connect) + { + close(params->file); + params->file = open(params->filename, O_RDONLY, 0); + printf("INFO: Retrying %s\n", params->filename); + continue; + } exit(1); } system = dv_buffer_system(buf); @@ -180,11 +206,17 @@ static void transfer_frames(struct trans { if (size < 0) perror("ERROR: read"); else fputs("ERROR: Failed to read complete frame\n", stderr); - if (retry_connect) return; + if (retry_connect) + { + close(params->file); + params->file = open(params->filename, O_RDONLY, 0); + printf("INFO: Retrying %s\n", params->filename); + continue; + } exit(1); } frame_number++; if (write(params->sock, buf, system->size) != (ssize_t)system->size) { @@ -243,13 +275,16 @@ static int is_dv_file(int fd) int main(int argc, char ** argv) { /* Initialise settings from configuration files. */ dvswitch_read_config(handle_config); + (void)signal(SIGHUP, &sighup); + struct transfer_params params; params.opt_loop = false; params.timings = false; + params.filename = NULL; /* Parse arguments. */ int opt; while ((opt = getopt_long(argc, argv, "h:p:ltR", options, NULL)) != -1) @@ -311,16 +346,17 @@ int main(int argc, char ** argv) /* Prepare to read the file and connect a socket to the mixer. */ if (strcmp(filename, "-")) { printf("INFO: Reading from %s\n", filename); + params.filename = filename; params.file = open(filename, O_RDONLY, 0); } else { printf("INFO: Reading from STDIN\n"); - params.file = feof(stdin); + params.file = fileno(stdin); } if (params.file < 0) { perror("ERROR: open"); return 1;
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.