Changeset 418edc0d35fd428561a2019652ffc2f606baa7b0

Show
Ignore:
Timestamp:
06/09/04 06:38:46 (4 years ago)
Author:
Rocky Bernstein <rocky@videolan.org>
git-committer:
Rocky Bernstein <rocky@videolan.org> 1094445526 +0000
git-parent:

[08997aa08c3f05c4fa2c1e0e803b93efdeda3ddf]

git-author:
Rocky Bernstein <rocky@videolan.org> 1094445526 +0000
Message:

2nd attempt to get libcdio cdda working.

mtime.h: define constant for second-to-millisecond conversions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/mtime.h

    re414aa3 r418edc0  
    4848#define MSTRTIME_MAX_SIZE 22 
    4949 
     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 
    5055#define msecstotimestr(psz_buffer, msecs) \ 
    51   secstotimestr( psz_buffer, (msecs / (int) 1000) ) 
     56  secstotimestr( psz_buffer, (msecs / (int) MILLISECONDS_PER_SEC) ) 
    5257 
    5358/***************************************************************************** 
  • modules/access/cdda/Modules.am

    re8f07ae r418edc0  
    11SOURCES_cddax = \ 
    2         ../vcdx/cdrom.c \ 
    3         ../vcdx/cdrom.h \ 
    42    access.c \ 
    53    cdda.c \ 
  • modules/access/cdda/access.c

    r4fcaafa r418edc0  
    3232#include <vlc/vlc.h> 
    3333#include <vlc/input.h> 
     34#include <vlc_playlist.h> 
    3435 
    3536#include <sys/types.h> 
    3637#include <cdio/cdio.h> 
     38#include <cdio/logging.h> 
    3739#include <cdio/cd_types.h> 
    3840 
     
    5254#include "cdda.h" 
    5355 
    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*/ 
    5561#define CDDA_BLOCKS_ONCE 20 
    5662#define CDDA_DATA_ONCE   (CDDA_BLOCKS_ONCE * CDIO_CD_FRAMESIZE_RAW) 
    5763 
    58 #define CDDA_MRL_PREFIX "cddax://" 
     64/* Frequency of sample in bits per second. */ 
     65#define CDDA_FREQUENCY_SAMPLE 44100 
    5966 
    6067/* FIXME: This variable is a hack. Would be nice to eliminate. */ 
     
    6976                 va_list args ); 
    7077static void     CDDAMetaInfo( access_t *p_access  ); 
     78static int      CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,  
     79                   const char *psz_source,  
     80                   vlc_bool_t b_single_track ); 
     81static 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 
     90static int      GetCDInfo( access_t *p_access, cdda_data_t *p_cdda ) ; 
     91 
     92 
     93 
    7194 
    7295/**************************************************************************** 
     
    127150uninit_log_handler (cdio_log_level_t level, const char message[]) 
    128151{ 
    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 
    130157  switch (level) { 
    131158  case CDIO_LOG_DEBUG: 
    132159  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))) 
    134161      return; 
    135162    /* Fall through if to warn case */ 
     
    167194 
    168195    dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN), "called %d",  
    169           p_cdda->i_sector); 
     196          p_cdda->i_lsn); 
    170197 
    171198    /* Check end of file */ 
     
    182209 
    183210    /* 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] ) 
    185212    { 
    186213        if( p_access->info.i_title + 1 >= p_cdda->i_tracks ) 
     
    195222      p_cdda->p_title[p_access->info.i_title]->i_size; 
    196223        p_access->info.i_pos = 0; 
     224    p_cdda->i_track++; 
    197225    } 
    198226 
    199227    /* 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] ) 
    202230    { 
    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
    205233    } 
    206234 
     
    214242    } 
    215243 
    216     if( cdio_read_audio_sectors( p_cdda->p_cddev->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 ) 
    218246        { 
    219247            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 ); 
    221249            block_Release( p_block ); 
    222250 
     
    225253           the future libcdio may have cdparanoia support. 
    226254         */ 
    227         p_cdda->i_sector++; 
     255        p_cdda->i_lsn++; 
    228256        p_access->info.i_pos += CDIO_CD_FRAMESIZE_RAW; 
    229257        return NULL; 
    230258        } 
    231259 
    232     p_cdda->i_sector     += i_blocks; 
     260    p_cdda->i_lsn     += i_blocks; 
    233261    p_access->info.i_pos += p_block->i_buffer; 
    234262 
     
    245273    cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; 
    246274 
    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] 
    248276                       + i_pos / CDIO_CD_FRAMESIZE_RAW; 
    249277    p_access->info.i_pos = i_pos; 
    250278 
    251279    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 ); 
    254282    return VLC_SUCCESS; 
    255283} 
     
    271299    int i, i_matches; 
    272300    cddb_conn_t  *conn = cddb_new(); 
    273     const CdIo *p_cdio = p_cdda->p_cddev->cdio; 
     301    const CdIo *p_cdio = p_cdda->p_cdio; 
    274302 
    275303 
     
    277305 
    278306    if (!conn) { 
    279       msg_Warn( p_access, "unable to initialize libcddb" ); 
     307      msg_Warn( p_access, _("Unable to initialize libcddb") ); 
    280308      goto cddb_destroy; 
    281309    } 
     
    314342    p_cdda->cddb.disc = cddb_disc_new(); 
    315343    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.") ); 
    317345      goto cddb_end; 
    318346    } 
     
    331359 
    332360    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") ); 
    334362      goto cddb_destroy; 
    335363    } 
     
    338366    if (i_matches > 0) { 
    339367      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.")
    341369                  i_matches); 
    342370      cddb_read(conn, p_cdda->cddb.disc); 
     
    346374 
    347375    } 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)); 
    349377    } 
    350378 
     
    357385 
    358386#define add_meta_val(FIELD, VLC_META, VAL)              \ 
    359   if ( p_cdda->p_meta ) {                     \ 
     387  if ( p_cdda->p_meta && VAL) {                       \ 
    360388    vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL );          \ 
    361389    dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL );   \ 
     
    410438    char psz_buffer[MSTRTIME_MAX_SIZE]; 
    411439    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]) 
    413441      / CDIO_CD_FRAMES_PER_SEC; 
    414442 
     
    420448      char track_str[TITLE_MAX]; 
    421449      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]) 
    423451        / CDIO_CD_FRAMES_PER_SEC; 
    424452      snprintf(track_str, TITLE_MAX, "%s %02d", _("Track"), i_track+1); 
     
    507535  size_t i; 
    508536  char * tp = temp_str; 
    509   bool saw_control_prefix = false; 
     537  vlc_bool_t saw_control_prefix = false; 
    510538  size_t format_len = strlen(format_str); 
    511539 
     
    600628        char psz_buffer[MSTRTIME_MAX_SIZE]; 
    601629        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]) 
    603631          / CDIO_CD_FRAMES_PER_SEC; 
    604632        add_format_str_info(secstotimestr( psz_buffer, i_duration ) ); 
     
    621649} 
    622650 
    623 #ifdef TRACK_META_INFORMATION_FINISHED 
    624651static void 
    625 CDDACreatePlayListItem(const input_thread_t *p_access, cdda_data_t *p_cdda, 
    626                        playlist_t *p_playlist, unsigned int i_track, 
     652CDDACreatePlaylistItem(const access_t *p_access, cdda_data_t *p_cdda, 
     653                       playlist_t *p_playlist, track_t i_track, 
    627654                       char *psz_mrl, int psz_mrl_max, 
    628655                       const char *psz_source, int playlist_operation, 
     
    630657{ 
    631658  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]) 
    633660    * (1000000 / CDIO_CD_FRAMES_PER_SEC) ; 
    634661  char *p_author; 
     
    712739 
    713740static int 
    714 CDDAFixupPlayList( access_t *p_access, cdda_data_t *p_cdda, 
    715                    const char *psz_source, track_t i_track
     741CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,  
     742          const char *psz_source, vlc_bool_t b_single_track
    716743{ 
    717744  int i; 
     745  playlist_t * p_playlist; 
    718746  char       * psz_mrl; 
    719747  unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) + 
    720748    strlen("@T") + strlen("100") + 1; 
    721749 
     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 
    722758  psz_mrl = malloc( psz_mrl_max ); 
    723759 
     
    725761    { 
    726762      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; 
    728773    } 
    729774 
    730775  CDDAMetaInfo(p_access); 
    731776 
    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
    749803 
    750804/**************************************************************************** 
     
    797851E_(CDDAOpen)( vlc_object_t *p_this ) 
    798852{ 
    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; 
    804860 
    805861    /* Set where to log errors messages from libcdio. */ 
    806862    p_cdda_input = p_access; 
    807863 
    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 ) 
    809867    { 
    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 */ 
    811892        if( !p_this->b_force ) return VLC_EGENERIC; 
    812893 
     
    817898        char **cd_drives = 
    818899          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     
    824908        psz_source = strdup(cd_drives[0]); 
    825909        cdio_free_device_list(cd_drives); 
    826910      } 
    827911    } 
    828     else  
    829       psz_source = strdup( p_access->psz_path ); 
    830912 
    831913    cdio_log_set_handler ( cdio_log_handler ); 
    832914 
    833915    /* Open CDDA */ 
    834     if( !(p_cddev = ioctl_Open( p_this, psz_source )) ) 
     916    if( !(p_cdio = cdio_open( psz_source, DRIVER_UNKNOWN )) ) 
    835917    { 
    836918        msg_Warn( p_access, "could not open %s", psz_source ); 
     
    845927        return VLC_ENOMEM; 
    846928    } 
     929    memset( p_cdda, 0, sizeof(cdda_data_t) ); 
    847930 
    848931#ifdef HAVE_LIBCDDB 
     
    854937 
    855938    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; 
    857941    p_cdda->i_debug  = config_GetInt( p_this, MODULE_STRING "-debug" ); 
    858942 
    859     printf("+++debug: %d\n", p_cdda->i_debug); 
    860  
    861943    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     } 
    873944 
    874945    /* Set up p_access */ 
     
    887958    p_access->p_sys     = (access_sys_t *) p_cdda; 
    888959 
    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 ); 
    926965     
    927966    /* Build a WAV header to put in front of the output data.  
     
    937976    SetDWLE( &p_cdda->waveheader.SubChunkLength, 16); 
    938977    SetWLE( &p_cdda->waveheader.Modus, 2); 
    939     SetDWLE( &p_cdda->waveheader.SampleFreq, 44100); 
     978    SetDWLE( &p_cdda->waveheader.SampleFreq, CDDA_FREQUENCY_SAMPLE); 
    940979    SetWLE( &p_cdda->waveheader.BytesPerSample, 
    941980            2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 ); 
    942981    SetDWLE( &p_cdda->waveheader.BytesPerSec, 
    943          2*16/8 /*BytesPerSample*/ * 44100 /*SampleFreq*/ ); 
     982         2*16/8 /*BytesPerSample*/ * CDDA_FREQUENCY_SAMPLE ); 
    944983    p_cdda->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a'); 
    945984    p_cdda->waveheader.DataLength  = 0;    /* we just don't know */ 
     
    951990 
    952991 error: 
    953     ioctl_Close( p_cdda->p_cddev ); 
     992    cdio_destroy( p_cdda->p_cdio ); 
    954993    free( p_cdda ); 
    955994 error2: 
    956995    free( psz_source ); 
    957     return VLC_EGENERIC
     996    return i_rc
    958997 
    959998} 
     
    9771016    } 
    9781017 
    979     ioctl_Close( p_cdda->p_cddev ); 
     1018    cdio_destroy( p_cdda->p_cdio ); 
    9801019 
    9811020    cdio_log_set_handler (uninit_log_handler); 
     
    9871026#endif 
    9881027 
    989     free( p_cdda->p_sectors ); 
     1028    free( p_cdda->p_lsns ); 
    9901029    if (p_cdda->psz_mcn) free( p_cdda->psz_mcn ); 
    9911030    free( p_cdda ); 
     
    10011040{ 
    10021041    cdda_data_t  *p_cdda = (cdda_data_t *) p_access->p_sys; 
    1003     vlc_bool_t   *pb_bool; 
    10041042    int          *pi_int; 
    10051043    int i; 
     
    10151053        case ACCESS_GET_META: 
    10161054      {  
    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         
    10211062        return VLC_SUCCESS; 
    10221063      } 
     
    10261067        case ACCESS_CAN_FASTSEEK: 
    10271068        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* ); 
    10301072            *pb_bool = VLC_TRUE; 
    10311073            break; 
     1074      } 
    10321075 
    10331076        /* */ 
     
    10391082        case ACCESS_GET_PTS_DELAY: 
    10401083      {  
    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; 
    10451087            break; 
    10461088      } 
     
    10591101            *pi_int = p_cdda->i_tracks; 
    10601102            *ppp_title = malloc(sizeof( input_title_t **) * p_cdda->i_tracks ); 
     1103 
     1104        if (!*ppp_title) return VLC_ENOMEM; 
     1105 
    10611106            for( i = 0; i < p_cdda->i_tracks; i++ ) 
    10621107            { 
     1108          if ( p_cdda->p_title[i] ) 
    10631109                (*ppp_title)[i] =  
    10641110          vlc_input_title_Duplicate( p_cdda->p_title[i] ); 
     
    10791125 
    10801126                /* Next sector to read */ 
    1081                 p_cdda->i_sector = p_cdda->p_sectors[i]; 
     1127                p_cdda->i_lsn = p_cdda->p_lsns[i]; 
    10821128            } 
    10831129            break; 
     
    10871133            return VLC_EGENERIC; 
    10881134        default: 
    1089             msg_Warn( p_access, "unimplemented query in control" ); 
     1135     msg_Warn( p_access, _("unimplemented query in control") ); 
    10901136            return VLC_EGENERIC; 
    10911137 
     
    10931139    return VLC_SUCCESS; 
    10941140} 
     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 *****************************************************************************/ 
     1153static int 
     1154GetCDInfo( 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  
    2323 *****************************************************************************/ 
    2424 
    25 #include "../vcdx/cdrom.h" 
     25#include <cdio/cdio.h> 
    2626#include "vlc_meta.h" 
    2727 
     
    5757typedef struct cdda_data_s 
    5858{ 
    59     cddev_t     *p_cddev;                 /* CD device descriptor */ 
     59    CdIo       *p_cdio;                   /* libcdio CD device */ 
    6060    int         i_tracks;                 /* # of tracks (titles) */ 
     61    int         i_first_track;            /* # of first track */ 
    6162 
    6263    /* Current position */ 
    6364    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 */ 
    6667 
    6768    int         i_debug;                  /* Debugging mask */