summaryrefslogtreecommitdiffstats
path: root/dec_audio.c
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-09-02 01:21:34 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-09-02 01:21:34 +0000
commit5dd2ccdbaca32b08c863df2ebfbb23443906b848 (patch)
tree3011b724b3b63d0ffe5c3f5ffefb481a1e7eca1e /dec_audio.c
parentae4f8a9a86396842bd41102963384dfd392ba9c3 (diff)
downloadmpv-5dd2ccdbaca32b08c863df2ebfbb23443906b848.tar.bz2
mpv-5dd2ccdbaca32b08c863df2ebfbb23443906b848.tar.xz
Now oggvorbis decoding properly works, but a/v sync is bad.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1835 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'dec_audio.c')
-rw-r--r--dec_audio.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/dec_audio.c b/dec_audio.c
index 0a317825fb..8015986c18 100644
--- a/dec_audio.c
+++ b/dec_audio.c
@@ -410,9 +410,9 @@ case AFM_VORBIS: {
}
printf("OggVorbis: Pageout: successfull.\n");
/* commenting out pagein to leave data (hopefully) to the decoder - atmos */
- //ogg_stream_pagein(&sh_audio->ov->os,&sh_audio->ov->og); /* we can ignore any errors here
- // as they'll also become apparent
- // at packetout */
+ ogg_stream_pagein(&sh_audio->ov->os,&sh_audio->ov->og); /* we can ignore any errors here
+ as they'll also become apparent
+ at packetout */
/* Get the serial number and set up the rest of decode. */
/* serialno first; use it to set up a logical stream */
@@ -463,33 +463,37 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
float **pcm;
ogg_int16_t convbuffer[4096];
int convsize;
- minlen=4096; // XXX hack, not neccessarily needed - atmos
- convsize=minlen/sh_audio->ov->vi.channels;
- while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) {
- if(ret == -1)
- printf("OggVorbis: Pageout: not properly synced, had to skip some bytes.\n");
- else
- if(ret == 0) {
- //printf("OggVorbis: Pageout: need more data to verify page, reading more data.\n");
- /* submit a minlen k block to libvorbis' Ogg layer */
- buffer=ogg_sync_buffer(&sh_audio->ov->oy,minlen);
- bytes=demux_read_data(sh_audio->ds,buffer,minlen);
- ogg_sync_wrote(&sh_audio->ov->oy,bytes);
- if(bytes==0)
- printf("OggVorbis: 0Bytes written, possible End of Stream\n");
- }
- }
- //printf("OggVorbis: Pageout: successfull, pagin in.\n");
- if(ogg_stream_pagein(&sh_audio->ov->os,&sh_audio->ov->og)<0)
- printf("OggVorbis: Pagein failed!\n");
+ int readlen=4096;
+ len=0;
+ convsize=readlen/sh_audio->ov->vi.channels;
+ while(len < minlen) { /* double loop allows for break in inner loop */
+ while(len < minlen) { /* without aborting the outer loop - atmos */
ret=ogg_stream_packetout(&sh_audio->ov->os,&sh_audio->ov->op);
- if(ret==0)
- printf("OggVorbis: Packetout: need more data, FIXME!\n");
- else
- if(ret<0)
+ if(ret==0) {
+ //printf("OggVorbis: Packetout: need more data, paging!\n");
+ while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) {
+ if(ret == -1)
+ printf("OggVorbis: Pageout: not properly synced, had to skip some bytes.\n");
+ else
+ if(ret == 0) {
+ //printf("OggVorbis: Pageout: need more data to verify page, reading more data.\n");
+ /* submit a readlen k block to libvorbis' Ogg layer */
+ buffer=ogg_sync_buffer(&sh_audio->ov->oy,readlen);
+ bytes=demux_read_data(sh_audio->ds,buffer,readlen);
+ ogg_sync_wrote(&sh_audio->ov->oy,bytes);
+ if(bytes==0)
+ printf("OggVorbis: 0Bytes written, possible End of Stream\n");
+ }
+ }
+ //printf("OggVorbis: Pageout: successfull, pagin in.\n");
+ if(ogg_stream_pagein(&sh_audio->ov->os,&sh_audio->ov->og)<0)
+ printf("OggVorbis: Pagein failed!\n");
+ break;
+ } else if(ret<0) {
printf("OggVorbis: Packetout: missing or corrupt data, skipping packet!\n");
- else {
+ break;
+ } else {
/* we have a packet. Decode it */
@@ -535,17 +539,19 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
printf("Clipping in frame %ld\n",(long)(sh_audio->ov->vd.sequence));
//fwrite(convbuffer,2*sh_audio->ov->vi.channels,bout,stderr); //dump pcm to file for debugging
- len=2*sh_audio->ov->vi.channels*bout;
- memcpy(buf,convbuffer,len);
+ memcpy(buf+len,convbuffer,2*sh_audio->ov->vi.channels*bout);
+ len+=2*sh_audio->ov->vi.channels*bout;
vorbis_synthesis_read(&sh_audio->ov->vd,bout); /* tell libvorbis how
many samples we
actually consumed */
}
+ } // from else, packetout ok
+ } // while len
+ } // outer while len
if(ogg_page_eos(&sh_audio->ov->og))
printf("OggVorbis: End of Stream reached!\n"); // FIXME clearup decoder, notify mplayer - atmos
- } // from else, packetout ok
break;
}