From 35a3ceeb38571b5799fed8b56683640febb4b78d Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Sat, 17 May 2003 20:30:31 +0000 Subject: [PATCH] * modules/access/cdda.c, modules/access/vcd/*: New CD digital audio module (by me and fenrir). You can now listen to your favorite CDDAs with vlc, or even stream them :) (Their is not yet any support for jitter correction). * modules/codec/araw.c: small clean-up. --- configure.ac.in | 12 +- modules/access/Modules.am | 6 + modules/access/cdda.c | 510 +++++++++++++++++++++++++++ modules/access/vcd/Modules.am | 2 +- modules/access/vcd/cdrom.c | 51 +-- modules/access/vcd/cdrom.h | 224 +++--------- modules/access/vcd/cdrom_internals.h | 212 +++++++++++ modules/access/vcd/vcd.c | 48 ++- modules/access/vcd/vcd.h | 89 ----- modules/codec/araw.c | 31 +- 10 files changed, 838 insertions(+), 347 deletions(-) create mode 100644 modules/access/cdda.c create mode 100644 modules/access/vcd/cdrom_internals.h delete mode 100644 modules/access/vcd/vcd.h diff --git a/configure.ac.in b/configure.ac.in index dc84585b83..ba3032337e 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -85,6 +85,7 @@ case "x${target_os}" in LDFLAGS_dvd="${LDFLAGS_dvd} -ldvd" LDFLAGS_dvdcss="${LDFLAGS_dvdcss} -ldvd" LDFLAGS_vcd="${LDFLAGS_vcd} -ldvd" + LDFLAGS_cdda="${LDFLAGS_cdda} -ldvd" ;; x*bsd*) SYS="${target_os}" @@ -1357,7 +1358,7 @@ then AC_MSG_CHECKING(for cdrom_msf0 in linux/cdrom.h) AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[ AC_MSG_RESULT(yes) - PLUGINS="${PLUGINS} vcd" + PLUGINS="${PLUGINS} vcd cdda" ],[ AC_MSG_RESULT(no) ]) @@ -1365,7 +1366,7 @@ then AC_MSG_CHECKING(for scsireq in sys/scsiio.h) AC_EGREP_HEADER(scsireq,sys/scsiio.h,[ AC_MSG_RESULT(yes) - PLUGINS="${PLUGINS} vcd" + PLUGINS="${PLUGINS} vcd cdda" AC_DEFINE(HAVE_SCSIREQ_IN_SYS_SCSIIO_H, 1, For NetBSD VCD support) ],[ AC_MSG_RESULT(no) @@ -1374,7 +1375,7 @@ then AC_MSG_CHECKING(for ioc_toc_header in sys/cdio.h) AC_EGREP_HEADER(ioc_toc_header ,sys/cdio.h,[ AC_MSG_RESULT(yes) - PLUGINS="${PLUGINS} vcd" + PLUGINS="${PLUGINS} vcd cdda" AC_DEFINE(HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H, 1, For FreeBSD VCD support) ],[ AC_MSG_RESULT(no) @@ -1382,13 +1383,14 @@ then if test "x${SYS}" = "xbsdi" -o "x${SYS}" = "xmingw32" then - PLUGINS="${PLUGINS} vcd" + PLUGINS="${PLUGINS} vcd cdda" fi if test "x${SYS}" = "xdarwin" then - PLUGINS="${PLUGINS} vcd" + PLUGINS="${PLUGINS} vcd cdda" LDFLAGS_vcd="${LDFLAGS_vcd} -framework IOKit -framework CoreFoundation" + LDFLAGS_cdda="${LDFLAGS_cdda} -framework IOKit -framework CoreFoundation" fi fi diff --git a/modules/access/Modules.am b/modules/access/Modules.am index 8871217e6c..9a0714c5d8 100644 --- a/modules/access/Modules.am +++ b/modules/access/Modules.am @@ -4,3 +4,9 @@ SOURCES_access_udp = modules/access/udp.c SOURCES_access_http = modules/access/http.c SOURCES_access_ftp = modules/access/ftp.c SOURCES_slp = modules/access/slp.c +SOURCES_cdda = \ + modules/access/cdda.c \ + modules/access/vcd/cdrom.c \ + modules/access/vcd/cdrom.h \ + modules/access/vcd/cdrom_internals.h \ + $(NULL) diff --git a/modules/access/cdda.c b/modules/access/cdda.c new file mode 100644 index 0000000000..688dfcaa15 --- /dev/null +++ b/modules/access/cdda.c @@ -0,0 +1,510 @@ +/***************************************************************************** + * cdda.c : CD digital audio input module for vlc + ***************************************************************************** + * Copyright (C) 2000 VideoLAN + * $Id: cdda.c,v 1.1 2003/05/17 20:30:31 gbazin Exp $ + * + * Authors: Laurent Aimar + * Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include +#include + +#include +#include +#include + +#include "codecs.h" + +#ifdef HAVE_UNISTD_H +# include +#endif + +#include + +#include "vcd/cdrom.h" + +/* how many blocks VCDRead will read in each loop */ +#define CDDA_BLOCKS_ONCE 20 +#define CDDA_DATA_ONCE (CDDA_BLOCKS_ONCE * CDDA_DATA_SIZE) + +/***************************************************************************** + * cdda_data_t: CD audio information + *****************************************************************************/ +typedef struct cdda_data_s +{ + vcddev_t *vcddev; /* vcd device descriptor */ + int i_nb_tracks; /* Nb of tracks (titles) */ + int i_track; /* Current track */ + int i_sector; /* Current Sector */ + int * p_sectors; /* Track sectors */ + vlc_bool_t b_end_of_track; /* If the end of track was reached */ + +} cdda_data_t; + +struct demux_sys_t +{ + es_descriptor_t *p_es; + mtime_t i_pts; +}; + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +static int CDDAOpen ( vlc_object_t * ); +static void CDDAClose ( vlc_object_t * ); +static int CDDARead ( input_thread_t *, byte_t *, size_t ); +static void CDDASeek ( input_thread_t *, off_t ); +static int CDDASetArea ( input_thread_t *, input_area_t * ); +static int CDDASetProgram ( input_thread_t *, pgrm_descriptor_t * ); + +static int CDDAOpenDemux ( vlc_object_t * ); +static void CDDACloseDemux ( vlc_object_t * ); +static int CDDADemux ( input_thread_t * p_input ); + +/***************************************************************************** + * Module descriptior + *****************************************************************************/ +#define CACHING_TEXT N_("Caching value in ms") +#define CACHING_LONGTEXT N_( \ + "Allows you to modify the default caching value for cdda streams. This " \ + "value should be set in miliseconds units." ) + +vlc_module_begin(); + set_description( _("CD Audio input") ); + add_integer( "cdda-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); + set_capability( "access", 80 ); + set_callbacks( CDDAOpen, CDDAClose ); + add_shortcut( "cdda" ); + + add_submodule(); + set_description( _("CD Audio demux") ); + set_capability( "demux", 0 ); + set_callbacks( CDDAOpenDemux, CDDACloseDemux ); + add_shortcut( "cdda" ); +vlc_module_end(); + +/***************************************************************************** + * CDDAOpen: open cdda + *****************************************************************************/ +static int CDDAOpen( vlc_object_t *p_this ) +{ + input_thread_t * p_input = (input_thread_t *)p_this; + char * psz_orig; + char * psz_parser; + char * psz_source; + cdda_data_t * p_cdda; + int i; + input_area_t * p_area; + int i_title = 1; + vcddev_t *vcddev; + +#ifdef WIN32 + /* On Win32 we want the CDDA access plugin to be explicitly requested, + * we end up with lots of problems otherwise */ + if( !p_input->psz_access || !*p_input->psz_access ) return( -1 ); +#endif + + /* parse the options passed in command line : */ + psz_orig = psz_parser = psz_source = strdup( p_input->psz_name ); + + if( !psz_orig ) + { + return( -1 ); + } + + while( *psz_parser && *psz_parser != '@' ) + { + psz_parser++; + } + + if( *psz_parser == '@' ) + { + /* Found options */ + *psz_parser = '\0'; + ++psz_parser; + + i_title = (int)strtol( psz_parser, NULL, 10 ); + i_title = i_title ? i_title : 1; + } + + if( !*psz_source ) + { + if( !p_input->psz_access ) + { + free( psz_orig ); + return -1; + } + psz_source = config_GetPsz( p_input, "vcd" ); + if( !psz_source ) return -1; + } + + /* Open CDDA */ + if( !(vcddev = ioctl_Open( p_this, psz_source )) ) + { + msg_Warn( p_input, "could not open %s", psz_source ); + free( psz_source ); + return -1; + } + free( psz_source ); + + p_cdda = malloc( sizeof(cdda_data_t) ); + if( p_cdda == NULL ) + { + msg_Err( p_input, "out of memory" ); + free( psz_source ); + return -1; + } + + p_cdda->vcddev = vcddev; + p_input->p_access_data = (void *)p_cdda; + + p_input->i_mtu = CDDA_DATA_ONCE; + + /* We read the Table Of Content information */ + p_cdda->i_nb_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input), + p_cdda->vcddev, &p_cdda->p_sectors ); + if( p_cdda->i_nb_tracks < 0 ) + msg_Err( p_input, "unable to count tracks" ); + else if( p_cdda->i_nb_tracks <= 0 ) + msg_Err( p_input, "no audio tracks found" ); + + if( p_cdda->i_nb_tracks <= 1) + { + ioctl_Close( p_this, p_cdda->vcddev ); + free( p_cdda ); + return -1; + } + + if( i_title >= p_cdda->i_nb_tracks || i_title < 1 ) + i_title = 1; + + /* Set stream and area data */ + vlc_mutex_lock( &p_input->stream.stream_lock ); + + /* Initialize ES structures */ + input_InitStream( p_input, 0 ); + + /* cdda input method */ + p_input->stream.i_method = INPUT_METHOD_CDDA; + + p_input->stream.b_pace_control = 1; + p_input->stream.b_seekable = 1; + p_input->stream.i_mux_rate = 44100 * 4 / 50; + +#define area p_input->stream.pp_areas + for( i = 1 ; i <= p_cdda->i_nb_tracks ; i++ ) + { + input_AddArea( p_input, i, 1 ); + + /* Absolute start offset and size */ + area[i]->i_start = + (off_t)p_cdda->p_sectors[i-1] * (off_t)CDDA_DATA_SIZE; + area[i]->i_size = + (off_t)(p_cdda->p_sectors[i] - p_cdda->p_sectors[i-1]) + * (off_t)CDDA_DATA_SIZE; + } +#undef area + + p_area = p_input->stream.pp_areas[i_title]; + + CDDASetArea( p_input, p_area ); + + vlc_mutex_unlock( &p_input->stream.stream_lock ); + + if( !p_input->psz_demux || !*p_input->psz_demux ) + { + p_input->psz_demux = "cdda"; + } + + p_input->pf_read = CDDARead; + p_input->pf_seek = CDDASeek; + p_input->pf_set_area = CDDASetArea; + p_input->pf_set_program = CDDASetProgram; + + return 0; +} + +/***************************************************************************** + * CDDAClose: closes cdda + *****************************************************************************/ +static void CDDAClose( vlc_object_t *p_this ) +{ + input_thread_t * p_input = (input_thread_t *)p_this; + cdda_data_t *p_cdda = (cdda_data_t *)p_input->p_access_data; + + ioctl_Close( p_this, p_cdda->vcddev ); + free( p_cdda ); +} + +/***************************************************************************** + * CDDARead: reads from the CDDA into PES packets. + ***************************************************************************** + * Returns -1 in case of error, 0 in case of EOF, otherwise the number of + * bytes. + *****************************************************************************/ +static int CDDARead( input_thread_t * p_input, byte_t * p_buffer, + size_t i_len ) +{ + cdda_data_t * p_cdda; + int i_blocks; + int i_index; + int i_read; + + p_cdda = (cdda_data_t *)p_input->p_access_data; + + i_read = 0; + + /* Compute the number of blocks we have to read */ + + i_blocks = i_len / CDDA_DATA_SIZE; + + for ( i_index = 0; i_index < i_blocks; i_index++ ) + { + if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_cdda->vcddev, + p_cdda->i_sector, p_buffer + i_index * CDDA_DATA_SIZE, + CDDA_DATA_START, CDDA_DATA_SIZE ) < 0 ) + { + msg_Err( p_input, "could not read sector %d", p_cdda->i_sector ); + return -1; + } + + p_cdda->i_sector ++; + if ( p_cdda->i_sector == p_cdda->p_sectors[p_cdda->i_track + 1] ) + { + input_area_t *p_area; + + if ( p_cdda->i_track >= p_cdda->i_nb_tracks - 1 ) + return 0; /* EOF */ + + vlc_mutex_lock( &p_input->stream.stream_lock ); + p_area = p_input->stream.pp_areas[ + p_input->stream.p_selected_area->i_id + 1 ]; + + msg_Dbg( p_input, "new title" ); + + p_area->i_part = 1; + CDDASetArea( p_input, p_area ); + vlc_mutex_unlock( &p_input->stream.stream_lock ); + } + i_read += CDDA_DATA_SIZE; + } + + if ( i_len % CDDA_DATA_SIZE ) /* this should not happen */ + { + msg_Err( p_input, "must read full sectors" ); + } + + return i_read; +} + + +/***************************************************************************** + * CDDASetProgram: Does nothing since a CDDA is mono_program + *****************************************************************************/ +static int CDDASetProgram( input_thread_t * p_input, + pgrm_descriptor_t * p_program) +{ + return 0; +} + + +/***************************************************************************** + * CDDASetArea: initialize input data for title x. + * It should be called for each user navigation request. + ****************************************************************************/ +static int CDDASetArea( input_thread_t * p_input, input_area_t * p_area ) +{ + cdda_data_t *p_cdda = (cdda_data_t*)p_input->p_access_data; + vlc_value_t val; + + /* we can't use the interface slider until initilization is complete */ + p_input->stream.b_seekable = 0; + + if( p_area != p_input->stream.p_selected_area ) + { + /* Change the default area */ + p_input->stream.p_selected_area = p_area; + + /* Change the current track */ + p_cdda->i_track = p_area->i_id - 1; + p_cdda->i_sector = p_cdda->p_sectors[p_cdda->i_track]; + + /* Update the navigation variables without triggering a callback */ + val.i_int = p_area->i_id; + var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL ); + } + + p_cdda->i_sector = p_cdda->p_sectors[p_cdda->i_track]; + + p_input->stream.p_selected_area->i_tell = + (off_t)p_cdda->i_sector * (off_t)CDDA_DATA_SIZE + - p_input->stream.p_selected_area->i_start; + + /* warn interface that something has changed */ + p_input->stream.b_seekable = 1; + p_input->stream.b_changed = 1; + + return 0; +} + + +/**************************************************************************** + * CDDASeek + ****************************************************************************/ +static void CDDASeek( input_thread_t * p_input, off_t i_off ) +{ + cdda_data_t * p_cdda; + + p_cdda = (cdda_data_t *) p_input->p_access_data; + + p_cdda->i_sector = p_cdda->p_sectors[p_cdda->i_track] + + i_off / (off_t)CDDA_DATA_SIZE; + + vlc_mutex_lock( &p_input->stream.stream_lock ); + p_input->stream.p_selected_area->i_tell = + (off_t)p_cdda->i_sector * (off_t)CDDA_DATA_SIZE + - p_input->stream.p_selected_area->i_start; + vlc_mutex_unlock( &p_input->stream.stream_lock ); +} + +/**************************************************************************** + * Demux Part + ****************************************************************************/ +static int CDDAOpenDemux ( vlc_object_t * p_this) +{ + input_thread_t *p_input = (input_thread_t *)p_this; + demux_sys_t *p_demux; + WAVEFORMATEX *p_wf; + + if( p_input->stream.i_method != INPUT_METHOD_CDDA ) + { + return VLC_EGENERIC; + } + + p_demux = malloc( sizeof( es_descriptor_t ) ); + p_demux->i_pts = 0; + p_demux->p_es = NULL; + + p_input->pf_demux = CDDADemux; + p_input->pf_rewind = NULL; + p_input->p_demux_data = p_demux; + + vlc_mutex_lock( &p_input->stream.stream_lock ); + if( input_AddProgram( p_input, 0, 0) == NULL ) + { + msg_Err( p_input, "cannot add program" ); + free( p_input->p_demux_data ); + return( -1 ); + } + p_input->stream.pp_programs[0]->b_is_ok = 0; + p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; + + /* create our ES */ + p_demux->p_es = input_AddES( p_input, + p_input->stream.p_selected_program, + 1 /* id */, AUDIO_ES, NULL, 0 ); + if( !p_demux->p_es ) + { + vlc_mutex_unlock( &p_input->stream.stream_lock ); + msg_Err( p_input, "out of memory" ); + free( p_input->p_demux_data ); + return( -1 ); + } + p_demux->p_es->i_stream_id = 1; + p_demux->p_es->i_fourcc = VLC_FOURCC('a','r','a','w'); + + p_demux->p_es->p_waveformatex = p_wf = malloc( sizeof( WAVEFORMATEX ) ); + p_wf->wFormatTag = WAVE_FORMAT_PCM; + p_wf->nChannels = 2; + p_wf->nSamplesPerSec = 44100; + p_wf->nAvgBytesPerSec = 2 * 44100 * 2; + p_wf->nBlockAlign = 4; + p_wf->wBitsPerSample = 16; + p_wf->cbSize = 0; + + input_SelectES( p_input, p_demux->p_es ); + + p_input->stream.p_selected_program->b_is_ok = 1; + vlc_mutex_unlock( &p_input->stream.stream_lock ); + + return VLC_SUCCESS; +} + +static void CDDACloseDemux( vlc_object_t * p_this) +{ + input_thread_t *p_input = (input_thread_t*)p_this; + demux_sys_t *p_demux = (demux_sys_t*)p_input->p_demux_data; + + free( p_demux ); + p_input->p_demux_data = NULL; + return; +} + +static int CDDADemux( input_thread_t * p_input ) +{ + demux_sys_t *p_demux = (demux_sys_t*)p_input->p_demux_data; + ssize_t i_read; + data_packet_t * p_data; + pes_packet_t * p_pes; + + input_ClockManageRef( p_input, + p_input->stream.p_selected_program, + p_demux->i_pts ); + + if( ( i_read = input_SplitBuffer( p_input, &p_data, CDDA_DATA_SIZE ) ) + <= 0 ) + { + return 0; // EOF + } + + p_pes = input_NewPES( p_input->p_method_data ); + + if( p_pes == NULL ) + { + msg_Err( p_input, "out of memory" ); + input_DeletePacket( p_input->p_method_data, p_data ); + return -1; + } + + p_pes->i_rate = p_input->stream.control.i_rate; + p_pes->p_first = p_pes->p_last = p_data; + p_pes->i_nb_data = 1; + p_pes->i_pes_size = i_read; + + p_pes->i_dts = + p_pes->i_pts = input_ClockGetTS( p_input, + p_input->stream.p_selected_program, + p_demux->i_pts ); + + if( p_demux->p_es->p_decoder_fifo ) + { + input_DecodePES( p_demux->p_es->p_decoder_fifo, p_pes ); + } + else + { + input_DeletePES( p_input->p_method_data, p_pes ); + } + + p_demux->i_pts += ((mtime_t)90000) * i_read + / (mtime_t)44100 / 4 /* stereo 16 bits */; + return 1; +} diff --git a/modules/access/vcd/Modules.am b/modules/access/vcd/Modules.am index 6f605d3231..d33d2bfe1a 100644 --- a/modules/access/vcd/Modules.am +++ b/modules/access/vcd/Modules.am @@ -1,6 +1,6 @@ SOURCES_vcd = \ modules/access/vcd/vcd.c \ - modules/access/vcd/vcd.h \ modules/access/vcd/cdrom.c \ modules/access/vcd/cdrom.h \ + modules/access/vcd/cdrom_internals.h \ $(NULL) diff --git a/modules/access/vcd/cdrom.c b/modules/access/vcd/cdrom.c index 4a7a3ecc2b..be74917d06 100644 --- a/modules/access/vcd/cdrom.c +++ b/modules/access/vcd/cdrom.c @@ -2,7 +2,7 @@ * cdrom.c: cdrom tools ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: cdrom.c,v 1.8 2003/03/10 00:12:53 gbazin Exp $ + * $Id: cdrom.c,v 1.9 2003/05/17 20:30:31 gbazin Exp $ * * Authors: Johan Bilien * Gildas Bazin @@ -67,8 +67,8 @@ # include #endif +#include "cdrom_internals.h" #include "cdrom.h" -#include "vcd.h" /***************************************************************************** * ioctl_Open: Opens a VCD device or file and returns an opaque handle @@ -542,10 +542,11 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev, } /**************************************************************************** - * ioctl_ReadSector: Read a sector (2324 bytes) + * ioctl_ReadSector: Read a sector (2352 bytes - i_start) ****************************************************************************/ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, - int i_sector, byte_t * p_buffer ) + int i_sector, byte_t * p_buffer, size_t i_start, + size_t i_len ) { byte_t p_block[ VCD_SECTOR_SIZE ]; @@ -569,7 +570,7 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, } /* We don't want to keep the header of the read sector */ - memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); + memcpy( p_buffer, p_block + i_start, i_len ); return 0; } @@ -627,6 +628,9 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, /* Operation code */ ssc.CDBByte[ 0 ] = READ_CD; + /* Sector type */ + ssc.CDBByte[ 1 ] = SECTOR_TYPE_MODE2_FORM2; + /* Start of LBA */ ssc.CDBByte[ 2 ] = ( i_sector >> 24 ) & 0xff; ssc.CDBByte[ 3 ] = ( i_sector >> 16 ) & 0xff; @@ -639,7 +643,7 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, ssc.CDBByte[ 8 ] = 1; /* Data selection */ - ssc.CDBByte[ 9 ] = READ_CD_USERDATA_MODE2; + ssc.CDBByte[ 9 ] = READ_CD_RAW_MODE2; /* Result buffer */ ssc.SRB_BufPointer = p_block; @@ -662,10 +666,6 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, { return -1; } - - /* We don't want to keep the footer of the read sector */ - memcpy( p_buffer, p_block, VCD_DATA_SIZE ); - return 0; } else { @@ -685,11 +685,6 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, { return -1; } - - /* We don't want to keep the header of the read sector */ - memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); - - return 0; } #elif defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) @@ -698,17 +693,9 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, int i_blocks = 1; int i_ret; - int sector_type = 5; /* mode2/form2 */ - int sync = 0, - header_code = 0, - user_data = 1, - edc_ecc = 0, - error_field = 0; - int sub_channel = 0; - memset( &sc, 0, sizeof(sc) ); sc.cmd[0] = 0xBE; - sc.cmd[1] = (sector_type) << 2; + sc.cmd[1] = SECTOR_TYPE_MODE2_FORM2; sc.cmd[2] = (i_sector >> 24) & 0xff; sc.cmd[3] = (i_sector >> 16) & 0xff; sc.cmd[4] = (i_sector >> 8) & 0xff; @@ -716,12 +703,11 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, sc.cmd[6] = (i_blocks >> 16) & 0xff; sc.cmd[7] = (i_blocks >> 8) & 0xff; sc.cmd[8] = (i_blocks >> 0) & 0xff; - sc.cmd[9] = (sync << 7) | (header_code << 5) | (user_data << 4) | - (edc_ecc << 3) | (error_field << 1); - sc.cmd[10] = sub_channel; + sc.cmd[9] = READ_CD_RAW_MODE2; + sc.cmd[10] = 0; /* sub channel */ sc.cmdlen = 12; sc.databuf = (caddr_t)p_block; - sc.datalen = VCD_SECTOR_SIZE; // was 2328 == VCD_DATA_SIZE + 4; + sc.datalen = VCD_SECTOR_SIZE; sc.senselen = sizeof( sc.sense ); sc.flags = SCCMD_READ; sc.timeout = 10000; @@ -779,13 +765,8 @@ int ioctl_ReadSector( vlc_object_t *p_this, const vcddev_t *p_vcddev, } #endif -#if defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) - /* FIXME: is this ok? */ - memcpy( p_buffer, p_block, VCD_DATA_SIZE ); -#else /* We don't want to keep the header of the read sector */ - memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); -#endif + memcpy( p_buffer, p_block + i_start, i_len ); return( 0 ); } @@ -832,7 +813,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev, } /* Open the cue file and try to parse it */ - msg_Dbg( p_this,"using .cue file: %s", psz_cuefile ); + msg_Dbg( p_this,"trying .cue file: %s", psz_cuefile ); cuefile = fopen( psz_cuefile, "rt" ); if( cuefile && fscanf( cuefile, "FILE %c", line ) && fgets( line, 1024, cuefile ) ) diff --git a/modules/access/vcd/cdrom.h b/modules/access/vcd/cdrom.h index afee0177e7..9aba916311 100644 --- a/modules/access/vcd/cdrom.h +++ b/modules/access/vcd/cdrom.h @@ -2,7 +2,7 @@ * cdrom.h: cdrom tools header ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: cdrom.h,v 1.4 2002/10/16 23:12:46 massiot Exp $ + * $Id: cdrom.h,v 1.5 2003/05/17 20:30:31 gbazin Exp $ * * Authors: Johan Bilien * Gildas Bazin @@ -22,32 +22,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ -/***************************************************************************** - * The vcddev structure - *****************************************************************************/ -typedef struct vcddev_s -{ - char *psz_dev; /* vcd device name */ - - /* Section used in vcd image mode */ - int i_vcdimage_handle; /* vcd image file descriptor */ - int i_tracks; /* number of tracks of the vcd */ - int *p_sectors; /* tracks layout on the vcd */ - - /* Section used in vcd device mode */ - -#ifdef WIN32 - HANDLE h_device_handle; /* vcd device descriptor */ - long hASPI; - short i_sid; - long (*lpSendCommand)( void* ); - -#else - int i_device_handle; /* vcd device descriptor */ -#endif - -} vcddev_t; - +/* where the data start on a VCD sector */ +#define VCD_DATA_START 24 +/* size of the availablr data on a VCD sector */ +#define VCD_DATA_SIZE 2324 +/* size of a VCD sector, header and tail included */ +#define VCD_SECTOR_SIZE 2352 +/* size of a CD sector */ +#define CD_SECTOR_SIZE 2048 +/* sector containing the entry points */ +#define VCD_ENTRIES_SECTOR 151 + +/* where the data start on a CDDA sector */ +#define CDDA_DATA_START 0 +/* size of the availablr data on a CDDA sector */ +#define CDDA_DATA_SIZE 2352 +/* size of a CDDA sector, header and tail included */ +#define CDDA_SECTOR_SIZE 2352 /***************************************************************************** * Misc. Macros @@ -56,157 +47,48 @@ typedef struct vcddev_s #define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min)) /* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */ #define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min)) +/* Converts BCD to Binary data */ +#define BCD_TO_BIN(i) \ + (uint8_t)((uint8_t)(0xf & (uint8_t)i)+((uint8_t)10*((uint8_t)i >> 4))) -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -#define VCDDEV_T 1 +typedef struct vcddev_s vcddev_t; /***************************************************************************** - * Platform specifics + * structure to store minute/second/frame locations *****************************************************************************/ -#if defined( SYS_DARWIN ) -#define darwin_freeTOC( p ) free( (void*)p ) -#define CD_MIN_TRACK_NO 01 -#define CD_MAX_TRACK_NO 99 -#endif - -#if defined( WIN32 ) - -/* Win32 DeviceIoControl specifics */ -#ifndef MAXIMUM_NUMBER_TRACKS -# define MAXIMUM_NUMBER_TRACKS 100 -#endif -typedef struct _TRACK_DATA { - UCHAR Reserved; - UCHAR Control : 4; - UCHAR Adr : 4; - UCHAR TrackNumber; - UCHAR Reserved1; - UCHAR Address[4]; -} TRACK_DATA, *PTRACK_DATA; -typedef struct _CDROM_TOC { - UCHAR Length[2]; - UCHAR FirstTrack; - UCHAR LastTrack; - TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]; -} CDROM_TOC, *PCDROM_TOC; -typedef enum _TRACK_MODE_TYPE { - YellowMode2, - XAForm2, - CDDA -} TRACK_MODE_TYPE, *PTRACK_MODE_TYPE; -typedef struct __RAW_READ_INFO { - LARGE_INTEGER DiskOffset; - ULONG SectorCount; - TRACK_MODE_TYPE TrackMode; -} RAW_READ_INFO, *PRAW_READ_INFO; - -#ifndef IOCTL_CDROM_BASE -# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM -#endif -#ifndef IOCTL_CDROM_READ_TOC -# define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, \ - METHOD_BUFFERED, FILE_READ_ACCESS) -#endif -#ifndef IOCTL_CDROM_RAW_READ -#define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \ - METHOD_OUT_DIRECT, FILE_READ_ACCESS) -#endif - -/* Win32 aspi specific */ -#define WIN_NT ( GetVersion() < 0x80000000 ) -#define ASPI_HAID 0 -#define ASPI_TARGET 0 -#define DTYPE_CDROM 0x05 - -#define SENSE_LEN 0x0E -#define SC_GET_DEV_TYPE 0x01 -#define SC_EXEC_SCSI_CMD 0x02 -#define SC_GET_DISK_INFO 0x06 -#define SS_COMP 0x01 -#define SS_PENDING 0x00 -#define SS_NO_ADAPTERS 0xE8 -#define SRB_DIR_IN 0x08 -#define SRB_DIR_OUT 0x10 -#define SRB_EVENT_NOTIFY 0x40 - -#define READ_CD 0xbe -#define SECTOR_TYPE_MODE2 0x14 -#define READ_CD_USERDATA_MODE2 0x10 - -#define READ_TOC 0x43 -#define READ_TOC_FORMAT_TOC 0x0 - -#pragma pack(1) - -struct SRB_GetDiskInfo -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned char SRB_DriveFlags; - unsigned char SRB_Int13HDriveInfo; - unsigned char SRB_Heads; - unsigned char SRB_Sectors; - unsigned char SRB_Rsvd1[22]; -}; - -struct SRB_GDEVBlock +typedef struct msf_s { - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned char SRB_DeviceType; - unsigned char SRB_Rsvd1; -}; + uint8_t minute; + uint8_t second; + uint8_t frame; +} msf_t; -struct SRB_ExecSCSICmd +/***************************************************************************** + * entries_sect structure: the sector containing entry points + *****************************************************************************/ +typedef struct entries_sect_s { - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned short SRB_Rsvd1; - unsigned long SRB_BufLen; - unsigned char *SRB_BufPointer; - unsigned char SRB_SenseLen; - unsigned char SRB_CDBLen; - unsigned char SRB_HaStat; - unsigned char SRB_TargStat; - unsigned long *SRB_PostProc; - unsigned char SRB_Rsvd2[20]; - unsigned char CDBByte[16]; - unsigned char SenseArea[SENSE_LEN+2]; -}; - -#pragma pack() -#endif /* WIN32 */ - + uint8_t psz_id[8]; /* "ENTRYVCD" */ + uint8_t i_version; /* 0x02 VCD2.0 + 0x01 SVCD */ + uint8_t i_sys_prof_tag; /* 0x01 if VCD1.1 + 0x00 else */ + uint16_t i_entries_nb; /* entries number <= 500 */ + + struct + { + uint8_t i_track; /* track number */ + msf_t msf; /* msf location + (in BCD format) */ + } entry[500]; + uint8_t zeros[36]; /* should be 0x00 */ +} entries_sect_t; /***************************************************************************** - * Local Prototypes + * Prototypes *****************************************************************************/ -static int OpenVCDImage( vlc_object_t *, const char *, vcddev_t * ); -static void CloseVCDImage( vlc_object_t *, vcddev_t * ); - -#if defined( SYS_DARWIN ) -static CDTOC *darwin_getTOC( vlc_object_t *, const vcddev_t * ); -static int darwin_getNumberOfDescriptors( CDTOC * ); -static int darwin_getNumberOfTracks( CDTOC *, int ); - -#elif defined( WIN32 ) -static int win32_vcd_open( vlc_object_t *, const char *, vcddev_t * ); -#endif +vcddev_t *ioctl_Open ( vlc_object_t *, const char * ); +void ioctl_Close ( vlc_object_t *, vcddev_t * ); +int ioctl_GetTracksMap ( vlc_object_t *, const vcddev_t *, int ** ); +int ioctl_ReadSector ( vlc_object_t *, const vcddev_t *, + int, byte_t *, size_t, size_t ); diff --git a/modules/access/vcd/cdrom_internals.h b/modules/access/vcd/cdrom_internals.h new file mode 100644 index 0000000000..6943fc13fd --- /dev/null +++ b/modules/access/vcd/cdrom_internals.h @@ -0,0 +1,212 @@ +/**************************************************************************** + * cdrom_internals.h: cdrom tools private header + ***************************************************************************** + * Copyright (C) 1998-2001 VideoLAN + * $Id: cdrom_internals.h,v 1.1 2003/05/17 20:30:31 gbazin Exp $ + * + * Authors: Johan Bilien + * Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * The vcddev structure + *****************************************************************************/ +struct vcddev_s +{ + char *psz_dev; /* vcd device name */ + + /* Section used in vcd image mode */ + int i_vcdimage_handle; /* vcd image file descriptor */ + int i_tracks; /* number of tracks of the vcd */ + int *p_sectors; /* tracks layout on the vcd */ + + /* Section used in vcd device mode */ + +#ifdef WIN32 + HANDLE h_device_handle; /* vcd device descriptor */ + long hASPI; + short i_sid; + long (*lpSendCommand)( void* ); + +#else + int i_device_handle; /* vcd device descriptor */ +#endif + +}; + + +/***************************************************************************** + * Misc. Macros + *****************************************************************************/ +/* LBA = msf.frame + 75 * ( msf.second + 60 * msf.minute ) */ +#define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min)) +/* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */ +#define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min)) + +#ifndef O_BINARY +# define O_BINARY 0 +#endif + +#define VCDDEV_T 1 + +/***************************************************************************** + * Platform specifics + *****************************************************************************/ +#if defined( SYS_DARWIN ) +#define darwin_freeTOC( p ) free( (void*)p ) +#define CD_MIN_TRACK_NO 01 +#define CD_MAX_TRACK_NO 99 +#endif + +#if defined( WIN32 ) + +/* Win32 DeviceIoControl specifics */ +#ifndef MAXIMUM_NUMBER_TRACKS +# define MAXIMUM_NUMBER_TRACKS 100 +#endif +typedef struct _TRACK_DATA { + UCHAR Reserved; + UCHAR Control : 4; + UCHAR Adr : 4; + UCHAR TrackNumber; + UCHAR Reserved1; + UCHAR Address[4]; +} TRACK_DATA, *PTRACK_DATA; +typedef struct _CDROM_TOC { + UCHAR Length[2]; + UCHAR FirstTrack; + UCHAR LastTrack; + TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]; +} CDROM_TOC, *PCDROM_TOC; +typedef enum _TRACK_MODE_TYPE { + YellowMode2, + XAForm2, + CDDA +} TRACK_MODE_TYPE, *PTRACK_MODE_TYPE; +typedef struct __RAW_READ_INFO { + LARGE_INTEGER DiskOffset; + ULONG SectorCount; + TRACK_MODE_TYPE TrackMode; +} RAW_READ_INFO, *PRAW_READ_INFO; + +#ifndef IOCTL_CDROM_BASE +# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM +#endif +#ifndef IOCTL_CDROM_READ_TOC +# define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, \ + METHOD_BUFFERED, FILE_READ_ACCESS) +#endif +#ifndef IOCTL_CDROM_RAW_READ +#define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \ + METHOD_OUT_DIRECT, FILE_READ_ACCESS) +#endif + +/* Win32 aspi specific */ +#define WIN_NT ( GetVersion() < 0x80000000 ) +#define ASPI_HAID 0 +#define ASPI_TARGET 0 +#define DTYPE_CDROM 0x05 + +#define SENSE_LEN 0x0E +#define SC_GET_DEV_TYPE 0x01 +#define SC_EXEC_SCSI_CMD 0x02 +#define SC_GET_DISK_INFO 0x06 +#define SS_COMP 0x01 +#define SS_PENDING 0x00 +#define SS_NO_ADAPTERS 0xE8 +#define SRB_DIR_IN 0x08 +#define SRB_DIR_OUT 0x10 +#define SRB_EVENT_NOTIFY 0x40 + +#define READ_CD 0xbe +#define SECTOR_TYPE_MODE2_FORM2 0x14 +#define READ_CD_RAW_MODE2 0xF0 + +#define READ_TOC 0x43 +#define READ_TOC_FORMAT_TOC 0x0 + +#pragma pack(1) + +struct SRB_GetDiskInfo +{ + unsigned char SRB_Cmd; + unsigned char SRB_Status; + unsigned char SRB_HaId; + unsigned char SRB_Flags; + unsigned long SRB_Hdr_Rsvd; + unsigned char SRB_Target; + unsigned char SRB_Lun; + unsigned char SRB_DriveFlags; + unsigned char SRB_Int13HDriveInfo; + unsigned char SRB_Heads; + unsigned char SRB_Sectors; + unsigned char SRB_Rsvd1[22]; +}; + +struct SRB_GDEVBlock +{ + unsigned char SRB_Cmd; + unsigned char SRB_Status; + unsigned char SRB_HaId; + unsigned char SRB_Flags; + unsigned long SRB_Hdr_Rsvd; + unsigned char SRB_Target; + unsigned char SRB_Lun; + unsigned char SRB_DeviceType; + unsigned char SRB_Rsvd1; +}; + +struct SRB_ExecSCSICmd +{ + unsigned char SRB_Cmd; + unsigned char SRB_Status; + unsigned char SRB_HaId; + unsigned char SRB_Flags; + unsigned long SRB_Hdr_Rsvd; + unsigned char SRB_Target; + unsigned char SRB_Lun; + unsigned short SRB_Rsvd1; + unsigned long SRB_BufLen; + unsigned char *SRB_BufPointer; + unsigned char SRB_SenseLen; + unsigned char SRB_CDBLen; + unsigned char SRB_HaStat; + unsigned char SRB_TargStat; + unsigned long *SRB_PostProc; + unsigned char SRB_Rsvd2[20]; + unsigned char CDBByte[16]; + unsigned char SenseArea[SENSE_LEN+2]; +}; + +#pragma pack() +#endif /* WIN32 */ + + +/***************************************************************************** + * Local Prototypes + *****************************************************************************/ +static int OpenVCDImage( vlc_object_t *, const char *, struct vcddev_s * ); +static void CloseVCDImage( vlc_object_t *, struct vcddev_s * ); + +#if defined( SYS_DARWIN ) +static CDTOC *darwin_getTOC( vlc_object_t *, const struct vcddev_s * ); +static int darwin_getNumberOfDescriptors( CDTOC * ); +static int darwin_getNumberOfTracks( CDTOC *, int ); + +#elif defined( WIN32 ) +static int win32_vcd_open( vlc_object_t *, const char *, struct vcddev_s *); +#endif diff --git a/modules/access/vcd/vcd.c b/modules/access/vcd/vcd.c index c5fc6cadce..32f7d9e1ae 100644 --- a/modules/access/vcd/vcd.c +++ b/modules/access/vcd/vcd.c @@ -2,7 +2,7 @@ * vcd.c : VCD input module for vlc ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: vcd.c,v 1.19 2003/05/04 22:42:15 gbazin Exp $ + * $Id: vcd.c,v 1.20 2003/05/17 20:30:31 gbazin Exp $ * * Author: Johan Bilien * @@ -38,7 +38,7 @@ #include -#include "vcd.h" +#include "cdrom.h" /* how many blocks VCDRead will read in each loop */ #define VCD_BLOCKS_ONCE 20 @@ -101,11 +101,7 @@ static int VCDOpen( vlc_object_t *p_this ) input_area_t * p_area; int i_title = 1; int i_chapter = 1; - - p_input->pf_read = VCDRead; - p_input->pf_seek = VCDSeek; - p_input->pf_set_area = VCDSetArea; - p_input->pf_set_program = VCDSetProgram; + vcddev_t *vcddev; #ifdef WIN32 /* On Win32 we want the VCD access plugin to be explicitly requested, @@ -154,40 +150,38 @@ static int VCDOpen( vlc_object_t *p_this ) if( !psz_source ) return -1; } - p_vcd = malloc( sizeof(thread_vcd_data_t) ); + /* Open VCD */ + if( !(vcddev = ioctl_Open( p_this, psz_source )) ) + { + msg_Warn( p_input, "could not open %s", psz_source ); + free( psz_source ); + return -1; + } + p_vcd = malloc( sizeof(thread_vcd_data_t) ); if( p_vcd == NULL ) { msg_Err( p_input, "out of memory" ); free( psz_source ); return -1; } + free( psz_source ); + p_vcd->vcddev = vcddev; p_input->p_access_data = (void *)p_vcd; p_input->i_mtu = VCD_DATA_ONCE; vlc_mutex_lock( &p_input->stream.stream_lock ); - p_input->stream.b_pace_control = 1; p_input->stream.b_seekable = 1; p_input->stream.p_selected_area->i_size = 0; p_input->stream.p_selected_area->i_tell = 0; - vlc_mutex_unlock( &p_input->stream.stream_lock ); - if( !(p_vcd->vcddev = ioctl_Open( p_this, psz_source )) ) - { - msg_Warn( p_input, "could not open %s", psz_source ); - free( psz_source ); - free( p_vcd ); - return -1; - } - /* We read the Table Of Content information */ p_vcd->i_nb_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input), p_vcd->vcddev, &p_vcd->p_sectors ); - free( psz_source ); if( p_vcd->i_nb_tracks < 0 ) msg_Err( p_input, "unable to count tracks" ); else if( p_vcd->i_nb_tracks <= 1 ) @@ -258,6 +252,11 @@ static int VCDOpen( vlc_object_t *p_this ) p_input->psz_demux = "ps"; } + p_input->pf_read = VCDRead; + p_input->pf_seek = VCDSeek; + p_input->pf_set_area = VCDSetArea; + p_input->pf_set_program = VCDSetProgram; + return 0; } @@ -299,7 +298,8 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer, for ( i_index = 0 ; i_index < i_blocks ; i_index++ ) { if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev, - p_vcd->i_sector, p_buffer + i_index * VCD_DATA_SIZE ) < 0 ) + p_vcd->i_sector, p_buffer + i_index * VCD_DATA_SIZE, + VCD_DATA_START, VCD_DATA_SIZE ) < 0 ) { msg_Err( p_input, "could not read sector %d", p_vcd->i_sector ); return -1; @@ -352,7 +352,8 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer, if ( i_len % VCD_DATA_SIZE ) /* this should not happen */ { if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev, - p_vcd->i_sector, p_last_sector ) < 0 ) + p_vcd->i_sector, p_last_sector, VCD_DATA_START, + VCD_DATA_SIZE ) < 0 ) { msg_Err( p_input, "could not read sector %d", p_vcd->i_sector ); return -1; @@ -366,7 +367,6 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer, return i_read; } - /***************************************************************************** * VCDSetProgram: Does nothing since a VCD is mono_program *****************************************************************************/ @@ -376,7 +376,6 @@ static int VCDSetProgram( input_thread_t * p_input, return 0; } - /***************************************************************************** * VCDSetArea: initialize input data for title x, chapter y. * It should be called for each user navigation request. @@ -443,7 +442,6 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area ) return 0; } - /**************************************************************************** * VCDSeek ****************************************************************************/ @@ -502,7 +500,7 @@ static int VCDEntryPoints( input_thread_t * p_input ) } if( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev, - VCD_ENTRIES_SECTOR, p_sector ) < 0 ) + VCD_ENTRIES_SECTOR, p_sector, VCD_DATA_START, VCD_DATA_SIZE ) < 0 ) { msg_Err( p_input, "could not read entry points sector" ); free( p_sector ); diff --git a/modules/access/vcd/vcd.h b/modules/access/vcd/vcd.h deleted file mode 100644 index bf911a5fea..0000000000 --- a/modules/access/vcd/vcd.h +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** - * vcd.h: thread structure of the VCD plugin - ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: vcd.h,v 1.4 2003/02/12 17:13:33 jobi Exp $ - * - * Author: Johan Bilien - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/* where the data start on a VCD sector */ -#define VCD_DATA_START 24 -/* size of the availablr data on a VCD sector */ -#define VCD_DATA_SIZE 2324 -/* size of a VCD sector, header and tail included */ -#define VCD_SECTOR_SIZE 2352 -/* size of a CD sector */ -#define CD_SECTOR_SIZE 2048 -/* sector containing the entry points */ -#define VCD_ENTRIES_SECTOR 151 - -/***************************************************************************** - * Misc. Macros - *****************************************************************************/ -/* LBA = msf.frame + 75 * ( msf.second + 60 * msf.minute ) */ -#define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min)) -/* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */ -#define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min)) -/* Converts BCD to Binary data */ -#define BCD_TO_BIN(i) \ - (uint8_t)((uint8_t)(0xf & (uint8_t)i)+((uint8_t)10*((uint8_t)i >> 4))) - -#ifndef VCDDEV_T -typedef struct vcddev_s vcddev_t; -#endif - -/***************************************************************************** - * structure to store minute/second/frame locations - *****************************************************************************/ -typedef struct msf_s -{ - uint8_t minute; - uint8_t second; - uint8_t frame; -} msf_t; - - -/***************************************************************************** - * entries_sect structure: the sector containing entry points - *****************************************************************************/ -typedef struct entries_sect_s -{ - uint8_t psz_id[8]; /* "ENTRYVCD" */ - uint8_t i_version; /* 0x02 VCD2.0 - 0x01 SVCD */ - uint8_t i_sys_prof_tag; /* 0x01 if VCD1.1 - 0x00 else */ - uint16_t i_entries_nb; /* entries number <= 500 */ - - struct - { - uint8_t i_track; /* track number */ - msf_t msf; /* msf location - (in BCD format) */ - } entry[500]; - uint8_t zeros[36]; /* should be 0x00 */ -} entries_sect_t; - -/***************************************************************************** - * Prototypes - *****************************************************************************/ -vcddev_t *ioctl_Open ( vlc_object_t *, const char * ); -void ioctl_Close ( vlc_object_t *, vcddev_t * ); -int ioctl_GetTracksMap ( vlc_object_t *, const vcddev_t *, int ** ); -int ioctl_ReadSector ( vlc_object_t *, const vcddev_t *, - int, byte_t * ); diff --git a/modules/codec/araw.c b/modules/codec/araw.c index 188846676a..0150effe28 100644 --- a/modules/codec/araw.c +++ b/modules/codec/araw.c @@ -2,7 +2,7 @@ * araw.c: Pseudo audio decoder; for raw pcm data ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: araw.c,v 1.14 2003/03/11 17:40:40 fenrir Exp $ + * $Id: araw.c,v 1.15 2003/05/17 20:30:31 gbazin Exp $ * * Authors: Laurent Aimar * @@ -40,9 +40,6 @@ typedef struct adec_thread_s { WAVEFORMATEX *p_wf; - /* The bit stream structure handles the PES stream at the bit level */ -// bit_stream_t bit_stream; - /* Input properties */ decoder_fifo_t *p_fifo; int16_t *p_logtos16; // used with m/alaw to s16 @@ -244,7 +241,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) *****************************************************************************/ static int InitThread( adec_thread_t * p_adec ) { - if( ( p_adec->p_wf = (WAVEFORMATEX*)p_adec->p_fifo->p_waveformatex ) == NULL ) + if( ( p_adec->p_wf = (WAVEFORMATEX*)p_adec->p_fifo->p_waveformatex ) + == NULL ) { msg_Err( p_adec->p_fifo, "unknown raw format" ); return( -1 ); @@ -261,7 +259,8 @@ static int InitThread( adec_thread_t * p_adec ) } msg_Dbg( p_adec->p_fifo, - "raw format: samplerate:%dHz channels:%d bits/sample:%d blockalign:%d", + "raw format: samplerate:%dHz channels:%d bits/sample:%d " + "blockalign:%d", p_adec->p_wf->nSamplesPerSec, p_adec->p_wf->nChannels, p_adec->p_wf->wBitsPerSample, @@ -362,8 +361,7 @@ static int InitThread( adec_thread_t * p_adec ) } p_adec->output_format.i_rate = p_adec->p_wf->nSamplesPerSec; - if( p_adec->p_wf->nChannels <= 0 || - p_adec->p_wf->nChannels > 5 ) + if( p_adec->p_wf->nChannels <= 0 || p_adec->p_wf->nChannels > 5 ) { msg_Err( p_adec->p_fifo, "bad channels count(1-5)" ); return( -1 ); @@ -386,10 +384,6 @@ static int InitThread( adec_thread_t * p_adec ) return( -1 ); } - /* Init the BitStream */ -// InitBitstream( &p_adec->bit_stream, p_adec->p_fifo, -// NULL, NULL ); - return( 0 ); } @@ -405,7 +399,8 @@ static void GetPESData( u8 *p_buf, int i_max, pes_packet_t *p_pes ) while( p_data != NULL && i_count < i_max ) { - i_copy = __MIN( p_data->p_payload_end - p_data->p_payload_start, i_max - i_count ); + i_copy = __MIN( p_data->p_payload_end - p_data->p_payload_start, + i_max - i_count ); if( i_copy > 0 ) { @@ -455,11 +450,9 @@ static void DecodeThread( adec_thread_t *p_adec ) return; } - i_samples = i_size / - ( ( p_adec->p_wf->wBitsPerSample + 7 ) / 8 ) / + i_samples = i_size / ( ( p_adec->p_wf->wBitsPerSample + 7 ) / 8 ) / p_adec->p_wf->nChannels; -// msg_Warn( p_adec->p_fifo, "got %d samples (%d bytes)", i_samples, i_size ); p_adec->pts = p_pes->i_pts; /* **** Now we can output these samples **** */ @@ -511,8 +504,7 @@ static void DecodeThread( adec_thread_t *p_adec ) } else { - memcpy( p_aout_buffer->p_buffer, - p, + memcpy( p_aout_buffer->p_buffer, p, p_aout_buffer->i_nb_bytes ); p += p_aout_buffer->i_nb_bytes; @@ -527,7 +519,6 @@ static void DecodeThread( adec_thread_t *p_adec ) input_DeletePES( p_adec->p_fifo->p_packets_mgt, p_pes ); } - /***************************************************************************** * EndThread : faad decoder thread destruction *****************************************************************************/ @@ -542,5 +533,3 @@ static void EndThread (adec_thread_t *p_adec) free( p_adec ); } - - -- 2.39.2