changeset 6384:f0b933918a22

Support for playing audio cds using cdparanoia. Include a raw audio demuxer wich can be used for other purpose.
author albeu
date Tue, 11 Jun 2002 14:29:51 +0000
parents 49f9e6b07687
children 65ceb2d07a71
files Makefile configure libmpdemux/Makefile libmpdemux/cdda.c libmpdemux/demux_rawaudio.c libmpdemux/demuxer.c libmpdemux/demuxer.h libmpdemux/open.c libmpdemux/opt-reg.c libmpdemux/stream.c libmpdemux/stream.h
diffstat 11 files changed, 400 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Jun 10 18:43:42 2002 +0000
+++ b/Makefile	Tue Jun 11 14:29:51 2002 +0000
@@ -51,11 +51,11 @@
 A_LIBS = $(ALSA_LIB) $(ARTS_LIB) $(NAS_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(SGIAUDIO_LIB)
 
 CODEC_LIBS = -Llibmpcodecs -lmpcodecs -Lmp3lib -lMP3 -Lliba52 -la52 -Llibmpeg2 -lmpeg2 $(AV_LIB) $(FAME_LIB)
-COMMON_LIBS = $(CODEC_LIBS) -Llibmpdemux -lmpdemux  $(NEW_INPUT_LIB)  $(LIB_LOADER) $(A_LIBS) $(CSS_LIB) $(ARCH_LIB) -Lpostproc -lpostproc $(DECORE_LIB) -Llinux -losdep $(TERMCAP_LIB)  $(STREAMING_LIB) $(Z_LIB) $(GTK_LIBS) $(PNG_LIB) $(JPEG_LIB) $(GIF_LIB) -lm
+COMMON_LIBS = $(CODEC_LIBS) -Llibmpdemux -lmpdemux  $(NEW_INPUT_LIB)  $(LIB_LOADER) $(A_LIBS) $(CSS_LIB) $(ARCH_LIB) -Lpostproc -lpostproc $(DECORE_LIB) -Llinux -losdep $(TERMCAP_LIB)  $(STREAMING_LIB) $(Z_LIB) $(GTK_LIBS) $(PNG_LIB) $(JPEG_LIB) $(GIF_LIB) $(CDPARANOIA_LIB) -lm
 ifeq ($(VIDIX),yes)
 MISC_LIBS += -Llibdha -ldha -Lvidix -lvidix
 endif
-CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader $(VO_INC) $(EXTRA_INC) # -Wall
+CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader $(VO_INC) $(EXTRA_INC) $(CDPARANOIA_INC)# -Wall
 
 PARTS = libfame libmpdemux libmpcodecs mp3lib liba52 libmp1e libmpeg2 libavcodec libao2 drivers drivers/syncfb linux postproc input libmpdvdkit
 ifeq ($(VIDIX),yes)
--- a/configure	Mon Jun 10 18:43:42 2002 +0000
+++ b/configure	Tue Jun 11 14:29:51 2002 +0000
@@ -162,6 +162,7 @@
   --disable-dvdnav       Disable dvdnav support [autodetect]
   --disable-dvdread      Disable libdvdread support [autodetect]
   --disable-mpdvdkit     Disable mpdvdkit support [autodetect]
+  --disable-cdparanoia   Disable cdparanoia support [autodetect]
   
 Video:
   --enable-gl            build with OpenGL render support [autodetect]
@@ -904,6 +905,7 @@
 _i18n=no
 _sighandler=yes
 _libdv=auto
+_cdparanoia=auto
 
 for ac_option do
   case "$ac_option" in
@@ -1058,6 +1060,8 @@
   --disable-select)	_select=no	;;
   --enable-linux-devfs)	_linux_devfs=yes	;;
   --disable-linux-devfs)	_linux_devfs=no	;;
+  --enable-cdparanoia)	_cdparanoia=yes	;;
+  --disable-cdparanoia)	_cdparanoia=no	;;
 
   --enable-dga) _dga=auto ;; # as we don't know if it's 1 or 2
   --enable-dga=*) _dga=`echo $ac_option | cut -d '=' -f 2` ;;
