Mercurial > mplayer.hg
comparison libmpdemux/tvi_v4l.c @ 2818:9f68d309f8cb
printf's changed into mp_msg
author | alex |
---|---|
date | Sun, 11 Nov 2001 03:40:16 +0000 |
parents | 37fc45a05082 |
children | 2e58962dc9fe |
comparison
equal
deleted
inserted
replaced
2817:cc93d9786954 | 2818:9f68d309f8cb |
---|---|
190 }; | 190 }; |
191 #endif | 191 #endif |
192 | 192 |
193 static int one = 1, zero = 0; | 193 static int one = 1, zero = 0; |
194 | 194 |
195 static int alarms; | |
196 | |
197 static void sigalarm(int signal) | |
198 { | |
199 alarms++; | |
200 printf("v4l: timeout (got SIGALRM), hardware/driver problems?\n"); | |
201 } | |
202 | |
203 static void siginit(void) | |
204 { | |
205 struct sigaction act, old; | |
206 | |
207 memset(&act, 0, sizeof(act)); | |
208 act.sa_handler = sigalarm; | |
209 sigemptyset(&act.sa_mask); | |
210 sigaction(SIGALRM, &act, &old); | |
211 } | |
212 | |
213 tvi_handle_t *tvi_init_v4l(char *device) | 195 tvi_handle_t *tvi_init_v4l(char *device) |
214 { | 196 { |
215 tvi_handle_t *h; | 197 tvi_handle_t *h; |
216 priv_t *priv; | 198 priv_t *priv; |
217 | 199 |
241 int i; | 223 int i; |
242 | 224 |
243 priv->fd = open(priv->video_device, O_RDWR); | 225 priv->fd = open(priv->video_device, O_RDWR); |
244 if (priv->fd == -1) | 226 if (priv->fd == -1) |
245 { | 227 { |
246 printf("v4l: unable to open '%s': %s\n", | 228 mp_msg(MSGT_TV, MSGL_ERR, "unable to open '%s': %s\n", |
247 priv->video_device, strerror(errno)); | 229 priv->video_device, strerror(errno)); |
248 goto err; | 230 goto err; |
249 } | 231 } |
250 | 232 |
251 printf("fd: %d\n", priv->fd); | 233 mp_msg(MSGT_TV, MSGL_V, "Video fd: %d\n", priv->fd); |
252 | 234 |
253 /* get capabilities (priv->capability is needed!) */ | 235 /* get capabilities (priv->capability is needed!) */ |
254 if (ioctl(priv->fd, VIDIOCGCAP, &priv->capability) == -1) | 236 if (ioctl(priv->fd, VIDIOCGCAP, &priv->capability) == -1) |
255 { | 237 { |
256 printf("ioctl get capabilites error: %s\n", strerror(errno)); | 238 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get capabilites failed: %s\n", strerror(errno)); |
257 goto err; | 239 goto err; |
258 } | 240 } |
259 | 241 |
260 fcntl(priv->fd, F_SETFD, FD_CLOEXEC); | 242 fcntl(priv->fd, F_SETFD, FD_CLOEXEC); |
261 siginit(); | 243 // siginit(); |
262 | 244 |
263 #if 0 | 245 #if 0 |
264 for (i=0; params[i].opt; i++) | 246 for (i=0; params[i].opt; i++) |
265 { | 247 { |
266 if (!strcmp(params[i].opt, "input")) | 248 if (!strcmp(params[i].opt, "input")) |
267 priv->input = (int)*(void **)params[i].value; | 249 priv->input = (int)*(void **)params[i].value; |
268 } | 250 } |
269 printf("priv->input: %d\n", priv->input); | 251 printf("priv->input: %d\n", priv->input); |
270 #endif | 252 #endif |
271 | 253 |
272 printf("Selected device: %s\n", priv->capability.name); | 254 mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.name); |
273 printf(" Capabilites: "); | 255 mp_msg(MSGT_TV, MSGL_INFO, " Capabilites: "); |
274 for (i = 0; device_cap[i] != NULL; i++) | 256 for (i = 0; device_cap[i] != NULL; i++) |
275 if (priv->capability.type & (1 << i)) | 257 if (priv->capability.type & (1 << i)) |
276 printf("%s ", device_cap[i]); | 258 mp_msg(MSGT_TV, MSGL_INFO, "%s ", device_cap[i]); |
277 printf("\n"); | 259 mp_msg(MSGT_TV, MSGL_INFO, "\n"); |
278 printf(" Device type: %d\n", priv->capability.type); | 260 mp_msg(MSGT_TV, MSGL_INFO, " Device type: %d\n", priv->capability.type); |
279 printf(" Supported sizes: %dx%d => %dx%d\n", | 261 mp_msg(MSGT_TV, MSGL_INFO, " Supported sizes: %dx%d => %dx%d\n", |
280 priv->capability.minwidth, priv->capability.minheight, | 262 priv->capability.minwidth, priv->capability.minheight, |
281 priv->capability.maxwidth, priv->capability.maxheight); | 263 priv->capability.maxwidth, priv->capability.maxheight); |
282 priv->width = priv->capability.minwidth; | 264 priv->width = priv->capability.minwidth; |
283 priv->height = priv->capability.minheight; | 265 priv->height = priv->capability.minheight; |
284 printf(" Inputs: %d\n", priv->capability.channels); | 266 mp_msg(MSGT_TV, MSGL_INFO, " Inputs: %d\n", priv->capability.channels); |
285 | 267 |
286 priv->channels = malloc(sizeof(struct video_channel)*priv->capability.channels); | 268 priv->channels = malloc(sizeof(struct video_channel)*priv->capability.channels); |
287 memset(priv->channels, 0, sizeof(struct video_channel)*priv->capability.channels); | 269 memset(priv->channels, 0, sizeof(struct video_channel)*priv->capability.channels); |
288 for (i = 0; i < priv->capability.channels; i++) | 270 for (i = 0; i < priv->capability.channels; i++) |
289 { | 271 { |
290 priv->channels[i].channel = i; | 272 priv->channels[i].channel = i; |
291 ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]); | 273 ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]); |
292 printf(" %d: %s: %s%s%s%s (tuner:%d, norm:%d)\n", i, | 274 mp_msg(MSGT_TV, MSGL_INFO, " %d: %s: %s%s%s%s (tuner:%d, norm:%d)\n", i, |
293 priv->channels[i].name, | 275 priv->channels[i].name, |
294 (priv->channels[i].flags & VIDEO_VC_TUNER) ? "tuner " : "", | 276 (priv->channels[i].flags & VIDEO_VC_TUNER) ? "tuner " : "", |
295 (priv->channels[i].flags & VIDEO_VC_AUDIO) ? "audio " : "", | 277 (priv->channels[i].flags & VIDEO_VC_AUDIO) ? "audio " : "", |
296 (priv->channels[i].flags & VIDEO_TYPE_TV) ? "tv " : "", | 278 (priv->channels[i].flags & VIDEO_TYPE_TV) ? "tv " : "", |
297 (priv->channels[i].flags & VIDEO_TYPE_CAMERA) ? "camera " : "", | 279 (priv->channels[i].flags & VIDEO_TYPE_CAMERA) ? "camera " : "", |
299 priv->channels[i].norm); | 281 priv->channels[i].norm); |
300 } | 282 } |
301 | 283 |
302 if (!(priv->capability.type & VID_TYPE_CAPTURE)) | 284 if (!(priv->capability.type & VID_TYPE_CAPTURE)) |
303 { | 285 { |
304 printf("Only grabbing supported (for overlay use another program)\n"); | 286 mp_msg(MSGT_TV, MSGL_ERR, "Only grabbing supported (for overlay use another program)\n"); |
305 goto err; | 287 goto err; |
306 } | 288 } |
307 | 289 |
308 /* map grab buffer */ | 290 /* map grab buffer */ |
309 if (ioctl(priv->fd, VIDIOCGMBUF, &priv->mbuf) == -1) | 291 if (ioctl(priv->fd, VIDIOCGMBUF, &priv->mbuf) == -1) |
310 { | 292 { |
311 printf("ioctl get mbuf failed: %s\n", strerror(errno)); | 293 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno)); |
312 goto err; | 294 goto err; |
313 } | 295 } |
314 | 296 |
315 printf("mbuf: size=%d, frames=%d\n", | 297 mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n", |
316 priv->mbuf.size, priv->mbuf.frames); | 298 priv->mbuf.size, priv->mbuf.frames); |
317 priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE, | 299 priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE, |
318 MAP_SHARED, priv->fd, 0); | 300 MAP_SHARED, priv->fd, 0); |
319 if (priv->mmap == -1) | 301 if (priv->mmap == -1) |
320 { | 302 { |
321 printf("Unabel to map memory for buffers: %s\n", strerror(errno)); | 303 mp_msg(MSGT_TV, MSGL_ERR, "Unabel to map memory for buffers: %s\n", strerror(errno)); |
322 goto err; | 304 goto err; |
323 } | 305 } |
324 printf("our buffer: %p\n", priv->mmap); | 306 mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap); |
325 | 307 |
326 /* num of buffers */ | 308 /* num of buffers */ |
327 priv->nbuf = priv->mbuf.frames; | 309 priv->nbuf = priv->mbuf.frames; |
328 | 310 |
329 /* video buffers */ | 311 /* video buffers */ |
348 int i; | 330 int i; |
349 | 331 |
350 | 332 |
351 if (ioctl(priv->fd, VIDIOCGPICT, &priv->picture) == -1) | 333 if (ioctl(priv->fd, VIDIOCGPICT, &priv->picture) == -1) |
352 { | 334 { |
353 printf("ioctl get picture failed: %s\n", strerror(errno)); | 335 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno)); |
354 return(0); | 336 return(0); |
355 } | 337 } |
356 | 338 |
357 priv->picture.palette = format2palette(priv->format); | 339 priv->picture.palette = format2palette(priv->format); |
358 priv->picture.depth = palette2depth(priv->picture.palette); | 340 priv->picture.depth = palette2depth(priv->picture.palette); |
359 priv->bytesperline = priv->width * priv->picture.depth / 8; | 341 priv->bytesperline = priv->width * priv->picture.depth / 8; |
360 | 342 |
361 printf("Picture values:\n"); | 343 mp_msg(MSGT_TV, MSGL_INFO, "Picture values:\n"); |
362 printf(" Depth: %d, Palette: %d (Format: %s)\n", priv->picture.depth, | 344 mp_msg(MSGT_TV, MSGL_INFO, " Depth: %d, Palette: %d (Format: %s)\n", priv->picture.depth, |
363 priv->picture.palette, vo_format_name(priv->format)); | 345 priv->picture.palette, vo_format_name(priv->format)); |
364 printf(" Brightness: %d, Hue: %d, Colour: %d, Contrast: %d\n", | 346 mp_msg(MSGT_TV, MSGL_INFO, " Brightness: %d, Hue: %d, Colour: %d, Contrast: %d\n", |
365 priv->picture.brightness, priv->picture.hue, | 347 priv->picture.brightness, priv->picture.hue, |
366 priv->picture.colour, priv->picture.contrast); | 348 priv->picture.colour, priv->picture.contrast); |
367 | 349 |
368 | 350 |
369 if (ioctl(priv->fd, VIDIOCSPICT, &priv->picture) == -1) | 351 if (ioctl(priv->fd, VIDIOCSPICT, &priv->picture) == -1) |
370 { | 352 { |
371 printf("ioctl set picture failed: %s\n", strerror(errno)); | 353 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno)); |
372 return(0); | 354 return(0); |
373 } | 355 } |
374 | 356 |
375 priv->nbuf = priv->mbuf.frames; | 357 priv->nbuf = priv->mbuf.frames; |
376 for (i=0; i < priv->nbuf; i++) | 358 for (i=0; i < priv->nbuf; i++) |
377 { | 359 { |
378 priv->buf[i].format = priv->picture.palette; | 360 priv->buf[i].format = priv->picture.palette; |
379 priv->buf[i].frame = i; | 361 priv->buf[i].frame = i; |
380 priv->buf[i].width = priv->width; | 362 priv->buf[i].width = priv->width; |
381 priv->buf[i].height = priv->height; | 363 priv->buf[i].height = priv->height; |
382 printf("buffer: %d => %p\n", i, &priv->buf[i]); | 364 mp_msg(MSGT_TV, MSGL_DBG2, "buffer: %d => %p\n", i, &priv->buf[i]); |
383 } | 365 } |
384 | 366 |
385 /* start capture */ | 367 /* start capture */ |
386 if (ioctl(priv->fd, VIDIOCCAPTURE, &one) == -1) | 368 if (ioctl(priv->fd, VIDIOCCAPTURE, &one) == -1) |
387 { | 369 { |
388 printf("ioctl capture failed: %s\n", strerror(errno)); | 370 mp_msg(MSGT_TV, MSGL_ERR, "ioctl capture failed: %s\n", strerror(errno)); |
389 return(0); | 371 return(0); |
390 } | 372 } |
391 } | 373 } |
392 | 374 |
393 static int control(priv_t *priv, int cmd, void *arg) | 375 static int control(priv_t *priv, int cmd, void *arg) |
394 { | 376 { |
395 printf("debug: control(priv=%p, cmd=%d, arg=%p)\n", | 377 mp_msg(MSGT_TV, MSGL_DBG2, "debug: control(priv=%p, cmd=%d, arg=%p)\n", |
396 priv, cmd, arg); | 378 priv, cmd, arg); |
397 switch(cmd) | 379 switch(cmd) |
398 { | 380 { |
399 /* ========== GENERIC controls =========== */ | 381 /* ========== GENERIC controls =========== */ |
400 case TVI_CONTROL_IS_VIDEO: | 382 case TVI_CONTROL_IS_VIDEO: |
437 break; | 419 break; |
438 case VIDEO_PALETTE_YUV420P: | 420 case VIDEO_PALETTE_YUV420P: |
439 output_fmt = IMGFMT_YV12; | 421 output_fmt = IMGFMT_YV12; |
440 break; | 422 break; |
441 default: | 423 default: |
442 printf("no suitable output format found (%s)\n", | 424 mp_msg(MSGT_TV, MSGL_ERR, "no suitable output format found (%s)\n", |
443 PALETTE(priv->palette)); | 425 PALETTE(priv->palette)); |
444 return(TVI_CONTROL_FALSE); | 426 return(TVI_CONTROL_FALSE); |
445 } | 427 } |
446 #endif | 428 #endif |
447 output_fmt = priv->format; | 429 output_fmt = priv->format; |
448 (int)*(void **)arg = output_fmt; | 430 (int)*(void **)arg = output_fmt; |
449 printf("Output format: %s\n", vo_format_name(output_fmt)); | 431 mp_msg(MSGT_TV, MSGL_INFO, "Output format: %s\n", vo_format_name(output_fmt)); |
450 return(TVI_CONTROL_TRUE); | 432 return(TVI_CONTROL_TRUE); |
451 } | 433 } |
452 case TVI_CONTROL_VID_SET_FORMAT: | 434 case TVI_CONTROL_VID_SET_FORMAT: |
453 priv->format = (int)*(void **)arg; | 435 priv->format = (int)*(void **)arg; |
454 return(TVI_CONTROL_TRUE); | 436 return(TVI_CONTROL_TRUE); |
463 return(TVI_CONTROL_TRUE); | 445 return(TVI_CONTROL_TRUE); |
464 case TVI_CONTROL_VID_CHK_WIDTH: | 446 case TVI_CONTROL_VID_CHK_WIDTH: |
465 { | 447 { |
466 int req_width = (int)*(void **)arg; | 448 int req_width = (int)*(void **)arg; |
467 | 449 |
468 printf("Requested width: %d\n", req_width); | 450 mp_msg(MSGT_TV, MSGL_INFO, "Requested width: %d\n", req_width); |
469 if ((req_width >= priv->capability.minwidth) && | 451 if ((req_width >= priv->capability.minwidth) && |
470 (req_width <= priv->capability.maxwidth)) | 452 (req_width <= priv->capability.maxwidth)) |
471 return(TVI_CONTROL_TRUE); | 453 return(TVI_CONTROL_TRUE); |
472 return(TVI_CONTROL_FALSE); | 454 return(TVI_CONTROL_FALSE); |
473 } | 455 } |
479 return(TVI_CONTROL_TRUE); | 461 return(TVI_CONTROL_TRUE); |
480 case TVI_CONTROL_VID_CHK_HEIGHT: | 462 case TVI_CONTROL_VID_CHK_HEIGHT: |
481 { | 463 { |
482 int req_height = (int)*(void **)arg; | 464 int req_height = (int)*(void **)arg; |
483 | 465 |
484 printf("Requested height: %d\n", req_height); | 466 mp_msg(MSGT_TV, MSGL_INFO, "Requested height: %d\n", req_height); |
485 if ((req_height >= priv->capability.minheight) && | 467 if ((req_height >= priv->capability.minheight) && |
486 (req_height <= priv->capability.maxheight)) | 468 (req_height <= priv->capability.maxheight)) |
487 return(TVI_CONTROL_TRUE); | 469 return(TVI_CONTROL_TRUE); |
488 return(TVI_CONTROL_FALSE); | 470 return(TVI_CONTROL_FALSE); |
489 } | 471 } |
496 { | 478 { |
497 unsigned long freq; | 479 unsigned long freq; |
498 | 480 |
499 if (ioctl(priv->fd, VIDIOCGFREQ, &freq) == -1) | 481 if (ioctl(priv->fd, VIDIOCGFREQ, &freq) == -1) |
500 { | 482 { |
501 printf("ioctl get freq failed: %s\n", strerror(errno)); | 483 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get freq failed: %s\n", strerror(errno)); |
502 return(TVI_CONTROL_FALSE); | 484 return(TVI_CONTROL_FALSE); |
503 } | 485 } |
504 | 486 |
505 /* tuner uses khz not mhz ! */ | 487 /* tuner uses khz not mhz ! */ |
506 if (priv->tuner.flags & VIDEO_TUNER_LOW) | 488 if (priv->tuner.flags & VIDEO_TUNER_LOW) |
511 case TVI_CONTROL_TUN_SET_FREQ: | 493 case TVI_CONTROL_TUN_SET_FREQ: |
512 { | 494 { |
513 /* argument is in MHz ! */ | 495 /* argument is in MHz ! */ |
514 unsigned long freq = (unsigned long)*(void **)arg; | 496 unsigned long freq = (unsigned long)*(void **)arg; |
515 | 497 |
516 printf("requested frequency: %lu MHz\n", (float)freq/16); | 498 mp_msg(MSGT_TV, MSGL_V, "requested frequency: %lu MHz\n", (float)freq/16); |
517 | 499 |
518 /* tuner uses khz not mhz ! */ | 500 /* tuner uses khz not mhz ! */ |
519 if (priv->tuner.flags & VIDEO_TUNER_LOW) | 501 if (priv->tuner.flags & VIDEO_TUNER_LOW) |
520 freq *= 1000; | 502 freq *= 1000; |
521 printf(" requesting from driver: freq=%.3f\n", (float)freq/16); | 503 mp_msg(MSGT_TV, MSGL_V, " requesting from driver: freq=%.3f\n", (float)freq/16); |
522 if (ioctl(priv->fd, VIDIOCSFREQ, &freq) == -1) | 504 if (ioctl(priv->fd, VIDIOCSFREQ, &freq) == -1) |
523 { | 505 { |
524 printf("ioctl set freq failed: %s\n", strerror(errno)); | 506 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set freq failed: %s\n", strerror(errno)); |
525 return(TVI_CONTROL_FALSE); | 507 return(TVI_CONTROL_FALSE); |
526 } | 508 } |
527 return(TVI_CONTROL_TRUE); | 509 return(TVI_CONTROL_TRUE); |
528 } | 510 } |
529 case TVI_CONTROL_TUN_GET_TUNER: | 511 case TVI_CONTROL_TUN_GET_TUNER: |
530 { | 512 { |
531 if (ioctl(priv->fd, VIDIOCGTUNER, &priv->tuner) == -1) | 513 if (ioctl(priv->fd, VIDIOCGTUNER, &priv->tuner) == -1) |
532 { | 514 { |
533 printf("ioctl get tuner failed: %s\n", strerror(errno)); | 515 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno)); |
534 return(TVI_CONTROL_FALSE); | 516 return(TVI_CONTROL_FALSE); |
535 } | 517 } |
536 | 518 |
537 printf("Tuner (%s) range: %lu -> %lu\n", priv->tuner.name, | 519 mp_msg(MSGT_TV, MSGL_INFO, "Tuner (%s) range: %lu -> %lu\n", priv->tuner.name, |
538 priv->tuner.rangelow, priv->tuner.rangehigh); | 520 priv->tuner.rangelow, priv->tuner.rangehigh); |
539 return(TVI_CONTROL_TRUE); | 521 return(TVI_CONTROL_TRUE); |
540 } | 522 } |
541 case TVI_CONTROL_TUN_SET_TUNER: | 523 case TVI_CONTROL_TUN_SET_TUNER: |
542 { | 524 { |
543 if (ioctl(priv->fd, VIDIOCSTUNER, &priv->tuner) == -1) | 525 if (ioctl(priv->fd, VIDIOCSTUNER, &priv->tuner) == -1) |
544 { | 526 { |
545 printf("ioctl get tuner failed: %s\n", strerror(errno)); | 527 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno)); |
546 return(TVI_CONTROL_FALSE); | 528 return(TVI_CONTROL_FALSE); |
547 } | 529 } |
548 return(TVI_CONTROL_TRUE); | 530 return(TVI_CONTROL_TRUE); |
549 } | 531 } |
550 case TVI_CONTROL_TUN_SET_NORM: | 532 case TVI_CONTROL_TUN_SET_NORM: |
554 if ((!(priv->tuner.flags & VIDEO_TUNER_NORM)) || | 536 if ((!(priv->tuner.flags & VIDEO_TUNER_NORM)) || |
555 ((req_mode == VIDEO_MODE_PAL) && !(priv->tuner.flags & VIDEO_TUNER_PAL)) || | 537 ((req_mode == VIDEO_MODE_PAL) && !(priv->tuner.flags & VIDEO_TUNER_PAL)) || |
556 ((req_mode == VIDEO_MODE_NTSC) && !(priv->tuner.flags & VIDEO_TUNER_NTSC)) || | 538 ((req_mode == VIDEO_MODE_NTSC) && !(priv->tuner.flags & VIDEO_TUNER_NTSC)) || |
557 ((req_mode == VIDEO_MODE_SECAM) && !(priv->tuner.flags & VIDEO_TUNER_SECAM))) | 539 ((req_mode == VIDEO_MODE_SECAM) && !(priv->tuner.flags & VIDEO_TUNER_SECAM))) |
558 { | 540 { |
559 printf("tuner isn't capable to set norm!\n"); | 541 mp_msg(MSGT_TV, MSGL_ERR, "Tuner isn't capable to set norm!\n"); |
560 return(TVI_CONTROL_FALSE); | 542 return(TVI_CONTROL_FALSE); |
561 } | 543 } |
562 | 544 |
563 priv->tuner.mode = req_mode; | 545 priv->tuner.mode = req_mode; |
564 | 546 |
607 break; | 589 break; |
608 } | 590 } |
609 | 591 |
610 if (ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]) == -1) | 592 if (ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]) == -1) |
611 { | 593 { |
612 printf("ioctl get channel failed: %s\n", strerror(errno)); | 594 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno)); |
613 return(TVI_CONTROL_FALSE); | 595 return(TVI_CONTROL_FALSE); |
614 } | 596 } |
615 return(TVI_CONTROL_TRUE); | 597 return(TVI_CONTROL_TRUE); |
616 } | 598 } |
617 | 599 |
621 int req_chan = (int)*(void **)arg; | 603 int req_chan = (int)*(void **)arg; |
622 int i; | 604 int i; |
623 | 605 |
624 if (req_chan >= priv->capability.channels) | 606 if (req_chan >= priv->capability.channels) |
625 { | 607 { |
626 printf("Invalid input requested: %d, valid: 0-%d\n", | 608 mp_msg(MSGT_TV, MSGL_ERR, "Invalid input requested: %d, valid: 0-%d\n", |
627 req_chan, priv->capability.channels); | 609 req_chan, priv->capability.channels); |
628 return(TVI_CONTROL_FALSE); | 610 return(TVI_CONTROL_FALSE); |
629 } | 611 } |
630 | 612 |
631 for (i = 0; i < priv->capability.channels; i++) | 613 for (i = 0; i < priv->capability.channels; i++) |
634 chan = priv->channels[i]; | 616 chan = priv->channels[i]; |
635 } | 617 } |
636 | 618 |
637 if (ioctl(priv->fd, VIDIOCSCHAN, &chan) == -1) | 619 if (ioctl(priv->fd, VIDIOCSCHAN, &chan) == -1) |
638 { | 620 { |
639 printf("ioctl set chan failed: %s\n", strerror(errno)); | 621 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno)); |
640 return(TVI_CONTROL_FALSE); | 622 return(TVI_CONTROL_FALSE); |
641 } | 623 } |
642 printf("Using input '%s'\n", chan.name); | 624 mp_msg(MSGT_TV, MSGL_INFO, "Using input '%s'\n", chan.name); |
643 | 625 |
644 /* update tuner state */ | 626 /* update tuner state */ |
645 if (priv->capability.type & VID_TYPE_TUNER) | 627 if (priv->capability.type & VID_TYPE_TUNER) |
646 control(priv, TVI_CONTROL_TUN_GET_TUNER, 0); | 628 control(priv, TVI_CONTROL_TUN_GET_TUNER, 0); |
647 | 629 |
657 static int grab_video_frame(priv_t *priv, char *buffer, int len) | 639 static int grab_video_frame(priv_t *priv, char *buffer, int len) |
658 { | 640 { |
659 int frame = priv->queue % priv->nbuf; | 641 int frame = priv->queue % priv->nbuf; |
660 int nextframe = (priv->queue+1) % priv->nbuf; | 642 int nextframe = (priv->queue+1) % priv->nbuf; |
661 | 643 |
662 printf("grab_video_frame(priv=%p, buffer=%p, len=%d\n", | 644 mp_msg(MSGT_TV, MSGL_DBG2, "grab_video_frame(priv=%p, buffer=%p, len=%d\n", |
663 priv, buffer, len); | 645 priv, buffer, len); |
664 | 646 |
665 printf("buf: %p + frame: %d => %p\n", | 647 mp_msg(MSGT_TV, MSGL_DBG3, "buf: %p + frame: %d => %p\n", |
666 priv->buf, nextframe, &priv->buf[nextframe]); | 648 priv->buf, nextframe, &priv->buf[nextframe]); |
667 if (ioctl(priv->fd, VIDIOCMCAPTURE, &priv->buf[nextframe]) == -1) | 649 if (ioctl(priv->fd, VIDIOCMCAPTURE, &priv->buf[nextframe]) == -1) |
668 { | 650 { |
669 printf("ioctl mcapture failed: %s\n", strerror(errno)); | 651 mp_msg(MSGT_TV, MSGL_ERR, "ioctl mcapture failed: %s\n", strerror(errno)); |
670 return(0); | 652 return(0); |
671 } | 653 } |
672 | 654 |
673 if (ioctl(priv->fd, VIDIOCSYNC, &priv->buf[frame].frame) == -1) | 655 if (ioctl(priv->fd, VIDIOCSYNC, &priv->buf[frame].frame) == -1) |
674 printf("ioctl sync failed: %s\n", strerror(errno)); | 656 mp_msg(MSGT_TV, MSGL_ERR, "ioctl sync failed: %s\n", strerror(errno)); |
675 priv->queue++; | 657 priv->queue++; |
676 | 658 |
677 printf("mmap: %p + offset: %d => %p\n", | 659 mp_msg(MSGT_TV, MSGL_DBG3, "mmap: %p + offset: %d => %p\n", |
678 priv->mmap, priv->mbuf.offsets[frame], | 660 priv->mmap, priv->mbuf.offsets[frame], |
679 priv->mmap+priv->mbuf.offsets[frame]); | 661 priv->mmap+priv->mbuf.offsets[frame]); |
680 memcpy(buffer, priv->mmap+priv->mbuf.offsets[frame], len); | 662 memcpy(buffer, priv->mmap+priv->mbuf.offsets[frame], len); |
681 | 663 |
682 return(len); | 664 return(len); |