Changeset 7f4aba6183dab7a43b2d87ce8b73383aa5d79aa0
- Timestamp:
- 01/01/08 15:54:42 (6 months ago)
- git-parent:
- Files:
-
- THANKS (modified) (1 diff)
- modules/access/v4l2.c (modified) (44 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
THANKS
r7b08761 r7f4aba6 67 67 Davor Orel <syntheticamac at yahoo.it> - Mac OS X icons 68 68 Dennis van Amerongen <Dennis dot vanAmerongen at nob dot nl> - x264 options unification 69 Dennis Lou <dlou99 at yahoo dot com> - ATSC support in the DVB module 69 Dennis Lou <dlou99 at yahoo dot com> - ATSC support in the DVB module, MPEG2 support in the v4l2 module 70 70 Dermot McGahon <dermot at dspsrv dot com> - Bug fixes, RC interface loop and repeat 71 71 Diego Petteno <flameeyes at gentoo dot org> - remove usage of internal ffmpeg symbols, configure fixes modules/access/v4l2.c
r7778719 r7f4aba6 7 7 * Authors: Benjamin Pracht <bigben at videolan dot org> 8 8 * Richard Hosking <richard at hovis dot net> 9 * Antoine Cellerier <dionoea at videolan d.t net> 9 * Antoine Cellerier <dionoea at videolan d.t org> 10 * Dennis Lou <dlou99 at yahoo dot com> 10 11 * 11 12 * This program is free software; you can redistribute it and/or modify … … 108 109 #define BRIGHTNESS_TEXT N_( "Brightness" ) 109 110 #define BRIGHTNESS_LONGTEXT N_( \ 110 "Brightness of the video input ." )111 "Brightness of the video input (if supported by v4l2 driver)." ) 111 112 #define CONTRAST_TEXT N_( "Contrast" ) 112 113 #define CONTRAST_LONGTEXT N_( \ 113 "Contrast of the video input ." )114 "Contrast of the video input (if supported by v4l2 driver)." ) 114 115 #define SATURATION_TEXT N_( "Saturation" ) 115 116 #define SATURATION_LONGTEXT N_( \ 116 "Saturation of the video input ." )117 "Saturation of the video input (if supported by v4l2 driver)." ) 117 118 #define HUE_TEXT N_( "Hue" ) 118 119 #define HUE_LONGTEXT N_( \ 119 "Hue of the video input ." )120 "Hue of the video input (if supported by v4l2 driver)." ) 120 121 #define GAMMA_TEXT N_( "Gamma" ) 121 122 #define GAMMA_LONGTEXT N_( \ 122 "Gamma of the video input ." )123 "Gamma of the video input (if supported by v4l2 driver)." ) 123 124 124 125 #define ADEV_TEXT N_("Audio device name") … … 184 185 add_float( CFG_PREFIX "fps", 0, NULL, FPS_TEXT, FPS_LONGTEXT, VLC_TRUE ); 185 186 186 set_section( N_( "Video controls" ), NULL );187 add_bool( CFG_PREFIX "controls-reset", VLC_FALSE, NULL, CTRL_RESET_TEXT,188 CTRL_RESET_LONGTEXT, VLC_TRUE );189 add_integer( CFG_PREFIX "brightness", -1, NULL, BRIGHTNESS_TEXT,190 BRIGHTNESS_LONGTEXT, VLC_TRUE );191 add_integer( CFG_PREFIX "contrast", -1, NULL, CONTRAST_TEXT,192 CONTRAST_LONGTEXT, VLC_TRUE );193 add_integer( CFG_PREFIX "saturation", -1, NULL, SATURATION_TEXT,194 SATURATION_LONGTEXT, VLC_TRUE );195 add_integer( CFG_PREFIX "hue", -1, NULL, HUE_TEXT,196 HUE_LONGTEXT, VLC_TRUE );197 add_integer( CFG_PREFIX "gamma", -1, NULL, GAMMA_TEXT,198 GAMMA_LONGTEXT, VLC_TRUE );199 200 187 set_section( N_( "Audio input" ), NULL ); 201 188 add_string( CFG_PREFIX "adev", "/dev/dsp", 0, ADEV_TEXT, ADEV_LONGTEXT, … … 212 199 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); 213 200 201 set_section( N_( "Controls" ), N_( "v4l2 driver controls" ) ); 202 add_bool( CFG_PREFIX "controls-reset", VLC_FALSE, NULL, CTRL_RESET_TEXT, 203 CTRL_RESET_LONGTEXT, VLC_TRUE ); 204 add_integer( CFG_PREFIX "brightness", -1, NULL, BRIGHTNESS_TEXT, 205 BRIGHTNESS_LONGTEXT, VLC_TRUE ); 206 add_integer( CFG_PREFIX "contrast", -1, NULL, CONTRAST_TEXT, 207 CONTRAST_LONGTEXT, VLC_TRUE ); 208 add_integer( CFG_PREFIX "saturation", -1, NULL, SATURATION_TEXT, 209 SATURATION_LONGTEXT, VLC_TRUE ); 210 add_integer( CFG_PREFIX "hue", -1, NULL, HUE_TEXT, 211 HUE_LONGTEXT, VLC_TRUE ); 212 add_integer( CFG_PREFIX "gamma", -1, NULL, GAMMA_TEXT, 213 GAMMA_LONGTEXT, VLC_TRUE ); 214 215 214 216 add_shortcut( "v4l2" ); 215 217 set_capability( "access_demux", 10 ); … … 230 232 static void CommonClose( vlc_object_t *, demux_sys_t * ); 231 233 static void ParseMRL( demux_sys_t *, char *, vlc_object_t * ); 232 static void GetV4L2Params( demux_sys_t * , vlc_object_t * );234 static void GetV4L2Params( demux_sys_t *, vlc_object_t * ); 233 235 234 236 static int DemuxControl( demux_t *, int, va_list ); … … 242 244 static block_t* GrabAudio( demux_t *p_demux ); 243 245 244 vlc_bool_t IsPixelFormatSupported( demux_t *p_demux, unsigned int i_pixelformat ); 245 246 char* ResolveALSADeviceName( char *psz_device ); 246 static vlc_bool_t IsPixelFormatSupported( demux_t *p_demux, 247 unsigned int i_pixelformat ); 248 249 static char* ResolveALSADeviceName( char *psz_device ); 247 250 static int OpenVideoDev( vlc_object_t *, demux_sys_t *, vlc_bool_t ); 248 static int OpenAudioDev( demux_t *, char *psz_device ); 249 static vlc_bool_t ProbeVideoDev( vlc_object_t *, demux_sys_t *, char *psz_device ); 250 static vlc_bool_t ProbeAudioDev( demux_t *, char *psz_device ); 251 static int OpenAudioDev( vlc_object_t *, demux_sys_t *, vlc_bool_t ); 252 static vlc_bool_t ProbeVideoDev( vlc_object_t *, demux_sys_t *, 253 char *psz_device ); 254 static vlc_bool_t ProbeAudioDev( vlc_object_t *, demux_sys_t *, 255 char *psz_device ); 251 256 252 257 static int ControlList( vlc_object_t *, int , vlc_bool_t, vlc_bool_t ); 253 258 static int Control( vlc_object_t *, int i_fd, 254 259 const char *psz_name, int i_cid, int i_value ); 255 static int DemuxControlCallback( vlc_object_t *p_this, 256 const char *psz_var, vlc_value_t oldval, vlc_value_t newval, 257 void *p_data ); 258 static int DemuxControlResetCallback( vlc_object_t *p_this, 259 const char *psz_var, vlc_value_t oldval, vlc_value_t newval, 260 void *p_data ); 261 static int AccessControlCallback( vlc_object_t *p_this, 262 const char *psz_var, vlc_value_t oldval, vlc_value_t newval, 263 void *p_data ); 260 261 static int DemuxControlCallback( vlc_object_t *p_this, const char *psz_var, 262 vlc_value_t oldval, vlc_value_t newval, 263 void *p_data ); 264 static int DemuxControlResetCallback( vlc_object_t *p_this, const char *psz_var, 265 vlc_value_t oldval, vlc_value_t newval, 266 void *p_data ); 267 static int AccessControlCallback( vlc_object_t *p_this, const char *psz_var, 268 vlc_value_t oldval, vlc_value_t newval, 269 void *p_data ); 264 270 static int AccessControlResetCallback( vlc_object_t *p_this, 265 const char *psz_var, vlc_value_t oldval, vlc_value_t newval,266 void *p_data );271 const char *psz_var, vlc_value_t oldval, 272 vlc_value_t newval, void *p_data ); 267 273 268 274 static struct … … 400 406 }; 401 407 408 #define FIND_VIDEO 1 409 #define FIND_AUDIO 2 410 411 static int FindMainDevice( vlc_object_t *p_this, demux_sys_t *p_sys, 412 int i_flags, vlc_bool_t b_demux, 413 vlc_bool_t b_forced ) 414 { 415 /* Find main device (video or audio) */ 416 if( p_sys->psz_device && *p_sys->psz_device ) 417 { 418 msg_Dbg( p_this, "main device='%s'", p_sys->psz_device ); 419 420 /* Try to open as video device */ 421 if( i_flags & FIND_VIDEO ) 422 { 423 msg_Dbg( p_this, "trying device '%s' as video", p_sys->psz_device ); 424 if( ProbeVideoDev( p_this, p_sys, p_sys->psz_device ) ) 425 { 426 msg_Dbg( p_this, "'%s' is a video device", p_sys->psz_device ); 427 /* Device was a video device */ 428 if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); 429 p_sys->psz_vdev = p_sys->psz_device; 430 p_sys->psz_device = NULL; 431 p_sys->i_fd_video = OpenVideoDev( p_this, p_sys, b_demux ); 432 if( p_sys->i_fd_video < 0 ) 433 return VLC_EGENERIC; 434 return VLC_SUCCESS; 435 } 436 } 437 438 if( i_flags & FIND_AUDIO ) 439 { 440 /* Try to open as audio device */ 441 msg_Dbg( p_this, "trying device '%s' as audio", p_sys->psz_device ); 442 if( ProbeAudioDev( p_this, p_sys, p_sys->psz_device ) ) 443 { 444 msg_Dbg( p_this, "'%s' is an audio device", p_sys->psz_device ); 445 /* Device was an audio device */ 446 if( p_sys->psz_adev ) free( p_sys->psz_adev ); 447 p_sys->psz_adev = p_sys->psz_device; 448 p_sys->psz_device = NULL; 449 p_sys->i_fd_audio = OpenAudioDev( p_this, p_sys, b_demux ); 450 if( p_sys->i_fd_audio < 0 ) 451 return VLC_EGENERIC; 452 return VLC_SUCCESS; 453 } 454 } 455 } 456 457 /* If no device opened, only continue if the access was forced */ 458 if( b_forced == VLC_FALSE 459 && !( ( i_flags & FIND_VIDEO && p_sys->i_fd_video >= 0 ) 460 || ( i_flags & FIND_AUDIO && p_sys->i_fd_audio >= 0 ) ) ) 461 { 462 return VLC_EGENERIC; 463 } 464 465 /* Find video device */ 466 if( i_flags & FIND_VIDEO && p_sys->i_fd_video < 0 ) 467 { 468 if( !p_sys->psz_vdev || !*p_sys->psz_vdev ) 469 { 470 if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); 471 p_sys->psz_vdev = var_CreateGetString( p_this, "v4l2-dev" ); 472 } 473 474 msg_Dbg( p_this, "opening '%s' as video", p_sys->psz_vdev ); 475 if( p_sys->psz_vdev && *p_sys->psz_vdev 476 && ProbeVideoDev( p_this, p_sys, p_sys->psz_vdev ) ) 477 { 478 p_sys->i_fd_video = OpenVideoDev( p_this, p_sys, b_demux ); 479 } 480 } 481 482 /* Find audio device */ 483 if( i_flags & FIND_AUDIO && p_sys->i_fd_audio < 0 ) 484 { 485 if( !p_sys->psz_adev || !*p_sys->psz_adev ) 486 { 487 if( p_sys->psz_adev ) free( p_sys->psz_adev ); 488 p_sys->psz_adev = var_CreateGetString( p_this, "v4l2-adev" ); 489 } 490 491 msg_Dbg( p_this, "opening '%s' as audio", p_sys->psz_adev ); 492 if( p_sys->psz_adev && *p_sys->psz_adev 493 && ProbeAudioDev( p_this, p_sys, p_sys->psz_adev ) ) 494 { 495 p_sys->i_fd_audio = OpenAudioDev( p_this, p_sys, b_demux ); 496 } 497 } 498 499 if( !( ( i_flags & FIND_VIDEO && p_sys->i_fd_video >= 0 ) 500 || ( i_flags & FIND_AUDIO && p_sys->i_fd_audio >= 0 ) ) ) 501 { 502 return VLC_EGENERIC; 503 } 504 return VLC_SUCCESS; 505 } 506 402 507 /***************************************************************************** 403 508 * DemuxOpen: opens v4l2 device, access_demux callback … … 434 539 #endif 435 540 436 /* Find main device (video or audio) */ 437 if( p_sys->psz_device && *p_sys->psz_device ) 438 { 439 msg_Dbg( p_demux, "main device='%s'", p_sys->psz_device ); 440 441 /* Try to open as video device */ 442 msg_Dbg( p_demux, "trying device '%s' as video", p_sys->psz_device ); 443 if( ProbeVideoDev( (vlc_object_t *) p_demux, p_sys, p_sys->psz_device ) ) 444 { 445 msg_Dbg( p_demux, "'%s' is a video device", p_sys->psz_device ); 446 /* Device was a video device */ 447 if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); 448 p_sys->psz_vdev = p_sys->psz_device; 449 p_sys->psz_device = NULL; 450 p_sys->i_fd_video = OpenVideoDev( (vlc_object_t *) p_demux, p_sys, VLC_TRUE ); 451 if( p_sys->i_fd_video < 0 ) 452 { 453 DemuxClose( p_this ); 454 return VLC_EGENERIC; 455 } 456 } 457 else 458 { 459 /* Try to open as audio device */ 460 msg_Dbg( p_demux, "trying device '%s' as audio", p_sys->psz_device ); 461 if( ProbeAudioDev( p_demux, p_sys->psz_device ) ) 462 { 463 msg_Dbg( p_demux, "'%s' is an audio device", p_sys->psz_device ); 464 /* Device was an audio device */ 465 if( p_sys->psz_adev ) free( p_sys->psz_adev ); 466 p_sys->psz_adev = p_sys->psz_device; 467 p_sys->psz_device = NULL; 468 p_sys->i_fd_audio = OpenAudioDev( p_demux, p_sys->psz_adev ); 469 if( p_sys->i_fd_audio < 0 ) 470 { 471 DemuxClose( p_this ); 472 return VLC_EGENERIC; 473 } 474 } 475 } 476 } 477 478 /* If no device opened, only continue if the access was forced */ 479 if( p_sys->i_fd_video < 0 && p_sys->i_fd_audio < 0 ) 480 { 481 if( strcmp( p_demux->psz_access, "v4l2" ) ) 482 { 483 DemuxClose( p_this ); 484 return VLC_EGENERIC; 485 } 486 } 487 488 /* Find video device */ 489 if( p_sys->i_fd_video < 0 ) 490 { 491 if( !p_sys->psz_vdev || !*p_sys->psz_vdev ) 492 { 493 if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); 494 p_sys->psz_vdev = var_CreateGetString( p_demux, "v4l2-dev" ); 495 } 496 497 msg_Dbg( p_demux, "opening '%s' as video", p_sys->psz_vdev ); 498 if( p_sys->psz_vdev && *p_sys->psz_vdev && ProbeVideoDev( (vlc_object_t *) p_demux, p_sys, p_sys->psz_vdev ) ) 499 { 500 p_sys->i_fd_video = OpenVideoDev( (vlc_object_t *) p_demux, p_sys, VLC_TRUE ); 501 } 502 } 503 504 /* Find audio device */ 505 if( p_sys->i_fd_audio < 0 ) 506 { 507 if( !p_sys->psz_adev || !*p_sys->psz_adev ) 508 { 509 if( p_sys->psz_adev ) free( p_sys->psz_adev ); 510 p_sys->psz_adev = var_CreateGetString( p_demux, "v4l2-adev" ); 511 } 512 513 msg_Dbg( p_demux, "opening '%s' as audio", p_sys->psz_adev ); 514 if( p_sys->psz_adev && *p_sys->psz_adev && ProbeAudioDev( p_demux, p_sys->psz_adev ) ) 515 { 516 p_sys->i_fd_audio = OpenAudioDev( p_demux, p_sys->psz_adev ); 517 } 518 } 519 520 if( p_sys->i_fd_video < 0 && p_sys->i_fd_audio < 0 ) 541 if( FindMainDevice( p_this, p_sys, FIND_VIDEO|FIND_AUDIO, 542 VLC_TRUE, !strcmp( p_demux->psz_access, "v4l2" ) ) != VLC_SUCCESS ) 521 543 { 522 544 DemuxClose( p_this ); … … 530 552 * GetV4L2Params: fill in p_sys parameters (shared by DemuxOpen and AccessOpen) 531 553 *****************************************************************************/ 532 void GetV4L2Params( demux_sys_t *p_sys, vlc_object_t *p_obj ) 533 { 534 vlc_value_t val; 535 554 static void GetV4L2Params( demux_sys_t *p_sys, vlc_object_t *p_obj ) 555 { 536 556 p_sys->i_video_pts = -1; 537 557 538 var_Create( p_obj, "v4l2-standard", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 539 var_Get( p_obj, "v4l2-standard", &val ); 540 p_sys->i_selected_standard_id = i_standards_list[val.i_int]; 558 p_sys->i_selected_standard_id = 559 i_standards_list[var_CreateGetInteger( p_obj, "v4l2-standard" )]; 541 560 542 561 p_sys->i_selected_input = var_CreateGetInteger( p_obj, "v4l2-input" ); … … 549 568 var_CreateGetBool( p_obj, "v4l2-controls-reset" ); 550 569 551 var_Create( p_obj, "v4l2-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); 552 var_Get( p_obj, "v4l2-fps", &val ); 553 p_sys->f_fps = val.f_float; 554 555 var_Create( p_obj, "v4l2-samplerate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 556 var_Get( p_obj, "v4l2-samplerate", &val ); 557 p_sys->i_sample_rate = val.i_int; 558 570 p_sys->f_fps = var_CreateGetFloat( p_obj, "v4l2-fps" ); 571 p_sys->i_sample_rate = var_CreateGetInteger( p_obj, "v4l2-samplerate" ); 559 572 p_sys->psz_requested_chroma = var_CreateGetString( p_obj, "v4l2-chroma" ); 560 573 561 574 #ifdef HAVE_ALSA 562 var_Create( p_obj, "v4l2-alsa", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 563 var_Get( p_obj, "v4l2-alsa", &val ); 564 p_sys->b_use_alsa = val.b_bool; 575 p_sys->b_use_alsa = var_CreateGetBool( p_obj, "v4l2-alsa" ); 565 576 #endif 566 577 567 var_Create( p_obj, "v4l2-stereo", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 568 var_Get( p_obj, "v4l2-stereo", &val ); 569 p_sys->b_stereo = val.b_bool; 578 p_sys->b_stereo = var_CreateGetBool( p_obj, "v4l2-stereo" ); 570 579 571 580 p_sys->i_pts = var_CreateGetInteger( p_obj, "v4l2-caching" ); … … 947 956 if( p_sys == NULL ) return VLC_ENOMEM; 948 957 949 GetV4L2Params( p_sys, (vlc_object_t *) p_access);958 GetV4L2Params( p_sys, (vlc_object_t *) p_access ); 950 959 951 960 ParseMRL( p_sys, p_access->psz_path, (vlc_object_t *) p_access ); 952 961 953 /* Find main device (video) */ 954 if( p_sys->psz_device && *p_sys->psz_device ) 955 { 956 msg_Dbg( p_access, "main device='%s'", p_sys->psz_device ); 957 958 /* Try to open as video device */ 959 msg_Dbg( p_access, "trying device '%s' as video", p_sys->psz_device ); 960 if( ProbeVideoDev( (vlc_object_t *) p_access, p_sys, p_sys->psz_device ) ) 961 { 962 msg_Dbg( p_access, "'%s' is a video device", p_sys->psz_device ); 963 /* Device was a video device */ 964 if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); 965 p_sys->psz_vdev = p_sys->psz_device; 966 p_sys->psz_device = NULL; 967 p_sys->i_fd_video = OpenVideoDev( (vlc_object_t *) p_access, p_sys, VLC_FALSE ); 968 if( p_sys->i_fd_video < 0 ) 969 { 970 AccessClose( p_this ); 971 return VLC_EGENERIC; 972 } 973 } 974 } 975 976 /* If no device opened, only continue if the access was forced */ 977 if( p_sys->i_fd_video < 0 ) 978 { 979 if( strcmp( p_access->psz_access, "v4l2" ) ) 980 { 981 AccessClose( p_this ); 982 return VLC_EGENERIC; 983 } 984 } 985 986 /* Find video device */ 987 if( p_sys->i_fd_video < 0 ) 988 { 989 if( !p_sys->psz_vdev || !*p_sys->psz_vdev ) 990 { 991 if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); 992 p_sys->psz_vdev = var_CreateGetString( p_access, "v4l2-dev" ); 993 } 994 995 msg_Dbg( p_access, "opening '%s' as video", p_sys->psz_vdev ); 996 if( p_sys->psz_vdev && *p_sys->psz_vdev && ProbeVideoDev( (vlc_object_t *) p_access, p_sys, p_sys->psz_vdev ) ) 997 { 998 p_sys->i_fd_video = OpenVideoDev( (vlc_object_t *) p_access, p_sys, VLC_FALSE ); 999 } 1000 } 1001 1002 1003 if( p_sys->i_fd_video < 0 ) 962 if( FindMainDevice( p_this, p_sys, FIND_VIDEO, 963 VLC_FALSE, !strcmp( p_access->psz_access, "v4l2" ) ) != VLC_SUCCESS ) 1004 964 { 1005 965 AccessClose( p_this ); … … 1602 1562 * in the array of supported formats returned by the driver 1603 1563 *****************************************************************************/ 1604 vlc_bool_t IsPixelFormatSupported( demux_t *p_demux, unsigned int i_pixelformat )1564 static vlc_bool_t IsPixelFormatSupported( demux_t *p_demux, unsigned int i_pixelformat ) 1605 1565 { 1606 1566 demux_sys_t *p_sys = p_demux->p_sys; … … 1617 1577 * OpenVideoDev: open and set up the video device and probe for capabilities 1618 1578 *****************************************************************************/ 1619 int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, vlc_bool_t b_demux )1579 static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, vlc_bool_t b_demux ) 1620 1580 { 1621 1581 int i_fd; … … 1661 1621 /* TODO: Move the resolution stuff up here */ 1662 1622 /* if MPEG encoder card, no need to do anything else after this */ 1623 ControlList( p_obj, i_fd, 1624 var_GetBool( p_obj, "v4l2-controls-reset" ), b_demux ); 1663 1625 if( VLC_FALSE == b_demux) 1664 1626 { 1665 ControlList( p_obj, i_fd,1666 var_GetBool( p_obj, "v4l2-controls-reset" ), b_demux );1667 1668 1627 return i_fd; 1669 1628 } … … 1981 1940 * ResolveALSADeviceName: Change any . to : in the ALSA device name 1982 1941 *****************************************************************************/ 1983 char*ResolveALSADeviceName( char *psz_device )1942 static char *ResolveALSADeviceName( char *psz_device ) 1984 1943 { 1985 1944 char* psz_alsa_name = strdup( psz_device ); … … 1995 1954 * OpenAudioDev: open and set up the audio device and probe for capabilities 1996 1955 *****************************************************************************/ 1997 int OpenAudioDev( demux_t *p_demux, char *psz_device ) 1998 { 1999 demux_sys_t *p_sys = p_demux->p_sys; 1956 static int OpenAudioDev( vlc_object_t *p_this, demux_sys_t *p_sys, 1957 vlc_bool_t b_demux ) 1958 { 1959 char *psz_device = p_sys->psz_adev; 2000 1960 int i_fd = 0; 2001 1961 int i_format; … … 2018 1978 SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK ) ) < 0) 2019 1979 { 2020 msg_Err( p_demux, "Cannot open ALSA audio device %s (%s)", 2021 psz_alsa_device_name, 2022 snd_strerror( i_err ) ); 1980 msg_Err( p_this, "Cannot open ALSA audio device %s (%s)", 1981 psz_alsa_device_name, snd_strerror( i_err ) ); 2023 1982 goto adev_fail; 2024 1983 } … … 2026 1985 if( ( i_err = snd_pcm_nonblock( p_sys->p_alsa_pcm, 1 ) ) < 0) 2027 1986 { 2028 msg_Err( p_ demux, "Cannot set ALSA nonblock (%s)",2029 snd_strerror( i_err ) );1987 msg_Err( p_this, "Cannot set ALSA nonblock (%s)", 1988 snd_strerror( i_err ) ); 2030 1989 goto adev_fail; 2031 1990 } … … 2035 1994 if( ( i_err = snd_pcm_hw_params_malloc( &p_hw_params ) ) < 0 ) 2036 1995 { 2037 msg_Err( p_demux, "ALSA: cannot allocate hardware parameter structure (%s)", 2038 snd_strerror( i_err ) ); 1996 msg_Err( p_this, 1997 "ALSA: cannot allocate hardware parameter structure (%s)", 1998 snd_strerror( i_err ) ); 2039 1999 goto adev_fail; 2040 2000 } … … 2042 2002 if( ( i_err = snd_pcm_hw_params_any( p_sys->p_alsa_pcm, p_hw_params ) ) < 0 ) 2043 2003 { 2044 msg_Err( p_demux, "ALSA: cannot initialize hardware parameter structure (%s)", 2045 snd_strerror( i_err ) ); 2004 msg_Err( p_this, 2005 "ALSA: cannot initialize hardware parameter structure (%s)", 2006 snd_strerror( i_err ) ); 2046 2007 goto adev_fail; 2047 2008 } … … 2050 2011 if( ( i_err = snd_pcm_hw_params_set_access( p_sys->p_alsa_pcm, p_hw_params, SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 ) 2051 2012 { 2052 msg_Err( p_ demux, "ALSA: cannot set access type (%s)",2053 snd_strerror( i_err ) );2013 msg_Err( p_this, "ALSA: cannot set access type (%s)", 2014 snd_strerror( i_err ) ); 2054 2015 goto adev_fail; 2055 2016 } … … 2058 2019 if( ( i_err = snd_pcm_hw_params_set_format( p_sys->p_alsa_pcm, p_hw_params, SND_PCM_FORMAT_S16_LE ) ) < 0 ) 2059 2020 { 2060 msg_Err( p_ demux, "ALSA: cannot set sample format (%s)",2061 snd_strerror( i_err ) );2021 msg_Err( p_this, "ALSA: cannot set sample format (%s)", 2022 snd_strerror( i_err ) ); 2062 2023 goto adev_fail; 2063 2024 } … … 2071 2032 if( i_err < 0 ) 2072 2033 { 2073 msg_Err( p_ demux, "ALSA: cannot set sample rate (%s)",2074 snd_strerror( i_err ) );2034 msg_Err( p_this, "ALSA: cannot set sample rate (%s)", 2035 snd_strerror( i_err ) ); 2075 2036 goto adev_fail; 2076 2037 } … … 2081 2042 { 2082 2043 channels = ( channels==1 ) ? 2 : 1; 2083 msg_Warn( p_demux, "ALSA: cannot set channel count (%s). Trying with channels=%d", 2084 snd_strerror( i_err ), 2085 channels ); 2044 msg_Warn( p_this, "ALSA: cannot set channel count (%s). " 2045 "Trying with channels=%d", 2046 snd_strerror( i_err ), 2047 channels ); 2086 2048 if( ( i_err = snd_pcm_hw_params_set_channels( p_sys->p_alsa_pcm, p_hw_params, channels ) ) < 0 ) 2087 2049 { 2088 msg_Err( p_ demux, "ALSA: cannot set channel count (%s)",2089 snd_strerror( i_err ) );2050 msg_Err( p_this, "ALSA: cannot set channel count (%s)", 2051 snd_strerror( i_err ) ); 2090 2052 goto adev_fail; 2091 2053 } … … 2097 2059 if( ( i_err = snd_pcm_hw_params_get_buffer_time_max(p_hw_params, &buffer_time, 0) ) < 0 ) 2098 2060 { 2099 msg_Err( p_ demux, "ALSA: cannot get buffer time max (%s)",2100 snd_strerror( i_err ) );2061 msg_Err( p_this, "ALSA: cannot get buffer time max (%s)", 2062 snd_strerror( i_err ) ); 2101 2063 goto adev_fail; 2102 2064 } … … 2112 2074 if( i_err < 0 ) 2113 2075 { 2114 msg_Err( p_ demux, "ALSA: cannot set period time (%s)",2115 snd_strerror( i_err ) );2076 msg_Err( p_this, "ALSA: cannot set period time (%s)", 2077 snd_strerror( i_err ) ); 2116 2078 goto adev_fail; 2117 2079 } … … 2125 2087 if( i_err < 0 ) 2126 2088 { 2127 msg_Err( p_ demux, "ALSA: cannot set buffer time (%s)",2128 snd_strerror( i_err ) );2089 msg_Err( p_this, "ALSA: cannot set buffer time (%s)", 2090 snd_strerror( i_err ) ); 2129 2091 goto adev_fail; 2130 2092 } … … 2133 2095 if( ( i_err = snd_pcm_hw_params( p_sys->p_alsa_pcm, p_hw_params ) ) < 0 ) 2134 2096 { 2135 msg_Err( p_ demux, "ALSA: cannot set hw parameters (%s)",2136 snd_strerror( i_err ) );2097 msg_Err( p_this, "ALSA: cannot set hw parameters (%s)", 2098 snd_strerror( i_err ) ); 2137 2099 goto adev_fail; 2138 2100 } … … 2143 2105 if (chunk_size == buffer_size) 2144 2106 { 2145 msg_Err( p_demux, "ALSA: period cannot equal buffer size (%lu == %lu)", 2146 chunk_size, buffer_size); 2107 msg_Err( p_this, 2108 "ALSA: period cannot equal buffer size (%lu == %lu)", 2109 chunk_size, buffer_size); 2147 2110 goto adev_fail; 2148 2111 } … … 2161 2124 if( ( i_err = snd_pcm_prepare( p_sys->p_alsa_pcm ) ) < 0 ) 2162 2125 { 2163 msg_Err( p_demux, "ALSA: cannot prepare audio interface for use (%s)", 2164 snd_strerror( i_err ) ); 2126 msg_Err( p_this, 2127 "ALSA: cannot prepare audio interface for use (%s)", 2128 snd_strerror( i_err ) ); 2165 2129 goto adev_fail; 2166 2130 } … … 2177 2141 if( (i_fd = open( psz_device, O_RDONLY | O_NONBLOCK )) < 0 ) 2178 2142 { 2179 msg_Err( p_ demux, "cannot open OSS audio device (%m)" );2143 msg_Err( p_this, "cannot open OSS audio device (%m)" ); 2180 2144 goto adev_fail; 2181 2145 } … … 2185 2149 || i_format != AFMT_S16_LE ) 2186 2150 { 2187 msg_Err( p_ demux, "cannot set audio format (16b little endian) "2188 " (%m)" );2151 msg_Err( p_this, 2152 "cannot set audio format (16b little endian) (%m)" ); 2189 2153 goto adev_fail; 2190 2154 } … … 2193 2157 &p_sys->b_stereo ) < 0 ) 2194 2158 { 2195 msg_Err( p_ demux, "cannot set audio channels count (%m)" );2159 msg_Err( p_this, "cannot set audio channels count (%m)" ); 2196 2160 goto adev_fail; 2197 2161 } … … 2200 2164 &p_sys->i_sample_rate ) < 0 ) 2201 2165 { 2202 msg_Err( p_ demux, "cannot set audio sample rate (%m)" );2166 msg_Err( p_this, "cannot set audio sample rate (%m)" ); 2203 2167 goto adev_fail; 2204 2168 } … … 2207 2171 } 2208 2172 2209 msg_Dbg( p_ demux, "opened adev=`%s' %s %dHz",2173 msg_Dbg( p_this, "opened adev=`%s' %s %dHz", 2210 2174 psz_device, p_sys->b_stereo ? "stereo" : "mono", 2211 2175 p_sys->i_sample_rate ); … … 2220 2184 fmt.i_bitrate = fmt.audio.i_channels * fmt.audio.i_rate * fmt.audio.i_bitspersample; 2221 2185 2222 msg_Dbg( p_demux, "new audio es %d channels %dHz", 2223 fmt.audio.i_channels, fmt.audio.i_rate ); 2224 2225 p_sys->p_es_audio = es_out_Add( p_demux->out, &fmt ); 2186 msg_Dbg( p_this, "new audio es %d channels %dHz", 2187 fmt.audio.i_channels, fmt.audio.i_rate ); 2188 2189 if( b_demux ) 2190 { 2191 demux_t *p_demux = (demux_t *)p_this; 2192 p_sys->p_es_audio = es_out_Add( p_demux->out, &fmt ); 2193 } 2226 2194 2227 2195 #ifdef HAVE_ALSA … … 2248 2216 * ProbeVideoDev: probe video for capabilities 2249 2217 *****************************************************************************/ 2250 vlc_bool_t ProbeVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, char *psz_device ) 2218 static vlc_bool_t ProbeVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, 2219 char *psz_device ) 2251 2220 { 2252 2221 int i_index; … … 2538 2507 * ProbeAudioDev: probe audio for capabilities 2539 2508 *****************************************************************************/ 2540 vlc_bool_t ProbeAudioDev( demux_t *p_demux, char *psz_device ) 2509 static vlc_bool_t ProbeAudioDev( vlc_object_t *p_this, demux_sys_t *p_sys, 2510 char *psz_device ) 2541 2511 { 2542 2512 int i_fd = 0; … … 2544 2514 2545 2515 #ifdef HAVE_ALSA 2546 demux_sys_t *p_sys = p_demux->p_sys;2547 2548 2516 if( p_sys->b_use_alsa ) 2549 2517 { … … 2556 2524 if( ( i_err = snd_pcm_open( &p_alsa_pcm, psz_alsa_device_name, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK ) ) < 0 ) 2557 2525 { 2558 msg_Err( p_ demux, "cannot open device %s for ALSA audio (%s)", psz_alsa_device_name, snd_strerror( i_err ) );2526 msg_Err( p_this, "cannot open device %s for ALSA audio (%s)", psz_alsa_device_name, snd_strerror( i_err ) ); 2559 2527 free( psz_alsa_device_name ); 2560 2528 goto open_failed; … … 2571 2539 if( ( i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ) ) < 0 ) 2572 2540 { 2573 msg_Err( p_ demux, "cannot open device %s for OSS audio (%m)", psz_device );2541 msg_Err( p_this, "cannot open device %s for OSS audio (%m)", psz_device ); 2574 2542 goto open_failed; 2575 2543 } … … 2578 2546 if( ioctl( i_fd, SNDCTL_DSP_GETCAPS, &i_caps ) < 0 ) 2579 2547 { 2580 msg_Err( p_ demux, "cannot get audio caps (%m)" );2548 msg_Err( p_this, "cannot get audio caps (%m)" ); 2581 2549 goto open_failed; 2582 2550 } … … 2590 2558 if( i_fd >= 0 ) close( i_fd ); 2591 2559 return VLC_FALSE; 2592 2593 2560 } 2594 2561 … … 2767 2734 * value and create the relevant variables to enable runtime changes 2768 2735 *****************************************************************************/ 2769 static int ControlList( vlc_object_t *p_obj, int i_fd, vlc_bool_t b_reset, vlc_bool_t b_demux ) 2736 static int ControlList( vlc_object_t *p_obj, int i_fd, 2737 vlc_bool_t b_reset, vlc_bool_t b_demux ) 2770 2738 { 2771 2739 struct v4l2_queryctrl queryctrl;