@@ -1147,6 +1151,12 @@
   --with-madlibdir=*)
     _ld_mad=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
     ;;
+  --with-cdparanoiaincdir=*)
+    _inc_cdparanoia=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
+    ;;
+  --with-cdparanoialibdir=*)
+    _ld_cdparanoia=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
+    ;;
 
   --prefix=*)
     _prefix=`echo $ac_option | cut -d '=' -f 2`
@@ -3005,6 +3015,25 @@
   echores "no"
 fi
 
+echocheck "cdparanoia"
+if test "$_cdparanoia" = auto ; then
+    cat > $TMPC <<EOF
+#include <cdda_interface.h>
+#include <cdda_paranoia.h>
+// This need a better test. How ?
+int main(void) { return 1; }
+EOF
+    _cdparanoia=no
+    cc_check $_inc_cdparnoia $_ld_cdparanoia -lcdda_interface -lcdda_paranoia && _cdparanoia=yes
+fi
+if test "$_cdparanoia" = yes ; then
+    _def_cdparanoia='#define HAVE_CDDA'
+    _ld_cdparanoia="$_ld_cdparanoia -lcdda_interface -lcdda_paranoia"
+else
+    _def_cdparanoia='#undef HAVE_CDDA'
+fi
+echores "$_cdparanoia"
+
 echocheck "zlib"
 cat > $TMPC << EOF
 #include <zlib.h>
@@ -3966,6 +3995,8 @@
 DIRECTFB_INC = $_inc_directfb
 DIRECTFB_LIB = $_ld_directfb
 NEW_INPUT_LIB = $_ld_new_input
+CDPARANOIA_INC = $_inc_cdparnoia
+CDPARANOIA_LIB = $_ld_cdparanoia
 
 # --- Some stuff for autoconfigure ----
 $_target_arch
@@ -4283,6 +4314,9 @@
 /* enable streaming */
 $_def_streaming
 
+/* enables / disables cdparanoia support */
+$_def_cdparanoia
+
 /* enables / disables vidix usage */
 $_def_vidix
 
--- a/libmpdemux/Makefile	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/Makefile	Tue Jun 11 14:29:51 2002 +0000
@@ -3,7 +3,7 @@
 
 include ../config.mak
 
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c demux_ogg.c demux_bmp.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c
 ifeq ($(STREAMING),yes)
 SRCS += asf_streaming.c url.c http.c network.c rtp.c asf_mmst_streaming.c
 endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpdemux/cdda.c	Tue Jun 11 14:29:51 2002 +0000
