Commit e8f07ae1 authored by Gildas Bazin's avatar Gildas Bazin

* modules/access/cdda/*: got rid of the demux. The access plugin will now build a WAV header which will allow this plugin to work with the dts/a52 demuxers as well as the wav demuxer.
parent 0895ba28
......@@ -4,5 +4,4 @@ SOURCES_cddax = \
access.c \
cdda.c \
cdda.h \
demux.c \
$(NULL)
......@@ -2,7 +2,7 @@
* cddax.c : CD digital audio input module for vlc using libcdio
*****************************************************************************
* Copyright (C) 2000,2003 VideoLAN
* $Id: access.c,v 1.23 2004/01/29 17:51:07 zorglub Exp $
* $Id: access.c,v 1.24 2004/02/11 18:08:05 gbazin Exp $
*
* Authors: Rocky Bernstein <rocky@panix.com>
* Laurent Aimar <fenrir@via.ecp.fr>
......@@ -52,7 +52,7 @@
#include "cdda.h"
/* how many blocks Open will read in each loop */
#define CDDA_BLOCKS_ONCE 1
#define CDDA_BLOCKS_ONCE 20
#define CDDA_DATA_ONCE (CDDA_BLOCKS_ONCE * CDIO_CD_FRAMESIZE_RAW)
#define CDDA_MRL_PREFIX "cddax://"
......@@ -187,24 +187,31 @@ static int CDDARead( input_thread_t * p_input, byte_t * p_buffer,
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 / CDIO_CD_FRAMESIZE_RAW;
i_read = 0;
if( !p_cdda->i_header_pos )
{
p_cdda->i_header_pos = sizeof(WAVEHEADER);
i_blocks = (i_len - sizeof(WAVEHEADER)) / CDIO_CD_FRAMESIZE_RAW;
memcpy( p_buffer, &p_cdda->waveheader, sizeof(WAVEHEADER) );
p_buffer += sizeof(WAVEHEADER);
i_read += sizeof(WAVEHEADER);
}
for ( i_index = 0; i_index < i_blocks; i_index++ )
for( i_index = 0; i_index < i_blocks; i_index++ )
{
if (cdio_read_audio_sector(p_cdda->p_cddev->cdio, p_buffer,
p_cdda->i_sector) != 0)
if( cdio_read_audio_sector( p_cdda->p_cddev->cdio, p_buffer,
p_cdda->i_sector) != 0 )
{
msg_Err( p_input, "could not read sector %d", p_cdda->i_sector );
return -1;
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] )
if( p_cdda->i_sector == p_cdda->p_sectors[p_cdda->i_track + 1] )
{
input_area_t *p_area;
......@@ -223,6 +230,7 @@ static int CDDARead( input_thread_t * p_input, byte_t * p_buffer,
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
i_read += CDIO_CD_FRAMESIZE_RAW;
p_buffer += CDIO_CD_FRAMESIZE_RAW;
}
if ( i_len % CDIO_CD_FRAMESIZE_RAW ) /* this should not happen */
......@@ -901,6 +909,7 @@ E_(Open)( vlc_object_t *p_this )
int i;
int i_track = 1;
cddev_t *p_cddev;
vlc_value_t val;
bool play_single_track = false;
/* Set where to log errors messages from libcdio. */
......@@ -1036,22 +1045,38 @@ E_(Open)( vlc_object_t *p_this )
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;
/* Update default_pts to a suitable value for cdda access */
p_input->i_pts_delay = config_GetInt( p_input,
MODULE_STRING "-caching" ) * 1000;
var_Create( p_input, MODULE_STRING "-caching",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_input, MODULE_STRING "-caching", &val );
p_input->i_pts_delay = val.i_int * 1000;
free( psz_source );
/* Build a WAV header for the output data */
memset( &p_cdda->waveheader, 0, sizeof(WAVEHEADER) );
SetWLE( &p_cdda->waveheader.Format, 1 ); /*WAVE_FORMAT_PCM*/
SetWLE( &p_cdda->waveheader.BitsPerSample, 16);
p_cdda->waveheader.MainChunkID = VLC_FOURCC('R', 'I', 'F', 'F');
p_cdda->waveheader.Length = 0; /* we just don't know */
p_cdda->waveheader.ChunkTypeID = VLC_FOURCC('W', 'A', 'V', 'E');
p_cdda->waveheader.SubChunkID = VLC_FOURCC('f', 'm', 't', ' ');
SetDWLE( &p_cdda->waveheader.SubChunkLength, 16);
SetWLE( &p_cdda->waveheader.Modus, 2);
SetDWLE( &p_cdda->waveheader.SampleFreq, 44100);
SetWLE( &p_cdda->waveheader.BytesPerSample,
2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 );
SetDWLE( &p_cdda->waveheader.BytesPerSec,
16 /*BytesPerSample*/ * 44100 /*SampleFreq*/ );
p_cdda->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a');
p_cdda->waveheader.DataLength = 0; /* we just don't know */
p_cdda->i_header_pos = 0;
return 0;
}
......
......@@ -3,7 +3,7 @@
* using libcdio, libvcd and libvcdinfo
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: cdda.h,v 1.4 2003/12/22 14:32:55 sam Exp $
* $Id: cdda.h,v 1.5 2004/02/11 18:08:05 gbazin Exp $
*
* Author: Rocky Bernstein <rocky@panix.com>
*
......@@ -50,6 +50,26 @@
#define dbg_print(mask, s, args...)
#endif
/*****************************************************************************
* Wave header structure definition
*****************************************************************************/
typedef struct WAVEHEADER
{
uint32_t MainChunkID; // it will be 'RIFF'
uint32_t Length;
uint32_t ChunkTypeID; // it will be 'WAVE'
uint32_t SubChunkID; // it will be 'fmt '
uint32_t SubChunkLength;
uint16_t Format;
uint16_t Modus;
uint32_t SampleFreq;
uint32_t BytesPerSec;
uint16_t BytesPerSample;
uint16_t BitsPerSample;
uint32_t DataChunkID; // it will be 'data'
uint32_t DataLength;
} WAVEHEADER;
/*****************************************************************************
* cdda_data_t: CD audio information
*****************************************************************************/
......@@ -75,6 +95,8 @@ typedef struct cdda_data_s
} cddb;
#endif
WAVEHEADER waveheader; /* Wave header for the output data */
int i_header_pos;
} cdda_data_t;
......
/*****************************************************************************
* demux.c: demux functions for dvdplay.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: demux.c,v 1.1 2003/11/30 02:41:00 rocky Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* Rocky Bernstein <rocky@panix.com>
*
* 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.
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <cdio/cdio.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Demux ( input_thread_t * p_input );
/*****************************************************************************
* Private structure
*****************************************************************************/
struct demux_sys_t
{
es_out_id_t *p_es;
mtime_t i_pts;
};
/****************************************************************************
* DemuxOpen:
****************************************************************************/
int
E_(DemuxOpen) ( vlc_object_t * p_this)
{
input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys;
es_format_t fmt;
if( p_input->stream.i_method != INPUT_METHOD_CDDA )
{
return VLC_EGENERIC;
}
p_input->pf_demux = Demux;
p_input->pf_rewind = NULL;
p_input->pf_demux_control = demux_vaControlDefault;
p_input->p_demux_data = p_sys = malloc( sizeof( es_descriptor_t ) );
p_sys->i_pts = 0;
vlc_mutex_lock( &p_input->stream.stream_lock );
if( input_InitStream( p_input, 0 ) == -1)
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
msg_Err( p_input, "cannot init stream" );
free( p_sys );
return VLC_EGENERIC;
}
p_input->stream.i_mux_rate = 4 * 44100 / 50;
vlc_mutex_unlock( &p_input->stream.stream_lock );
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'a', 'r', 'a', 'w' ) );
fmt.audio.i_channels = 2;
fmt.audio.i_rate = 44100;
fmt.audio.i_bitspersample = 16;
fmt.audio.i_blockalign = 4;
fmt.i_bitrate = 4 * 44100 * 8;
p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt );
return VLC_SUCCESS;
}
/****************************************************************************
* DemuxClose:
****************************************************************************/
void
E_(DemuxClose)( vlc_object_t * p_this)
{
input_thread_t *p_input = (input_thread_t*)p_this;
demux_sys_t *p_sys = (demux_sys_t*)p_input->p_demux_data;
free( p_sys );
return;
}
/****************************************************************************
* Demux:
****************************************************************************/
static int Demux( input_thread_t * p_input )
{
demux_sys_t *p_sys = (demux_sys_t*)p_input->p_demux_data;
block_t *p_block;
input_ClockManageRef( p_input,
p_input->stream.p_selected_program,
p_sys->i_pts );
if( ( p_block = stream_Block( p_input->s, CDIO_CD_FRAMESIZE_RAW ) ) == NULL )
{
/* eof */
return 0;
}
p_block->i_dts =
p_block->i_pts = input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_sys->i_pts );
p_block->i_length = (mtime_t)90000 * (mtime_t)p_block->i_buffer/44100/4;
p_sys->i_pts += p_block->i_length;
es_out_Send( p_input->p_es_out, p_sys->p_es, p_block );
return 1;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment