Changeset 214
- Timestamp:
- 27/11/08 20:31:37 (6 weeks ago)
- Location:
- trunk
- Files:
-
- 12 modified
-
vbi2srt/Makefile (modified) (1 diff)
-
vbi2srt/args.c (modified) (6 diffs)
-
vbi2srt/args.h (modified) (1 diff)
-
vbi2srt/main.c (modified) (32 diffs)
-
vbi2srt/main.h (modified) (1 diff)
-
vbi2srt/vbi.c (modified) (6 diffs)
-
vbilib/Makefile (modified) (1 diff)
-
vbilib/language.c (modified) (4 diffs)
-
vbilib/teletext.c (modified) (15 diffs)
-
vbilib/vbilib.h (modified) (2 diffs)
-
vbishow/Makefile (modified) (1 diff)
-
vbishow/vbi-show.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/vbi2srt/Makefile
r213 r214 1 VERSION = -0. 1.111 VERSION = -0.2.02 2 2 3 3 PREFIX = /usr/local -
trunk/vbi2srt/args.c
r212 r214 93 93 opt->libopt.input_name = "/dev/video0"; 94 94 opt->input = STDIN_FILENO; 95 opt-> libopt.output_given = 0;96 opt-> libopt.output_name = "/dev/video16";95 opt->output_given = 0; 96 opt->output_name = "/dev/video16"; 97 97 opt->output = STDOUT_FILENO; 98 98 opt->time_offset_given = 0; … … 103 103 opt->vbi_name = "/dev/vbi0"; 104 104 opt->vbi = 0; 105 opt-> srt_given = 0;106 opt-> srt_name = "/dev/video0.srt";107 opt-> srt = 0;105 opt->libopt.output_given = 0; 106 opt->libopt.output_name = "/dev/video0.libopt.output"; 107 opt->libopt.output = 0; 108 108 opt->srt_colour = 0; 109 109 opt->libopt.pagenum_given = 0; … … 124 124 fwprintf(stderr, L"input_given=%s\n", opt->libopt.input_given ? "yes" : "no"); 125 125 fwprintf(stderr, L"input_name=%s\n", opt->libopt.input_name); 126 fwprintf(stderr, L"output_given=%s\n", opt-> libopt.output_given ? "yes" : "no");127 fwprintf(stderr, L"output_name=%s\n", opt-> libopt.output_name);126 fwprintf(stderr, L"output_given=%s\n", opt->output_given ? "yes" : "no"); 127 fwprintf(stderr, L"output_name=%s\n", opt->output_name); 128 128 fwprintf(stderr, L"duration_given=%s\n", opt->duration_given ? "yes" : "no"); 129 129 fwprintf(stderr, L"duration=%d\n", opt->duration); … … 132 132 fwprintf(stderr, L"vbi_given=%s\n", opt->vbi_given ? "yes" : "no"); 133 133 fwprintf(stderr, L"vbi_name=%s\n", opt->vbi_name); 134 fwprintf(stderr, L"srt_given=%s\n", opt-> srt_given ? "yes" : "no");135 fwprintf(stderr, L"srt_name=%s\n", opt-> srt_name);134 fwprintf(stderr, L"srt_given=%s\n", opt->libopt.output_given ? "yes" : "no"); 135 fwprintf(stderr, L"srt_name=%s\n", opt->libopt.output_name); 136 136 fwprintf(stderr, L"srt_colour=%s\n", opt->srt_colour ? "yes" : "no"); 137 137 fwprintf(stderr, L"vps_given=%s\n", opt->vps_given ? "yes" : "no"); … … 418 418 419 419 case 's': /* set srt device. */ 420 if (opt-> srt_given) {420 if (opt->libopt.output_given) { 421 421 fwprintf(stderr, L"%s: `--srt' (`-%c') option given more than once\n", 422 422 opt->libopt.program, c); 423 423 return 1; 424 424 } 425 opt-> srt_given = 1;426 opt-> srt_name = strdup(optarg);425 opt->libopt.output_given = 1; 426 opt->libopt.output_name = strdup(optarg); 427 427 break; 428 428 … … 442 442 443 443 case 'o': /* set video output device. */ 444 if (opt-> libopt.output_given) {444 if (opt->output_given) { 445 445 fwprintf(stderr, L"%s: `--output' (`-%c') option given more than once\n", 446 446 opt->libopt.program, c); 447 447 return 1; 448 448 } 449 opt-> libopt.output_given = 1;450 opt-> libopt.output_name = strdup(optarg);449 opt->output_given = 1; 450 opt->output_name = strdup(optarg); 451 451 break; 452 452 -
trunk/vbi2srt/args.h
r202 r214 42 42 char *vbi_name; /* vbi device. */ 43 43 int vbi; 44 int srt_given; /* Whether srt device was given. */ 45 char *srt_name; /* srt filename. */ 46 FILE *srt; 44 int output_given; /* Whether output device was given. */ 45 char *output_name; /* output filename. */ 46 FILE *output_fh; 47 //int srt_given; /* Whether srt device was given. */ 48 //char *srt_name; /* srt filename. */ 49 //FILE *srt; 47 50 int srt_colour; /* Whether to add colour codes to srt output. */ 48 51 int vps_given; /* Whether VPS was given. */ -
trunk/vbi2srt/main.c
r212 r214 81 81 if (signum == 15) { 82 82 if (opt.libopt.printverbose) { 83 fwprintf(stderr, L"termination_handler called with %d, ignored.\n", signum);83 vbiprintf(0, stderr, L"termination_handler called with %d, ignored.\n", signum); 84 84 } 85 85 return; … … 87 87 */ 88 88 if (opt.libopt.printverbose) { 89 fwprintf(stderr, L"termination_handler called with %d\n", signum);89 vbiprintf(0, stderr, L"termination_handler called with %d\n", signum); 90 90 } 91 91 terminate = 1; … … 97 97 ssize_t bytes_read; 98 98 ssize_t bytes_written; 99 fwprintf(stderr, L"verbose=%d\n", wd->opt->libopt.printverbose);100 fwprintf(stderr, L"mpeg_worker thread started\n");99 vbiprintf(0, stderr, L"verbose=%d\n", wd->opt->libopt.printverbose); 100 vbiprintf(0, stderr, L"mpeg_worker thread started\n"); 101 101 // wait for the streaming signal 102 102 while (!wd->streaming) { 103 103 if (terminate) { 104 fwprintf(stderr, L"mpeg_worker thread terminated not streaming\n");104 vbiprintf(0, stderr, L"mpeg_worker thread terminated not streaming\n"); 105 105 goto finished; 106 106 } 107 107 usleep(MPEG_DELAY); 108 108 } 109 fwprintf(stderr, L"mpeg_worker started recording\n");109 vbiprintf(0, stderr, L"mpeg_worker started recording\n"); 110 110 for (;;) { 111 111 if (terminate) { … … 114 114 enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 115 115 if (ioctl(wd->opt->input, VIDIOC_STREAMOFF, &buf_type) < 0) { 116 fwprintf(stderr, L"VIDIOC_STREAMOFF failed: %s\n", strerror(errno));116 vbiprintf(0, stderr, L"VIDIOC_STREAMOFF failed: %s\n", strerror(errno)); 117 117 break; 118 118 } … … 121 121 struct v4l2_encoder_cmd encoder_cmd = { V4L2_ENC_CMD_STOP, V4L2_ENC_CMD_STOP_AT_GOP_END }; 122 122 if (ioctl(opt.input, VIDIOC_ENCODER_CMD, &encoder_cmd) != 0) { 123 fwprintf(stderr, L"cannot set VIDIOC_ENCODER_CMD for \"%s\": %s\n",123 vbiprintf(0, stderr, L"cannot set VIDIOC_ENCODER_CMD for \"%s\": %s\n", 124 124 opt.libopt.input_name, strerror(errno)); 125 125 } 126 126 #endif 127 127 if (wd->opt->libopt.printverbose == 3) { 128 fwprintf(stderr, L"\n");129 } 130 fwprintf(stderr, L"mpeg_worker thread streaming off\n");128 vbiprintf(0, stderr, L"\n"); 129 } 130 vbiprintf(0, stderr, L"mpeg_worker thread streaming off\n"); 131 131 wd->streaming = 0; 132 132 } … … 134 134 bytes_read = read(wd->opt->input, wd->video_buffer, wd->video_buffer_size); 135 135 if (wd->opt->libopt.printverbose >= 4) { 136 fwprintf(stderr, L"bytes_read=%d, video_buffer_size=%d\n", bytes_read, wd->video_buffer_size);136 vbiprintf(0, stderr, L"bytes_read=%d, video_buffer_size=%d\n", bytes_read, wd->video_buffer_size); 137 137 } 138 138 if (bytes_read == 0) { 139 fwprintf(stderr, L"mpeg_worker thread terminated no more data\n");139 vbiprintf(0, stderr, L"mpeg_worker thread terminated no more data\n"); 140 140 break; 141 141 } else if (bytes_read < 0) { 142 fwprintf(stderr, L"mpeg_worker thread terminated data read error\n");143 fwprintf(stderr, L"cannot read from \"%s\" %s\n", wd->opt->libopt.input_name, strerror(errno));142 vbiprintf(0, stderr, L"mpeg_worker thread terminated data read error\n"); 143 vbiprintf(0, stderr, L"cannot read from \"%s\" %s\n", wd->opt->libopt.input_name, strerror(errno)); 144 144 break; 145 145 } 146 146 bytes_written = write(wd->opt->output, wd->video_buffer, bytes_read); 147 if (wd->opt->libopt.printverbose >= 4) {148 fwprintf(stderr, L"bytes_written=%d, bytes_read=%d\n", bytes_written, bytes_read);149 } 150 if (wd->opt->libopt.printverbose == 3) {151 fwprintf(stderr, L"%c", wd->streaming ? ',' : '.');147 if (wd->opt->libopt.printverbose >= 5) { 148 vbiprintf(0, stderr, L"bytes_written=%d, bytes_read=%d\n", bytes_written, bytes_read); 149 } 150 if (wd->opt->libopt.printverbose == 4) { 151 vbiprintf(0, stderr, L"%c", wd->streaming ? ',' : '.'); 152 152 } 153 153 fflush(stderr); 154 154 } 155 fwprintf(stderr, L"mpeg_worker stopped recording\n");155 vbiprintf(0, stderr, L"mpeg_worker stopped recording\n"); 156 156 finished: 157 157 if (wd->opt->libopt.printverbose == 3) { 158 fwprintf(stderr, L"\n");159 } 160 fwprintf(stderr, L"mpeg_worker thread finished\n");158 vbiprintf(0, stderr, L"\n"); 159 } 160 vbiprintf(0, stderr, L"mpeg_worker thread finished\n"); 161 161 fflush(stderr); 162 162 return NULL; … … 166 166 { 167 167 if (opt.libopt.printverbose) { 168 fwprintf(stderr, L"vbi_worker thread started\n");168 vbiprintf(0, stderr, L"vbi_worker thread started\n"); 169 169 } 170 170 for (;;) { … … 175 175 } 176 176 if (opt.libopt.printverbose) { 177 fwprintf(stderr, L"vbi_worker thread finished\n");177 vbiprintf(0, stderr, L"vbi_worker thread finished\n"); 178 178 } 179 179 … … 242 242 break; 243 243 } 244 fwprintf(stderr, L"%s\n", env[i]);244 vbiprintf(0, stderr, L"%s\n", env[i]); 245 245 } 246 246 } 247 247 248 248 if (opt.libopt.printverbose) { 249 fwprintf(stderr, L"Version is \"%s-%s\"\n", opt.libopt.program, opt.libopt.version);250 fwprintf(stderr, L"locale is \"%s\", codeset is \"%s\"\n", opt.libopt.locale, nl_langinfo(CODESET));251 fwprintf(stderr, L"\n");249 vbiprintf(0, stderr, L"Version is \"%s-%s\"\n", opt.libopt.program, opt.libopt.version); 250 vbiprintf(0, stderr, L"locale is \"%s\", codeset is \"%s\"\n", opt.libopt.locale, nl_langinfo(CODESET)); 251 vbiprintf(0, stderr, L"\n"); 252 252 } 253 253 254 254 // Some signal handlers to terminate cleanly 255 255 if (signal (SIGINT, termination_handler) == SIG_IGN) { 256 fwprintf(stderr, L"cannot set signal handler \"%s\": %s\n", "SIGINT", strerror(errno));256 vbiprintf(0, stderr, L"cannot set signal handler \"%s\": %s\n", "SIGINT", strerror(errno)); 257 257 signal (SIGINT, SIG_IGN); 258 258 } 259 259 if (signal (SIGHUP, termination_handler) == SIG_IGN) { 260 fwprintf(stderr, L"cannot set signal handler \"%s\": %s\n", "SIGHUP", strerror(errno));260 vbiprintf(0, stderr, L"cannot set signal handler \"%s\": %s\n", "SIGHUP", strerror(errno)); 261 261 signal (SIGHUP, SIG_IGN); 262 262 } 263 263 if (signal (SIGTERM, termination_handler) == SIG_IGN) { 264 fwprintf(stderr, L"cannot set signal handler \"%s\": %s\n", "SIGTERM", strerror(errno));264 vbiprintf(0, stderr, L"cannot set signal handler \"%s\": %s\n", "SIGTERM", strerror(errno)); 265 265 signal (SIGTERM, SIG_IGN); 266 266 } … … 268 268 opt.input = open(opt.libopt.input_name, O_RDONLY|O_LARGEFILE); 269 269 if (opt.input == -1) { 270 fwprintf(stderr, L"cannot open \"%s\": %s\n", opt.libopt.input_name, strerror(errno));270 vbiprintf(0, stderr, L"cannot open \"%s\": %s\n", opt.libopt.input_name, strerror(errno)); 271 271 return 1; 272 272 } 273 273 if (fstat64(opt.input, &status) == -1) { 274 fwprintf(stderr, L"cannot stat \"%s\": %s\n", opt.libopt.input_name, strerror(errno));274 vbiprintf(0, stderr, L"cannot stat \"%s\": %s\n", opt.libopt.input_name, strerror(errno)); 275 275 return 1; 276 276 } … … 280 280 int end_gop = 1; 281 281 if (ioctl(opt.input, IVTV_IOC_S_GOP_END, &end_gop) != 0) { 282 fwprintf(stderr, L"cannot set IVTV_IOC_S_GOP_END for \"%s\": %s\n",282 vbiprintf(0, stderr, L"cannot set IVTV_IOC_S_GOP_END for \"%s\": %s\n", 283 283 opt.libopt.input_name, strerror(errno)); 284 284 } … … 298 298 v4l2_format.fmt.sliced.reserved[1] = 0; 299 299 if (ioctl(opt.input, VIDIOC_S_FMT, &v4l2_format) < 0) { 300 // fwprintf(stderr, L"VIDIOC_S_FMT failed: \"%s\" %d\n", strerror(errno), errno);301 fwprintf(stderr, L"ioctl(%d, VIDIOC_S_FMT, v4l2_format): %s\n", opt.input, strerror(errno));300 //vbiprintf(0, stderr, L"VIDIOC_S_FMT failed: \"%s\" %d\n", strerror(errno), errno); 301 vbiprintf(0, stderr, L"ioctl(%d, VIDIOC_S_FMT, v4l2_format): %s\n", opt.input, strerror(errno)); 302 302 } 303 303 memset(&v4l2_format, 0, sizeof(v4l2_format)); 304 304 v4l2_format.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 305 305 if (ioctl(opt.input, VIDIOC_G_FMT, &v4l2_format) < 0) { 306 fwprintf(stderr, L"ioctl(%d, VIDIOC_G_FMT, v4l2_format): %s\n", opt.input, strerror(errno));307 } 308 fwprintf(stderr, L"v4l2_format: 0x%0X\n", v4l2_format.fmt.sliced.service_set);306 vbiprintf(0, stderr, L"ioctl(%d, VIDIOC_G_FMT, v4l2_format): %s\n", opt.input, strerror(errno)); 307 } 308 vbiprintf(0, stderr, L"v4l2_format: 0x%0X\n", v4l2_format.fmt.sliced.service_set); 309 309 310 310 struct v4l2_queryctrl qctrl; 311 311 const char *name = "Stream VBI Format"; 312 312 int ctrl_id = find_control_id(opt.input, name, &qctrl); 313 fwprintf(stderr, L"0x%08X is the id for \"%s\"\n", ctrl_id, name);313 vbiprintf(0, stderr, L"0x%08X is the id for \"%s\"\n", ctrl_id, name); 314 314 315 315 struct v4l2_ext_controls ext_controls; … … 323 323 324 324 if (ioctl(opt.input, VIDIOC_G_EXT_CTRLS, &ext_controls) < 0) { 325 fwprintf(stderr, L"ioctl(%d, VIDIOC_G_EXT_CTRLS, ext_controls): %s\n", opt.input, strerror(errno));325 vbiprintf(0, stderr, L"ioctl(%d, VIDIOC_G_EXT_CTRLS, ext_controls): %s\n", opt.input, strerror(errno)); 326 326 return 2; 327 327 } … … 329 329 switch (qctrl.type) { 330 330 case V4L2_CTRL_TYPE_INTEGER: 331 fwprintf(stderr, L"%s (int): min=%d max=%d step=%d default=%d value=%d", name,331 vbiprintf(0, stderr, L"%s (int): min=%d max=%d step=%d default=%d value=%d", name, 332 332 qctrl.minimum, qctrl.maximum, qctrl.step, qctrl.default_value, ext_control[0].value); 333 333 break; 334 334 case V4L2_CTRL_TYPE_INTEGER64: 335 fwprintf(stderr, L"%s (int64): value=%lld", name, ext_control[0].value64);335 vbiprintf(0, stderr, L"%s (int64): value=%lld", name, ext_control[0].value64); 336 336 break; 337 337 case V4L2_CTRL_TYPE_BOOLEAN: 338 fwprintf(stderr, L"%s (bool): default=%d value=%d", name, qctrl.default_value, ext_control[0].value);338 vbiprintf(0, stderr, L"%s (bool): default=%d value=%d", name, qctrl.default_value, ext_control[0].value); 339 339 break; 340 340 case V4L2_CTRL_TYPE_MENU: 341 fwprintf(stderr, L"%s (menu): min=%d max=%d default=%d value=%d", name,341 vbiprintf(0, stderr, L"%s (menu): min=%d max=%d default=%d value=%d", name, 342 342 qctrl.minimum, qctrl.maximum, qctrl.default_value, ext_control[0].value); 343 343 break; 344 344 case V4L2_CTRL_TYPE_BUTTON: 345 fwprintf(stderr, L"%s (button)\n", name);345 vbiprintf(0, stderr, L"%s (button)\n", name); 346 346 break; 347 347 default: 348 348 break; 349 349 } 350 fwprintf(stderr, L"%s (int): min=%d max=%d step=%d default=%d value=%d", name,350 vbiprintf(0, stderr, L"%s (int): min=%d max=%d step=%d default=%d value=%d", name, 351 351 qctrl.minimum, qctrl.maximum, qctrl.step, qctrl.default_value, ext_control[0].value); 352 352 } 353 353 if (opt.libopt.pagenum) { 354 fwprintf(stderr, L"pagenum=%d\n", opt.libopt.pagenum);354 vbiprintf(0, stderr, L"pagenum=%d\n", opt.libopt.pagenum); 355 355 ext_control[0].value = 1; 356 356 if (ioctl(opt.input, VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { 357 fwprintf(stderr, L"ioctl(%d, VIDIOC_S_EXT_CTRLS, ext_controls): %s\n", opt.input, strerror(errno));357 vbiprintf(0, stderr, L"ioctl(%d, VIDIOC_S_EXT_CTRLS, ext_controls): %s\n", opt.input, strerror(errno)); 358 358 return 2; 359 359 } … … 373 373 } 374 374 375 opt.output = open(opt. libopt.output_name, O_WRONLY|O_CREAT|O_LARGEFILE, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);375 opt.output = open(opt.output_name, O_WRONLY|O_CREAT|O_LARGEFILE, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); 376 376 if (opt.output == -1) { 377 fwprintf(stderr, L"cannot open \"%s\": %s\n", opt.libopt.output_name, strerror(errno));377 vbiprintf(0, stderr, L"cannot open \"%s\": %s\n", opt.output_name, strerror(errno)); 378 378 return 1; 379 379 } 380 380 if (fstat64(opt.output, &status) == -1) { 381 fwprintf(stderr, L"cannot stat \"%s\": %s\n", opt.libopt.output_name, strerror(errno));381 vbiprintf(0, stderr, L"cannot stat \"%s\": %s\n", opt.output_name, strerror(errno)); 382 382 return 1; 383 383 } … … 385 385 386 386 if (opt.input_isdevice && opt.output_isdevice) { 387 fwprintf(stderr, L"WARNING: \"%s\" and \"%s\" are devices.\n", opt.libopt.input_name, opt.libopt.output_name);387 vbiprintf(0, stderr, L"WARNING: \"%s\" and \"%s\" are devices.\n", opt.libopt.input_name, opt.libopt.output_name); 388 388 } 389 389 390 390 opt.vbi = open(opt.vbi_name, O_RDONLY|O_LARGEFILE|O_NONBLOCK); 391 391 if (opt.vbi == -1) { 392 fwprintf(stderr, L"cannot open \"%s\": %s\n", opt.vbi_name, strerror(errno));392 vbiprintf(0, stderr, L"cannot open \"%s\": %s\n", opt.vbi_name, strerror(errno)); 393 393 return 1; 394 394 } 395 395 if (fstat64(opt.vbi, &status) == -1) { 396 fwprintf(stderr, L"cannot stat \"%s\": %s\n", opt.vbi_name, strerror(errno));396 vbiprintf(0, stderr, L"cannot stat \"%s\": %s\n", opt.vbi_name, strerror(errno)); 397 397 return 1; 398 398 } 399 399 opt.vbi_isdevice = S_ISCHR(status.st_mode); 400 400 if (! opt.vbi_isdevice) { 401 fwprintf(stderr, L"\"%s\" is not a character device\n", opt.vbi_name);402 return 1; 403 } 404 405 406 if (! opt. srt_given) {401 vbiprintf(0, stderr, L"\"%s\" is not a character device\n", opt.vbi_name); 402 return 1; 403 } 404 405 406 if (! opt.libopt.output_given) { 407 407 if (opt.input_isdevice) { 408 408 int len = strlen(opt.libopt.output_name); 409 409 char *p = rindex(basename(opt.libopt.output_name), '.'); 410 opt. srt_name = malloc(len+5);411 if (opt. srt_name == 0) {410 opt.libopt.output_name = malloc(len+5); 411 if (opt.libopt.output_name == 0) { 412 412 return 1; 413 413 } … … 415 415 len = p - opt.libopt.output_name; 416 416 } 417 strcpy(&opt. srt_name[0], opt.libopt.output_name);418 strcpy(&opt. srt_name[len], ".srt");417 strcpy(&opt.libopt.output_name[0], opt.output_name); 418 strcpy(&opt.libopt.output_name[len], ".srt"); 419 419 } else { 420 420 int len = strlen(opt.libopt.input_name); 421 421 char *p = rindex(basename(opt.libopt.input_name), '.'); 422 opt. srt_name = malloc(len+5);423 if (opt. srt_name == 0) {422 opt.libopt.output_name = malloc(len+5); 423 if (opt.libopt.output_name == 0) { 424 424 return 1; 425 425 } … … 427 427 len = p - opt.libopt.input_name; 428 428 } 429 strcpy(&opt. srt_name[0], opt.libopt.input_name);430 strcpy(&opt. srt_name[len], ".srt");429 strcpy(&opt.libopt.output_name[0], opt.libopt.input_name); 430 strcpy(&opt.libopt.output_name[len], ".srt"); 431 431 } 432 432 } 433 433 434 434 if (opt.libopt.pagenum) { 435 opt. srt = fopen(opt.srt_name, "w");436 if (opt. srt_name == NULL) {437 fwprintf(stderr, L"cannot open srt \"%s\": %s\n", opt.srt_name, strerror(errno));435 opt.libopt.output = fopen(opt.libopt.output_name, "w"); 436 if (opt.libopt.output_name == NULL) { 437 vbiprintf(0, stderr, L"cannot open srt \"%s\": %s\n", opt.libopt.output_name, strerror(errno)); 438 438 return 1; 439 439 } 440 if (fstat64(fileno(opt. srt), &status) == -1) {441 fwprintf(stderr, L"cannot stat \"%s\": %s\n", opt.srt_name, strerror(errno));440 if (fstat64(fileno(opt.libopt.output), &status) == -1) { 441 vbiprintf(0, stderr, L"cannot stat \"%s\": %s\n", opt.libopt.output_name, strerror(errno)); 442 442 return 1; 443 443 } 444 444 opt.srt_isdevice = S_ISCHR(status.st_mode); 445 445 if (opt.srt_isdevice) { 446 fwprintf(stderr, L"\"%s\" is a character device\n", opt.srt_name);446 vbiprintf(0, stderr, L"\"%s\" is a character device\n", opt.libopt.output_name); 447 447 return 1; 448 448 } … … 455 455 if (! opt.libopt.utf8) { 456 456 if (opt.libopt.pagenum) { 457 fwprintf(stderr, L"WARNING: Subtitles will contain unicode characters but locale is \"%s\"\n",457 vbiprintf(0, stderr, L"WARNING: Subtitles will contain unicode characters but locale is \"%s\"\n", 458 458 opt.libopt.locale); 459 459 } … … 470 470 vbidata.fmt.fmt.sliced.reserved[1] = 0; 471 471 if (ioctl(opt.vbi, VIDIOC_S_FMT, &vbidata.fmt) < 0) { 472 fwprintf(stderr, L"VIDIOC_S_FMT failed: \"%s\" %d\n", strerror(errno), errno);472 vbiprintf(0, stderr, L"VIDIOC_S_FMT failed: \"%s\" %d\n", strerror(errno), errno); 473 473 close(opt.vbi); 474 474 return 1; … … 476 476 477 477 if (opt.libopt.printverbose >= 4) { 478 fwprintf(stderr, L"service_set=%08x, io_size=%d\n",478 vbiprintf(0, stderr, L"service_set=%08x, io_size=%d\n", 479 479 vbidata.fmt.fmt.sliced.service_set, vbidata.fmt.fmt.sliced.io_size); 480 fwprintf(stderr, L"\n");480 vbiprintf(0, stderr, L"\n"); 481 481 } 482 482 … … 484 484 485 485 if (clock_gettime (CLOCK_REALTIME, &now) != 0) { 486 fwprintf(stderr, L"clock_gettime failed: \"%s\" %d\n", strerror(errno), errno);486 vbiprintf(0, stderr, L"clock_gettime failed: \"%s\" %d\n", strerror(errno), errno); 487 487 } 488 488 vps_pat_watchdog(&now); … … 494 494 if (pthread_create (&mpeg_worker_thread, NULL, mpeg_worker, (void *)&mpegdata) != 0) { 495 495 perror("mpeg_worker_thread"); 496 fwprintf(stderr, L"Failed to create mpeg worker thread \"%s\"\n", strerror(errno));496 vbiprintf(0, stderr, L"Failed to create mpeg worker thread \"%s\"\n", strerror(errno)); 497 497 return 1; 498 498 } … … 500 500 if (pthread_create (&vbi_worker_thread, NULL, vbi_worker, (void *)&vbidata) != 0) { 501 501 perror("vbi_worker_thread"); 502 fwprintf(stderr, L"Failed to create vbi worker thread \"%s\"\n", strerror(errno));502 vbiprintf(0, stderr, L"Failed to create vbi worker thread \"%s\"\n", strerror(errno)); 503 503 return 1; 504 504 } … … 508 508 subtitles_init(&opt, &now); 509 509 } 510 511 if (clock_gettime (CLOCK_REALTIME, &now) != 0) { 512 vbiprintf(0, stderr, L"clock_gettime failed: \"%s\" %d\n", strerror(errno), errno); 513 } 514 prev_t.now = now; 515 prev_t.fno = frames; 510 516 511 517 for (;;) { … … 517 523 pthread_join (vbi_worker_thread, NULL); 518 524 pthread_join (mpeg_worker_thread, NULL); 519 fwprintf(stderr, L"terminated\n");525 vbiprintf(0, stderr, L"terminated\n"); 520 526 break; 521 527 } 522 528 523 529 if (clock_gettime (CLOCK_REALTIME, &now) != 0) { 524 fwprintf(stderr, L"clock_gettime failed: \"%s\" %d\n", strerror(errno), errno); 525 } 526 527 if (clock_gettime (CLOCK_REALTIME, &now) != 0) { 528 fwprintf(stderr, L"clock_gettime failed: \"%s\" %d\n", strerror(errno), errno); 530 vbiprintf(0, stderr, L"clock_gettime failed: \"%s\" %d\n", strerror(errno), errno); 529 531 } 530 532 this_t.now = now; … … 534 536 if (opt.libopt.printverbose >= 4) { 535 537 if (vbi_bytes_read >= 0) { 536 fwprintf(stderr, L"vbi_bytes_read=%d\n", vbi_bytes_read);538 vbiprintf(0, stderr, L"vbi_bytes_read=%d\n", vbi_bytes_read); 537 539 } 538 540 } … … 559 561 if (opt.libopt.printverbose) { 560 562 vps_time(&now); 561 fwprintf(stderr, L"vps state %s->%s\n", vps_state_name(laststate), vps_state_name(state));563 vbiprintf(0, stderr, L"vps state %s->%s\n", vps_state_name(laststate), vps_state_name(state)); 562 564