@@ -0,0 +1,207 @@
+#include "config.h"
+
+#ifdef HAVE_CDDA
+
+#include "stream.h"
+#include "../cfgparser.h"
+
+#include <cdda_interface.h>
+#include <cdda_paranoia.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int speed = -1;
+static int paranoia_mode = 1;
+static char* generic_dev = NULL;
+static int sector_size = 0;
+static int search_overlap = -1;
+static int toc_bias = 0;
+static int toc_offset = 0;
+static int no_skip = 0;
+
+static config_t cdda_opts[] = {
+  { "speed", &speed, CONF_TYPE_INT, CONF_RANGE,1,100, NULL },
+  { "paranoia", &paranoia_mode, CONF_TYPE_INT,CONF_RANGE, 0, 2, NULL },
+  { "generic-dev", &generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL },
+  { "sector-size", &sector_size, CONF_TYPE_INT, CONF_RANGE,1,100, NULL },
+  { "overlap", &search_overlap, CONF_TYPE_INT, CONF_RANGE,0,75, NULL },
+  { "toc-bias", &toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL },
+  { "toc-offset", &toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL },
+  { "noskip", &no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL },
+  { "skip", &no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL },
+  {NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
+static config_t cdda_conf[] = {
+  { "cdda", &cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+  { NULL,NULL, 0, 0, 0, 0, NULL}
+};
+
+void cdda_register_options(m_config_t* cfg) {
+  m_config_register_options(cfg,cdda_conf);
+}
+
+typedef struct {
+  cdrom_drive* cd;
+  cdrom_paranoia* cdp;
+  int sector;
+  int start_sector;
+  int end_sector;
+} cdda_priv;
+
+stream_t* open_cdda(char* dev,char* track) {
+  stream_t* st;
+  int start_track = 0;
+  int end_track = 0;
+  int mode = paranoia_mode;
+  int offset = toc_offset;
+  cdrom_drive* cdd = NULL;
+  cdda_priv* priv;
+  char* end = strchr(track,'-');
+
+  if(!end)
+    start_track = end_track = atoi(track);
+  else {
+    int st_len = end - track;
+    int ed_len = strlen(track) - 1 - st_len;
+
+    if(st_len) {
+      char st[st_len + 1];
+      strncpy(st,track,st_len);
+      st[st_len] = '\0';
+      start_track = atoi(st);
+    }
+    if(ed_len) {
+      char ed[ed_len + 1];
+      strncpy(ed,end+1,ed_len);
+      ed[ed_len] = '\0';
+      end_track = atoi(ed);
+    }
+  }
+    
+  if(generic_dev)
+    cdd = cdda_identify_scsi(generic_dev,dev,0,NULL);
+  else
+    cdd = cdda_identify(dev,0,NULL);
+
+  if(!cdd) {
+    mp_msg(MSGT_OPEN,MSGL_ERR,"Can't open cdda device\n");
+    return NULL;
+  }
+
+  cdda_verbose_set(cdd, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
+
+
+  if(sector_size) {
+    cdd->nsectors = sector_size;
+    cdd->bigbuff = sector_size * CD_FRAMESIZE_RAW;
+  }
+
+  if(cdda_open(cdd) != 0) {
+    mp_msg(MSGT_OPEN,MSGL_ERR,"Can't open disc\n");
+    cdda_close(cdd);
+    return NULL;
+  }
+
+  priv = (cdda_priv*)malloc(sizeof(cdda_priv));
+  priv->cd = cdd;
+
+  if(toc_bias)
+    offset -= cdda_track_firstsector(cdd,1);
+
+  if(offset) {
+    int i;
+    for(i = 0 ; i < cdd->tracks + 1 ; i++)
+      cdd->disc_toc[i].dwStartSector += offset;
+  }
+
+  if(speed)
+    cdda_speed_set(cdd,speed);
+
+  if(start_track)
+    priv->start_sector = cdda_track_firstsector(cdd,start_track);
+  else
+    priv->start_sector = cdda_disc_firstsector(cdd);
+
+  if(end_track) {
+    int last = cdda_tracks(cdd);
+    if(end_track > last) end_track = last;
+    priv->end_sector = cdda_track_lastsector(cdd,end_track);
+  } else
+    priv->end_sector = cdda_disc_lastsector(cdd);
+
+  priv->cdp = paranoia_init(cdd);
+  if(priv->cdp == NULL) {
+    cdda_close(cdd);
+    free(priv);
+    return NULL;
+  }
+
+  if(mode == 0)
+    mode = PARANOIA_MODE_DISABLE;
+  else if(mode == 1)
+    mode = PARANOIA_MODE_OVERLAP;
+  else
+    mode = PARANOIA_MODE_FULL;
+  
+  if(no_skip)
+    mode |= PARANOIA_MODE_NEVERSKIP;
+
+  if(search_overlap >= 0)
+    paranoia_overlapset(cdd,search_overlap);
+
+  paranoia_seek(priv->cdp,priv->start_sector,SEEK_SET);
+  priv->sector = priv->start_sector;
+
+  st = new_stream(-1,STREAMTYPE_CDDA);
+  st->priv = priv;
+  st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW;
+  st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW;
+
+  return st;
+}
+
+static void cdparanoia_callback(long inpos, int function) {
+}
+
+int read_cdda(stream_t* s) {
+  cdda_priv* p = (cdda_priv*)s->priv;
+  int16_t * buf;
+  
+  buf = paranoia_read(p->cdp,cdparanoia_callback);
+
+  p->sector++;
+  s->pos = p->sector*CD_FRAMESIZE_RAW;
+  memcpy(s->buffer,buf,CD_FRAMESIZE_RAW);
+
+  if(p->sector == p->end_sector)
+    s->eof = 1;
+
+  return CD_FRAMESIZE_RAW;
+}
+
+void seek_cdda(stream_t* s) {
+  cdda_priv* p = (cdda_priv*)s->priv;
+  int sec = s->pos/CD_FRAMESIZE_RAW;
+
+  if(sec < p->start_sector)
+    sec = p->start_sector;
+  else if(sec > p->end_sector)
+    sec = p->end_sector;
+
+  p->sector = sec;
+  s->pos = sec*CD_FRAMESIZE_RAW;
+
+  paranoia_seek(p->cdp,sec,SEEK_SET);
+
+}
+
+void close_cdda(stream_t* s) {
+  cdda_priv* p = (cdda_priv*)s->priv;
+  paranoia_free(p->cdp);
+  cdda_close(p->cd);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpdemux/demux_rawaudio.c	Tue Jun 11 14:29:51 2002 +0000
@@ -0,0 +1,97 @@
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "../cfgparser.h"
+
+#include "stream.h"
+#include "demuxer.h"
+#include "stheader.h"
+
+
+int use_rawaudio = 0;
+static int channels = 2;
+static int samplerate = 44100;
+static int samplesize = 2;
+static int format = 0x1; // Raw PCM
+
+static config_t demux_rawaudio_opts[] = {
+  { "on", &use_rawaudio, CONF_TYPE_FLAG, 0,0, 1, NULL },
+  { "channels", &channels, CONF_TYPE_INT,CONF_RANGE,1,8, NULL },
+  { "rate", &samplerate, CONF_TYPE_INT,CONF_RANGE,1000,8*48000, NULL },
+  { "samplesize", &samplesize, CONF_TYPE_INT,CONF_RANGE,1,8, NULL },
+  { "format", &format, CONF_TYPE_INT, CONF_MIN, 0 , 0, NULL },
+  {NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
+static config_t demux_rawaudio_conf[] = {
+  { "rawaudio", &demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+  { NULL,NULL, 0, 0, 0, 0, NULL}
+};
+
+void demux_rwaudio_register_options(m_config_t* cfg) {
+  m_config_register_options(cfg,demux_rawaudio_conf);
+}
+
+extern void resync_audio_stream(sh_audio_t *sh_audio);
+
+int demux_rawaudio_open(demuxer_t* demuxer) {
+  sh_audio_t* sh_audio;
+  WAVEFORMATEX* w;
+
+  sh_audio = new_sh_audio(demuxer,0);
+  sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX));
+  w->wFormatTag = sh_audio->format = format;
+  w->nChannels = sh_audio->channels = channels;
+  w->nSamplesPerSec = sh_audio->samplerate = samplerate;
+  w->nAvgBytesPerSec = samplerate*samplesize*channels;
+  w->nBlockAlign = channels*samplesize;
+  sh_audio->samplesize = samplesize;
+  w->wBitsPerSample = 8*samplesize;
+  w->cbSize = 0;
+
+  demuxer->movi_start = demuxer->stream->start_pos;
+  demuxer->movi_end = demuxer->stream->end_pos;
+
+  demuxer->audio->sh = sh_audio;
+  sh_audio->ds = demuxer->audio;
+
+  return 1;
+}
+
+int demux_rawaudio_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) {
+  sh_audio_t* sh_audio = demuxer->audio->sh;
+  int l = sh_audio->wf->nAvgBytesPerSec;
+  off_t spos = stream_tell(demuxer->stream);
+  demux_packet_t*  dp;
+
+  if(demuxer->stream->eof)
+    return 0;
+
+  dp = new_demux_packet(l);
+  ds->pts = spos / (float)(sh_audio->wf->nAvgBytesPerSec);
+  ds->pos = spos;
+
+  stream_read(demuxer->stream,dp->buffer,l);
+  ds_add_packet(ds,dp);
+
+  return 1;
+}
+
+void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
+  stream_t* s = demuxer->stream;
+  sh_audio_t* sh_audio = demuxer->audio->sh;
+  off_t base,pos;
+
+  base = (flags & 1) ? demuxer->movi_start : stream_tell(s);
+  if(flags & 2)
+    pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
+  else
+    pos = base + (rel_seek_secs*sh_audio->i_bps);
+
+  pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
+  stream_seek(s,pos);
+  resync_audio_stream(sh_audio);
+}
--- a/libmpdemux/demuxer.c	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/demuxer.c	Tue Jun 11 14:29:51 2002 +0000
@@ -260,6 +260,7 @@
 int demux_audio_fill_buffer(demux_stream_t *ds);
 extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
 extern int demux_ogg_fill_buffer(demuxer_t *d);
+extern int demux_rawaudio_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds);
 
 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
   // Note: parameter 'ds' can be NULL!
@@ -287,6 +288,7 @@
     case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
     case DEMUXER_TYPE_DEMUXERS: return demux_demuxers_fill_buffer(demux,ds);
     case DEMUXER_TYPE_OGG: return demux_ogg_fill_buffer(demux);
+    case DEMUXER_TYPE_RAWAUDIO: return demux_rawaudio_fill_buffer(demux,ds);
   }
   return 0;
 }
@@ -501,9 +503,12 @@
 extern void demux_open_nuv(demuxer_t *demuxer);
 extern int demux_audio_open(demuxer_t* demuxer);
 extern int demux_ogg_open(demuxer_t* demuxer);
+extern int demux_rawaudio_open(demuxer_t* demuxer);
 
 extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer);
 
