Changeset 418edc0d35fd428561a2019652ffc2f606baa7b0
- Timestamp:
- 06/09/04 06:38:46 (4 years ago)
- git-parent:
- Files:
-
- include/mtime.h (modified) (1 diff)
- modules/access/cdda/Modules.am (modified) (1 diff)
- modules/access/cdda/access.c (modified) (42 diffs)
- modules/access/cdda/cdda.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/mtime.h
re414aa3 r418edc0 48 48 #define MSTRTIME_MAX_SIZE 22 49 49 50 /* Well, Duh? But it does clue us in that we are converting from 51 millisecond quantity to a second quantity or vice versa. 52 */ 53 #define MILLISECONDS_PER_SEC 1000 54 50 55 #define msecstotimestr(psz_buffer, msecs) \ 51 secstotimestr( psz_buffer, (msecs / (int) 1000) )56 secstotimestr( psz_buffer, (msecs / (int) MILLISECONDS_PER_SEC) ) 52 57 53 58 /***************************************************************************** modules/access/cdda/Modules.am
re8f07ae r418edc0 1 1 SOURCES_cddax = \ 2 ../vcdx/cdrom.c \3 ../vcdx/cdrom.h \4 2 access.c \ 5 3 cdda.c \ modules/access/cdda/access.c
r4fcaafa r418edc0 32 32 #include <vlc/vlc.h> 33 33 #include <vlc/input.h> 34 #include <vlc_playlist.h> 34 35 35 36 #include <sys/types.h> 36 37 #include <cdio/cdio.h> 38 #include <cdio/logging.h> 37 39 #include <cdio/cd_types.h> 38 40 … … 52 54 #include "cdda.h" 53 55 54 /* how many blocks Open will read in each loop */ 56 #define CDDA_MRL_PREFIX "cddax://" 57 58 /* how many blocks Open will read in each loop. Note libcdio and 59 SCSI MMC devices can read at most 25 blocks. 60 */ 55 61 #define CDDA_BLOCKS_ONCE 20 56 62 #define CDDA_DATA_ONCE (CDDA_BLOCKS_ONCE * CDIO_CD_FRAMESIZE_RAW) 57 63 58 #define CDDA_MRL_PREFIX "cddax://" 64 /* Frequency of sample in bits per second. */ 65 #define CDDA_FREQUENCY_SAMPLE 44100 59 66 60 67 /* FIXME: This variable is a hack. Would be nice to eliminate. */ … … 69 76 va_list args ); 70 77 static void CDDAMetaInfo( access_t *p_access ); 78 static int CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, 79 const char *psz_source, 80 vlc_bool_t b_single_track ); 81 static void CDDACreatePlaylistItem(const access_t *p_access, 82 cdda_data_t *p_cdda, 83 playlist_t *p_playlist, 84 track_t i_track, 85 char *psz_mrl, int psz_mrl_max, 86 const char *psz_source, 87 int playlist_operation, 88 int i_pos); 89 90 static int GetCDInfo( access_t *p_access, cdda_data_t *p_cdda ) ; 91 92 93 71 94 72 95 /**************************************************************************** … … 127 150 uninit_log_handler (cdio_log_level_t level, const char message[]) 128 151 { 129 cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys; 152 cdda_data_t *p_cdda = NULL; 153 154 if (p_cdda_input) 155 p_cdda = (cdda_data_t *)p_cdda_input->p_sys; 156 130 157 switch (level) { 131 158 case CDIO_LOG_DEBUG: 132 159 case CDIO_LOG_INFO: 133 if (! (p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB)))160 if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB))) 134 161 return; 135 162 /* Fall through if to warn case */ … … 167 194 168 195 dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN), "called %d", 169 p_cdda->i_ sector);196 p_cdda->i_lsn); 170 197 171 198 /* Check end of file */ … … 182 209 183 210 /* Check end of track */ 184 while( p_cdda->i_ sector >= p_cdda->p_sectors[p_access->info.i_title + 1] )211 while( p_cdda->i_lsn >= p_cdda->p_lsns[p_access->info.i_title + 1] ) 185 212 { 186 213 if( p_access->info.i_title + 1 >= p_cdda->i_tracks ) … … 195 222 p_cdda->p_title[p_access->info.i_title]->i_size; 196 223 p_access->info.i_pos = 0; 224 p_cdda->i_track++; 197 225 } 198 226 199 227 /* Don't read after the end of a title */ 200 if( p_cdda->i_ sector+ i_blocks >=201 p_cdda->p_ sectors[p_access->info.i_title + 1] )228 if( p_cdda->i_lsn + i_blocks >= 229 p_cdda->p_lsns[p_access->info.i_title + 1] ) 202 230 { 203 i_blocks = p_cdda->p_ sectors[p_access->info.i_title + 1 ] -204 p_cdda->i_ sector;231 i_blocks = p_cdda->p_lsns[p_access->info.i_title + 1 ] - 232 p_cdda->i_lsn; 205 233 } 206 234 … … 214 242 } 215 243 216 if( cdio_read_audio_sectors( p_cdda->p_cd dev->cdio, p_block->p_buffer,217 p_cdda->i_ sector, i_blocks) != 0 )244 if( cdio_read_audio_sectors( p_cdda->p_cdio, p_block->p_buffer, 245 p_cdda->i_lsn, i_blocks) != 0 ) 218 246 { 219 247 msg_Err( p_access, "could not read sector %lu", 220 (long unsigned int) p_cdda->i_ sector);248 (long unsigned int) p_cdda->i_lsn ); 221 249 block_Release( p_block ); 222 250 … … 225 253 the future libcdio may have cdparanoia support. 226 254 */ 227 p_cdda->i_ sector++;255 p_cdda->i_lsn++; 228 256 p_access->info.i_pos += CDIO_CD_FRAMESIZE_RAW; 229 257 return NULL; 230 258 } 231 259 232 p_cdda->i_ sector+= i_blocks;260 p_cdda->i_lsn += i_blocks; 233 261 p_access->info.i_pos += p_block->i_buffer; 234 262 … … 245 273 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; 246 274 247 p_cdda->i_ sector = p_cdda->p_sectors[p_access->info.i_title]275 p_cdda->i_lsn = p_cdda->p_lsns[p_access->info.i_title] 248 276 + i_pos / CDIO_CD_FRAMESIZE_RAW; 249 277 p_access->info.i_pos = i_pos; 250 278 251 279 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK), 252 " sector%lu, offset: %lld",253 (long unsigned int) p_cdda->i_ sector, i_pos );280 "lsn %lu, offset: %lld", 281 (long unsigned int) p_cdda->i_lsn, i_pos ); 254 282 return VLC_SUCCESS; 255 283 } … … 271 299 int i, i_matches; 272 300 cddb_conn_t *conn = cddb_new(); 273 const CdIo *p_cdio = p_cdda->p_cd dev->cdio;301 const CdIo *p_cdio = p_cdda->p_cdio; 274 302 275 303 … … 277 305 278 306 if (!conn) { 279 msg_Warn( p_access, "unable to initialize libcddb");307 msg_Warn( p_access, _("Unable to initialize libcddb") ); 280 308 goto cddb_destroy; 281 309 } … … 314 342 p_cdda->cddb.disc = cddb_disc_new(); 315 343 if (!p_cdda->cddb.disc) { 316 msg_Err( p_access, "Unable to create CDDB disc structure.");344 msg_Err( p_access, _("Unable to create CDDB disc structure.") ); 317 345 goto cddb_end; 318 346 } … … 331 359 332 360 if (!cddb_disc_calc_discid(p_cdda->cddb.disc)) { 333 msg_Err( p_access, "CDDB disc calc failed");361 msg_Err( p_access, _("CDDB disc ID calculation failed") ); 334 362 goto cddb_destroy; 335 363 } … … 338 366 if (i_matches > 0) { 339 367 if (i_matches > 1) 340 msg_Warn( p_access, "Found %d matches in CDDB. Using first one.",368 msg_Warn( p_access, _("Found %d matches in CDDB. Using first one."), 341 369 i_matches); 342 370 cddb_read(conn, p_cdda->cddb.disc); … … 346 374 347 375 } else { 348 msg_Warn( p_access, "CDDB error: %s", cddb_error_str(errno));376 msg_Warn( p_access, _("CDDB error: %s"), cddb_error_str(errno)); 349 377 } 350 378 … … 357 385 358 386 #define add_meta_val(FIELD, VLC_META, VAL) \ 359 if ( p_cdda->p_meta ) { \387 if ( p_cdda->p_meta && VAL) { \ 360 388 vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL ); \ 361 389 dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL ); \ … … 410 438 char psz_buffer[MSTRTIME_MAX_SIZE]; 411 439 mtime_t i_duration = 412 (p_cdda->p_ sectors[i_track] - p_cdda->p_sectors[0])440 (p_cdda->p_lsns[i_track] - p_cdda->p_lsns[0]) 413 441 / CDIO_CD_FRAMES_PER_SEC; 414 442 … … 420 448 char track_str[TITLE_MAX]; 421 449 mtime_t i_duration = 422 (p_cdda->p_ sectors[i_track+1] - p_cdda->p_sectors[i_track])450 (p_cdda->p_lsns[i_track+1] - p_cdda->p_lsns[i_track]) 423 451 / CDIO_CD_FRAMES_PER_SEC; 424 452 snprintf(track_str, TITLE_MAX, "%s %02d", _("Track"), i_track+1); … … 507 535 size_t i; 508 536 char * tp = temp_str; 509 boolsaw_control_prefix = false;537 vlc_bool_t saw_control_prefix = false; 510 538 size_t format_len = strlen(format_str); 511 539 … … 600 628 char psz_buffer[MSTRTIME_MAX_SIZE]; 601 629 mtime_t i_duration = 602 (p_cdda->p_ sectors[i_track] - p_cdda->p_sectors[i_track-1])630 (p_cdda->p_lsns[i_track] - p_cdda->p_lsns[i_track-1]) 603 631 / CDIO_CD_FRAMES_PER_SEC; 604 632 add_format_str_info(secstotimestr( psz_buffer, i_duration ) ); … … 621 649 } 622 650 623 #ifdef TRACK_META_INFORMATION_FINISHED624 651 static void 625 CDDACreatePlay ListItem(const input_thread_t *p_access, cdda_data_t *p_cdda,626 playlist_t *p_playlist, unsigned int i_track,652 CDDACreatePlaylistItem(const access_t *p_access, cdda_data_t *p_cdda, 653 playlist_t *p_playlist, track_t i_track, 627 654 char *psz_mrl, int psz_mrl_max, 628 655 const char *psz_source, int playlist_operation, … … 630 657 { 631 658 mtime_t i_duration = 632 (p_cdda->p_ sectors[i_track] - p_cdda->p_sectors[i_track-1])659 (p_cdda->p_lsns[i_track] - p_cdda->p_lsns[i_track-1]) 633 660 * (1000000 / CDIO_CD_FRAMES_PER_SEC) ; 634 661 char *p_author; … … 712 739 713 740 static int 714 CDDAFixupPlay List( access_t *p_access, cdda_data_t *p_cdda,715 const char *psz_source, track_t i_track)741 CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, 742 const char *psz_source, vlc_bool_t b_single_track ) 716 743 { 717 744 int i; 745 playlist_t * p_playlist; 718 746 char * psz_mrl; 719 747 unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) + 720 748 strlen("@T") + strlen("100") + 1; 721 749 750 #ifdef HAVE_LIBCDDB 751 p_cdda->i_cddb_enabled = 752 config_GetInt( p_access, MODULE_STRING "-cddb-enabled" ); 753 if( b_single_track && !p_cdda->i_cddb_enabled ) return 0; 754 #else 755 if( b_single_track ) return VLC_SUCCESS; 756 #endif 757 722 758 psz_mrl = malloc( psz_mrl_max ); 723 759 … … 725 761 { 726 762 msg_Warn( p_access, "out of memory" ); 727 return -1; 763 return VLC_ENOMEM; 764 } 765 766 p_playlist = (playlist_t *) vlc_object_find( p_access, VLC_OBJECT_PLAYLIST, 767 FIND_ANYWHERE ); 768 if( !p_playlist ) 769 { 770 msg_Warn( p_access, "can't find playlist" ); 771 free(psz_mrl); 772 return VLC_EGENERIC; 728 773 } 729 774 730 775 CDDAMetaInfo(p_access); 731 776 732 for( i = 1 ; i <= p_cdda->i_tracks ; i++ ) 733 { 734 input_title_t *t = p_cdda->p_sectors[i-1] = vlc_input_title_New(); 735 736 asprintf( &t->psz_name, _("Track %i"), i ); 737 t->i_size = ( p_sys->p_sectors[i] - p_sys->p_sectors[i-1] ) * 738 (int64_t)CDIO_CD_FRAMESIZE_RAW; 739 740 t->i_length = I64C(1000000) * t->i_size / 44100 / 4; 741 CDDACreatePlayListItem(p_access, p_cdda, i, psz_mrl, 742 psz_mrl_max, psz_source, PLAYLIST_APPEND, 743 PLAYLIST_END); 744 } 745 746 return 0; 747 } 748 #endif /* TRACK_META_INFORMATION_FINISHED*/ 777 if (b_single_track) { 778 /* May fill out more information when the playlist user interface becomes 779 more mature. 780 */ 781 CDDACreatePlaylistItem(p_access, p_cdda, p_playlist, p_cdda->i_track, 782 psz_mrl, psz_mrl_max, psz_source, PLAYLIST_REPLACE, 783 p_playlist->i_index); 784 } else { 785 786 for( i = 1 ; i <= p_cdda->i_tracks ; i++ ) 787 { 788 input_title_t *t = p_cdda->p_title[i-1] = vlc_input_title_New(); 789 790 asprintf( &t->psz_name, _("Track %i"), i ); 791 t->i_size = ( p_cdda->p_lsns[i] - p_cdda->p_lsns[i-1] ) * 792 (int64_t)CDIO_CD_FRAMESIZE_RAW; 793 794 t->i_length = I64C(1000000) * t->i_size / CDDA_FREQUENCY_SAMPLE / 4; 795 CDDACreatePlaylistItem(p_access, p_cdda, p_playlist, i, psz_mrl, 796 psz_mrl_max, psz_source, PLAYLIST_APPEND, 797 PLAYLIST_END); 798 } 799 } 800 801 return VLC_SUCCESS; 802 } 749 803 750 804 /**************************************************************************** … … 797 851 E_(CDDAOpen)( vlc_object_t *p_this ) 798 852 { 799 access_t *p_access = (access_t*)p_this; 800 char * psz_source; 801 cdda_data_t * p_cdda; 802 int i; 803 cddev_t *p_cddev; 853 access_t *p_access = (access_t*)p_this; 854 char * psz_source = NULL; 855 cdda_data_t *p_cdda; 856 CdIo *p_cdio; 857 track_t i_track = 1; 858 vlc_bool_t b_single_track = false; 859 int i_rc = VLC_EGENERIC; 804 860 805 861 /* Set where to log errors messages from libcdio. */ 806 862 p_cdda_input = p_access; 807 863 808 if( !p_access->psz_path || !*p_access->psz_path ) 864 /* parse the options passed in command line : */ 865 866 if( p_access->psz_path && *p_access->psz_path ) 809 867 { 810 /* Only when selected */ 868 char *psz_parser = psz_source = strdup( p_access->psz_path ); 869 870 while( *psz_parser && *psz_parser != '@' ) 871 { 872 psz_parser++; 873 } 874 875 if( *psz_parser == '@' ) 876 { 877 /* Found options */ 878 *psz_parser = '\0'; 879 ++psz_parser; 880 881 if ('T' == *psz_parser || 't' == *psz_parser ) 882 ++psz_parser; 883 884 i_track = (int)strtol( psz_parser, NULL, 10 ); 885 i_track = i_track ? i_track : 1; 886 b_single_track = true; 887 } 888 } else { 889 890 /* No device/track given. Continue only when this plugin was 891 selected */ 811 892 if( !p_this->b_force ) return VLC_EGENERIC; 812 893 … … 817 898 char **cd_drives = 818 899 cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false); 819 if (NULL == cd_drives) return -1; 820 if (cd_drives[0] == NULL) { 821 cdio_free_device_list(cd_drives); 822 return -1; 823 } 900 901 if (NULL == cd_drives || NULL == cd_drives[0] ) { 902 msg_Err( p_access, 903 _("libcdio couldn't find something with a CD-DA in it") ); 904 if (cd_drives) cdio_free_device_list(cd_drives); 905 return VLC_EGENERIC; 906 } 907 824 908 psz_source = strdup(cd_drives[0]); 825 909 cdio_free_device_list(cd_drives); 826 910 } 827 911 } 828 else829 psz_source = strdup( p_access->psz_path );830 912 831 913 cdio_log_set_handler ( cdio_log_handler ); 832 914 833 915 /* Open CDDA */ 834 if( !(p_cd dev = ioctl_Open( p_this, psz_source)) )916 if( !(p_cdio = cdio_open( psz_source, DRIVER_UNKNOWN )) ) 835 917 { 836 918 msg_Warn( p_access, "could not open %s", psz_source ); … … 845 927 return VLC_ENOMEM; 846 928 } 929 memset( p_cdda, 0, sizeof(cdda_data_t) ); 847 930 848 931 #ifdef HAVE_LIBCDDB … … 854 937 855 938 p_cdda->b_header = VLC_FALSE; 856 p_cdda->p_cddev = p_cddev; 939 p_cdda->p_cdio = p_cdio; 940 p_cdda->i_track = i_track; 857 941 p_cdda->i_debug = config_GetInt( p_this, MODULE_STRING "-debug" ); 858 942 859 printf("+++debug: %d\n", p_cdda->i_debug);860 861 943 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "%s", psz_source ); 862 863 /* We read the Table Of Content information */864 p_cdda->i_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_access),865 p_cdda->p_cddev->cdio, &p_cdda->p_sectors );866 if( p_cdda->i_tracks < 0 ) {867 msg_Err( p_access, "unable to count tracks" );868 goto error;869 } else if( p_cdda->i_tracks <= 0 ) {870 msg_Err( p_access, "no audio tracks found" );871 goto error;872 }873 944 874 945 /* Set up p_access */ … … 887 958 p_access->p_sys = (access_sys_t *) p_cdda; 888 959 889 CDDAMetaInfo(p_access); 890 891 { 892 char *psz_config_title_fmt = MODULE_STRING "-title-format"; 893 const char *psz_title_fmt = 894 config_GetPsz( p_access, psz_config_title_fmt ); 895 896 #ifdef HAVE_LIBCDDB 897 if (p_cdda->i_cddb_enabled) { 898 psz_config_title_fmt = MODULE_STRING "-cddb-title-format"; 899 } 900 #endif /*HAVE_LIBCDDB*/ 901 902 for( i = 1 ; i <= p_cdda->i_tracks ; i++ ) 903 { 904 char * psz_title; 905 input_title_t *t = p_cdda->p_title[i-1] = vlc_input_title_New(); 906 char *psz_mrl; 907 908 asprintf(&psz_mrl, "%s%s@T%u", CDDA_MRL_PREFIX, psz_source, i); 909 910 psz_title = CDDAFormatStr(p_access, p_cdda, psz_title_fmt, 911 psz_mrl, i); 912 913 t->psz_name = strdup(psz_title); 914 915 t->i_size = ( p_cdda->p_sectors[i] - p_cdda->p_sectors[i-1] ) * 916 (int64_t)CDIO_CD_FRAMESIZE_RAW; 917 918 t->i_length = I64C(1000000) * t->i_size / 44100 / 4; 919 920 dbg_print((INPUT_DBG_MRL), "track %d, start=%d, mrl %s", 921 i, p_cdda->p_sectors[i-1], psz_mrl ); 922 923 free (psz_mrl); 924 } 925 } 960 /* We read the Table Of Content information */ 961 i_rc = GetCDInfo( p_access, p_cdda ); 962 if ( VLC_SUCCESS != i_rc ) goto error; 963 964 CDDAFixupPlaylist( p_access, p_cdda, psz_source, b_single_track ); 926 965 927 966 /* Build a WAV header to put in front of the output data. … … 937 976 SetDWLE( &p_cdda->waveheader.SubChunkLength, 16); 938 977 SetWLE( &p_cdda->waveheader.Modus, 2); 939 SetDWLE( &p_cdda->waveheader.SampleFreq, 44100);978 SetDWLE( &p_cdda->waveheader.SampleFreq, CDDA_FREQUENCY_SAMPLE); 940 979 SetWLE( &p_cdda->waveheader.BytesPerSample, 941 980 2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 ); 942 981 SetDWLE( &p_cdda->waveheader.BytesPerSec, 943 2*16/8 /*BytesPerSample*/ * 44100 /*SampleFreq*/);982 2*16/8 /*BytesPerSample*/ * CDDA_FREQUENCY_SAMPLE ); 944 983 p_cdda->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a'); 945 984 p_cdda->waveheader.DataLength = 0; /* we just don't know */ … … 951 990 952 991 error: 953 ioctl_Close( p_cdda->p_cddev);992 cdio_destroy( p_cdda->p_cdio ); 954 993 free( p_cdda ); 955 994 error2: 956 995 free( psz_source ); 957 return VLC_EGENERIC;996 return i_rc; 958 997 959 998 } … … 977 1016 } 978 1017 979 ioctl_Close( p_cdda->p_cddev);1018 cdio_destroy( p_cdda->p_cdio ); 980 1019 981 1020 cdio_log_set_handler (uninit_log_handler); … … 987 1026 #endif 988 1027 989 free( p_cdda->p_ sectors );1028 free( p_cdda->p_lsns ); 990 1029 if (p_cdda->psz_mcn) free( p_cdda->psz_mcn ); 991 1030 free( p_cdda ); … … 1001 1040 { 1002 1041 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; 1003 vlc_bool_t *pb_bool;1004 1042 int *pi_int; 1005 1043 int i; … … 1015 1053 case ACCESS_GET_META: 1016 1054 { 1017 vlc_meta_t **pp_meta; 1018 pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** ); 1019 dbg_print( INPUT_DBG_META, "Meta copied"); 1020 *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta ); 1055 vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** ); 1056 if ( p_cdda->p_meta ) { 1057 *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta ); 1058 dbg_print( INPUT_DBG_META, "%s", _("Meta copied") ); 1059 } else 1060 msg_Warn( p_access, _("Tried to copy NULL meta info") ); 1061 1021 1062 return VLC_SUCCESS; 1022 1063 } … … 1026 1067 case ACCESS_CAN_FASTSEEK: 1027 1068 case ACCESS_CAN_PAUSE: 1028 case ACCESS_CAN_CONTROL_PACE: 1029 pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); 1069 case ACCESS_CAN_CONTROL_PACE: 1070 { 1071 vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); 1030 1072 *pb_bool = VLC_TRUE; 1031 1073 break; 1074 } 1032 1075 1033 1076 /* */ … … 1039 1082 case ACCESS_GET_PTS_DELAY: 1040 1083 { 1041 int64_t *pi_64; 1042 pi_64 = (int64_t*)va_arg( args, int64_t * ); 1043 *pi_64 = 1000 * var_GetInteger( p_access, 1044 MODULE_STRING "-caching" ); 1084 int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * ); 1085 *pi_64 = var_GetInteger( p_access, MODULE_STRING "-caching" ) 1086 * MILLISECONDS_PER_SEC; 1045 1087 break; 1046 1088 } … … 1059 1101 *pi_int = p_cdda->i_tracks; 1060 1102 *ppp_title = malloc(sizeof( input_title_t **) * p_cdda->i_tracks ); 1103 1104 if (!*ppp_title) return VLC_ENOMEM; 1105 1061 1106 for( i = 0; i < p_cdda->i_tracks; i++ ) 1062 1107 { 1108 if ( p_cdda->p_title[i] ) 1063 1109 (*ppp_title)[i] = 1064 1110 vlc_input_title_Duplicate( p_cdda->p_title[i] ); … … 1079 1125 1080 1126 /* Next sector to read */ 1081 p_cdda->i_ sector = p_cdda->p_sectors[i];1127 p_cdda->i_lsn = p_cdda->p_lsns[i]; 1082 1128 } 1083 1129 break; … … 1087 1133 return VLC_EGENERIC; 1088 1134 default: 1089 msg_Warn( p_access, "unimplemented query in control");1135 msg_Warn( p_access, _("unimplemented query in control") ); 1090 1136 return VLC_EGENERIC; 1091 1137 … … 1093 1139 return VLC_SUCCESS; 1094 1140 } 1141 1142 /***************************************************************************** 1143 GetCDInfo: 1144 1145 Initialize information pertaining to the CD: the number of tracks, 1146 first track number, LSNs for each track and the leadout. The leadout 1147 information is stored after the last track. The LSN array is 1148 0-origin, same as p_access->info. Add first_track to get what track 1149 number this is on the CD. Note: libcdio uses the real track number. 1150 1151 We return the VLC-type status, e.g. VLC_SUCCESS, VLC_ENOMEM, etc. 1152 *****************************************************************************/ 1153 static int 1154 GetCDInfo( access_t *p_access, cdda_data_t *p_cdda ) 1155 { 1156 track_t i; 1157 discmode_t discmode = CDIO_DISC_MODE_NO_INFO; 1158 1159 p_cdda->i_tracks = cdio_get_num_tracks(p_cdda->p_cdio); 1160 p_cdda->i_first_track = cdio_get_first_track_num(p_cdda->p_cdio); 1161 1162 discmode = cdio_get_discmode(p_cdda->p_cdio); 1163 switch(discmode) { 1164 case CDIO_DISC_MODE_CD_DA: 1165 case CDIO_DISC_MODE_CD_MIXED: 1166 /* These are possible for CD-DA */ 1167 break; 1168 default: 1169 /* These are not possible for CD-DA */ 1170 msg_Err( p_access, 1171 _("Disc seems not to be CD-DA. libcdio reports it is %s"), 1172 discmode2str[discmode] 1173 ); 1174 return VLC_EGENERIC; 1175 } 1176 1177 p_cdda->p_lsns = malloc( (p_cdda->i_tracks + 1) * sizeof(lsn_t) ); 1178 1179 if( p_cdda->p_lsns == NULL ) 1180 { 1181 msg_Err( p_access, "out of memory" ); 1182 return VLC_ENOMEM; 1183 } 1184 1185 1186 1187 /* Fill the p_lsns structure with the track/sector matches. 1188 Note cdio_get_track_lsn when given num_tracks + 1 will return 1189 the leadout LSN. 1190 */ 1191 for( i = 0 ; i <= p_cdda->i_tracks ; i++ ) 1192 { 1193 (p_cdda->p_lsns)[ i ] = 1194 cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_first_track+i); 1195 } 1196 1197 return VLC_SUCCESS; 1198 } modules/access/cdda/cdda.h
r4fcaafa r418edc0 23 23 *****************************************************************************/ 24 24 25 #include "../vcdx/cdrom.h"25 #include <cdio/cdio.h> 26 26 #include "vlc_meta.h" 27 27 … … 57 57 typedef struct cdda_data_s 58 58 { 59 cddev_t *p_cddev; /* CD device descriptor*/59 CdIo *p_cdio; /* libcdio CD device */ 60 60 int i_tracks; /* # of tracks (titles) */ 61 int i_first_track; /* # of first track */ 61 62 62 63 /* Current position */ 63 64 int i_track; /* Current track */ 64 lsn_t i_ sector; /* Current Sector */65 lsn_t * p_ sectors; /* Track sectors */65 lsn_t i_lsn; /* Current Logical Sector Number */ 66 lsn_t * p_lsns; /* Track LSNs */ 66 67 67 68 int i_debug; /* Debugging mask */
