[Mplayer-cvslog] CVS: main/libac3 test2.c,1.1,1.2
Nick Kurshev
nickols_k at users.sourceforge.net
Wed Jun 6 11:33:58 CEST 2001
Update of /cvsroot/mplayer/main/libac3
In directory usw-pr-cvs1:/tmp/cvs-serv28060/main/libac3
Modified Files:
test2.c
Log Message:
PCM output
Index: test2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libac3/test2.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** test2.c 2001/05/13 20:26:18 1.1
--- test2.c 2001/06/06 09:33:56 1.2
***************
*** 1,2 ****
--- 1,4 ----
+ // gcc test2.c -I.. -L. -lac3 -o ac3test
+ //#define DUMP_PCM
#include <stdio.h>
***************
*** 8,12 ****
#include <sys/soundcard.h>
! #include "libac3/ac3.h"
#include "config.h"
--- 10,14 ----
#include <sys/soundcard.h>
! #include "ac3.h"
#include "config.h"
***************
*** 34,42 ****
float length;
int r;
int audio_fd;
ac3_frame_t* ac3_frame=NULL;
ac3file=fopen((argc>1)?argv[1]:"test2.ac3","rb");
! if(!ac3file){ printf("file not found\n"); exit(1); }
// Dolby AC3 audio:
--- 36,48 ----
float length;
int r;
+ #ifdef DUMP_PCM
+ FILE *fd_audio;
+ #else
int audio_fd;
+ #endif
ac3_frame_t* ac3_frame=NULL;
ac3file=fopen((argc>1)?argv[1]:"test2.ac3","rb");
! if(!ac3file){ printf("input ac3 stream not found\n"); exit(1); }
// Dolby AC3 audio:
***************
*** 54,57 ****
--- 60,67 ----
if(!ac3_frame){ printf("Can't decode this file...\n");exit(1); }
+ #ifdef DUMP_PCM
+ fd_audio=fopen("test.pcm", "wb");
+ if(!fd_audio){ printf("file creation error\n"); exit(1); }
+ #else
audio_fd=open("/dev/dsp", O_WRONLY);
if(audio_fd<0){ printf("Can't open audio device\n");exit(1); }
***************
*** 60,63 ****
--- 70,74 ----
r=ac3_frame->sampling_rate;ioctl (audio_fd, SNDCTL_DSP_SPEED, &r);
printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,ac3_frame->sampling_rate);
+ #endif
while(1){
***************
*** 68,72 ****
--- 79,87 ----
// play it
+ #ifdef DUMP_PCM
+ fwrite(ac3_frame->audio_data,len,1,fd_audio);
+ #else
len2=write(audio_fd,ac3_frame->audio_data,len);
+ #endif
if(len2<0) break; // ERROR?
if(len2<len) printf("???\n"); // shouldn't happen
***************
*** 75,78 ****
fclose(ac3file);
!
}
--- 90,95 ----
fclose(ac3file);
! #ifdef DUMP_PCM
! fclose(fd_audio);
! #endif
}
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
More information about the MPlayer-cvslog
mailing list