+extern int use_rawaudio;
+
 
 static demuxer_t* demux_open_stream(stream_t *stream,int file_format,int audio_id,int video_id,int dvdsub_id){
 
@@ -525,6 +530,11 @@
   file_format=DEMUXER_TYPE_MF;
  }
 
+if(stream->type == STREAMTYPE_CDDA || use_rawaudio) {
+  demuxer = new_demuxer(stream,DEMUXER_TYPE_RAWAUDIO,audio_id,video_id,dvdsub_id);
+  file_format = DEMUXER_TYPE_RAWAUDIO;
+}
+
 #ifdef USE_TV
 //=============== Try to open as TV-input: =================
 if((tv_param_on == 1) &&
@@ -789,6 +799,10 @@
 demuxer->file_format=file_format;
 
 switch(file_format){
+ case DEMUXER_TYPE_RAWAUDIO: {
+   demux_rawaudio_open(demuxer);
+   break;
+ }
  case DEMUXER_TYPE_MF: {
   if (!demux_open_mf(demuxer)) return NULL;
   break;
@@ -999,6 +1013,7 @@
 #ifdef HAVE_OGGVORBIS
 extern void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 #endif
+extern void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
     demux_stream_t *d_audio=demuxer->audio;
@@ -1071,6 +1086,8 @@
  case DEMUXER_TYPE_OGG:
       demux_ogg_seek(demuxer,rel_seek_secs,flags);  break;
 #endif
+ case DEMUXER_TYPE_RAWAUDIO:
+      demux_rawaudio_seek(demuxer,rel_seek_secs,flags);  break;
 
 
 } // switch(demuxer->file_format)
--- a/libmpdemux/demuxer.h	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/demuxer.h	Tue Jun 11 14:29:51 2002 +0000
@@ -28,10 +28,11 @@
 #define DEMUXER_TYPE_AUDIO 17
 #define DEMUXER_TYPE_OGG 18
 #define DEMUXER_TYPE_BMP 19
+#define DEMUXER_TYPE_RAWAUDIO 20
 // This should always match the higest demuxer type number.
 // Unless you want to disallow users to force the demuxer to some types
 #define DEMUXER_TYPE_MIN 0
-#define DEMUXER_TYPE_MAX 19
+#define DEMUXER_TYPE_MAX 20
 
 #define DEMUXER_TYPE_DEMUXERS (1<<16)
 // A virtual demuxer type for the network code
--- a/libmpdemux/open.c	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/open.c	Tue Jun 11 14:29:51 2002 +0000
@@ -67,6 +67,10 @@
 extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh);
 #endif
 
+#ifdef HAVE_CDDA
+stream_t* open_cdda(char* dev,char* track);
+#endif
+
 // Open a new stream  (stdin/file/vcd/url)
 
 stream_t* open_stream(char* filename,int vcd_track,int* file_format){
@@ -80,6 +84,11 @@
 int bsize = VCD_SECTOR_SIZE;
 #endif
 
+#ifdef HAVE_CDDA
+if(strncmp("cdda://",filename,7) == 0)
+  return open_cdda(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7);
+#endif
+
 //============ Open VideoCD track ==============
 #ifdef HAVE_VCD
 if(vcd_track){
--- a/libmpdemux/opt-reg.c	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/opt-reg.c	Tue Jun 11 14:29:51 2002 +0000
@@ -6,10 +6,17 @@
 
 extern void demux_audio_register_options(m_config_t* cfg);
 extern void demuxer_register_options(m_config_t* cfg);
+extern void demux_rwaudio_register_options(m_config_t* cfg);
+#ifdef HAVE_CDDA
+extern void cdda_register_options(m_config_t* cfg);
+#endif
 
 void libmpdemux_register_options(m_config_t* cfg) {
 
   demux_audio_register_options(cfg);
   demuxer_register_options(cfg);
-
+  demux_rwaudio_register_options(cfg);
+#ifdef HAVE_CDDA
+  cdda_register_options(cfg);
+#endif
 }
--- a/libmpdemux/stream.c	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/stream.c	Tue Jun 11 14:29:51 2002 +0000
@@ -35,6 +35,12 @@
 void dvd_seek(void* d,off_t pos);
 #endif
 
+#ifdef HAVE_CDDA
+int read_cdda(stream_t* s);
+void seek_cdda(stream_t* s);
+void close_cdda(stream_t* s);
+#endif
+
 //=================== STREAMER =========================
 
 int stream_fill_buffer(stream_t *s){
@@ -53,6 +59,11 @@
 #else
     len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break;
 #endif
+#ifdef HAVE_CDDA
+  case STREAMTYPE_CDDA:
+    len = read_cdda(s);
+    break;
+#endif
 #ifdef HAVE_VCD
   case STREAMTYPE_VCD:
 #ifdef VCD_CACHE
@@ -147,6 +158,13 @@
 #endif
     break;
 #endif
+#ifdef HAVE_CDDA
+  case STREAMTYPE_CDDA: {
+    s->pos=newpos;
+    seek_cdda(s);
+    break;
+  }
+#endif
 #ifdef USE_DVDNAV
   case STREAMTYPE_DVDNAV: {
     if (newpos==0) {
@@ -260,6 +278,10 @@
     waitpid(s->cache_pid,NULL,0);
   }
   if(s->fd>0) close(s->fd);
+#ifdef HAVE_CDDA
+  if(s->type == STREAMTYPE_CDDA)
+    close_cdda(s);
+#endif
   if(s->priv) free(s->priv);
   free(s);
 }
--- a/libmpdemux/stream.h	Mon Jun 10 18:43:42 2002 +0000
+++ b/libmpdemux/stream.h	Tue Jun 11 14:29:51 2002 +0000
@@ -17,6 +17,7 @@
 #define STREAMTYPE_MF   7
 #define STREAMTYPE_DS   8
 #define STREAMTYPE_DVDNAV 9   // we cannot safely "seek" in this...
+#define STREAMTYPE_CDDA 10
 
 #define VCD_SECTOR_SIZE 2352
 #define VCD_SECTOR_OFFS 24