summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-04-20 18:31:03 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-04-20 18:31:03 +0000
commit2d46a96efe82d911a106c316d6d11ac9a64cd9e0 (patch)
treed3c457ba38286e87e863ccb59eb575b2ab0ac0b5
parentccf0b324f336d93fcd6368ab2bda3d470adbbb99 (diff)
downloadxine-lib-2d46a96efe82d911a106c316d6d11ac9a64cd9e0.tar.gz
xine-lib-2d46a96efe82d911a106c316d6d11ac9a64cd9e0.tar.bz2
fix several audio buffer leaks
CVS patchset: 1748 CVS date: 2002/04/20 18:31:03
-rw-r--r--src/liba52/xine_decoder.c7
-rw-r--r--src/libdts/xine_decoder.c59
-rw-r--r--src/libw32dll/w32codec.c15
3 files changed, 47 insertions, 34 deletions
diff --git a/src/liba52/xine_decoder.c b/src/liba52/xine_decoder.c
index 484001a15..017423a78 100644
--- a/src/liba52/xine_decoder.c
+++ b/src/liba52/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.22 2002/04/09 03:38:00 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.23 2002/04/20 18:31:03 miguelfreitas Exp $
*
* stuff needed to turn liba52 into a xine decoder plugin
*/
@@ -331,11 +331,13 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts) {
buf = this->audio_out->get_buffer (this->audio_out);
int_samples = buf->mem;
+ buf->num_frames = 256*6;
for (i = 0; i < 6; i++) {
if (a52_block (&this->a52_state, this->samples)) {
printf ("liba52: a52_block error\n");
- return;
+ buf->num_frames = 0;
+ break;
}
switch (output_mode) {
@@ -374,7 +376,6 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts) {
/* output decoded samples */
- buf->num_frames = 256*6;
buf->vpts = pts;
this->audio_out->put_buffer (this->audio_out, buf);
diff --git a/src/libdts/xine_decoder.c b/src/libdts/xine_decoder.c
index 3b67d889a..e409d2144 100644
--- a/src/libdts/xine_decoder.c
+++ b/src/libdts/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.17 2002/04/09 03:38:00 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.18 2002/04/20 18:31:03 miguelfreitas Exp $
*
* 04-09-2001 DTS passtrough (C) Joachim Koenig
* 09-12-2001 DTS passthrough inprovements (C) James Courtier-Dutton
@@ -121,6 +121,14 @@ void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
return;
}
+ if ((data_in[0] != 0x7f) ||
+ (data_in[1] != 0xfe) ||
+ (data_in[2] != 0x80) ||
+ (data_in[3] != 0x01)) {
+ printf("DTS Sync bad\n");
+ return;
+ }
+
audio_buffer = this->audio_out->get_buffer (this->audio_out);
audio_buffer->frame_header_count = buf->decoder_info[1]; /* Number of frames */
audio_buffer->first_access_unit = buf->decoder_info[2]; /* First access unit */
@@ -134,13 +142,6 @@ void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
data_out=(uint8_t *) audio_buffer->mem;
- if ((data_in[0] != 0x7f) ||
- (data_in[1] != 0xfe) ||
- (data_in[2] != 0x80) ||
- (data_in[3] != 0x01)) {
- printf("DTS Sync bad\n");
- return;
- }
ac5_type=((data_in[4] & 0x01) << 6) | ((data_in[5] >>2) & 0x3f);
ac5_length=((data_in[5] & 0x03) << 12) | ((data_in[6] & 0xff) << 4) | ((data_in[7] & 0xf0) >> 4);
ac5_length++;
@@ -169,26 +170,28 @@ void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if (ac5_length > 8191) {
printf("ac5_length too long\n");
- return;
- }
-
- if (ac5_length <= 248) {
- ac5_pcm_length = 64;
- } else if (ac5_length <= 504) {
- ac5_pcm_length = 128;
- } else if (ac5_length <= 1016) {
- ac5_pcm_length = 256;
- } else if (ac5_length <= 2040) {
- ac5_pcm_length = 512;
- } else if (ac5_length <= 4088) {
- ac5_pcm_length = 1024;
+ ac5_pcm_length = 0;
} else {
- printf("BAD AC5 length\n");
- ac5_pcm_length = 512;
- }
- if (ac5_pcm_length < (512 )) {
- ac5_pcm_length = 512 ;
+
+ if (ac5_length <= 248) {
+ ac5_pcm_length = 64;
+ } else if (ac5_length <= 504) {
+ ac5_pcm_length = 128;
+ } else if (ac5_length <= 1016) {
+ ac5_pcm_length = 256;
+ } else if (ac5_length <= 2040) {
+ ac5_pcm_length = 512;
+ } else if (ac5_length <= 4088) {
+ ac5_pcm_length = 1024;
+ } else {
+ printf("BAD AC5 length\n");
+ ac5_pcm_length = 512;
+ }
+ if (ac5_pcm_length < (512 )) {
+ ac5_pcm_length = 512 ;
+ }
}
+
/* printf("DTS length=%d loop=%d pts=%u\n",ac5_pcm_length,n,audio_buffer->vpts); */
audio_buffer->num_frames = ac5_pcm_length;
@@ -198,7 +201,9 @@ void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
data_out[5] = 0; /* Unknown */
data_out[6] = (ac5_length << 3) & 0xff; /* ac5_length * 8 */
data_out[7] = ((ac5_length ) >> 5) & 0xff;
- swab(data_in, &data_out[8], ac5_length );
+
+ if( ac5_pcm_length )
+ swab(data_in, &data_out[8], ac5_length );
this->audio_out->put_buffer (this->audio_out, audio_buffer);
}
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c
index b69485675..5f3895307 100644
--- a/src/libw32dll/w32codec.c
+++ b/src/libw32dll/w32codec.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: w32codec.c,v 1.71 2002/04/16 02:36:46 miguelfreitas Exp $
+ * $Id: w32codec.c,v 1.72 2002/04/20 18:31:03 miguelfreitas Exp $
*
* routines for using w32 codecs
* DirectShow support by Miguel Freitas (Nov/2001)
@@ -980,6 +980,7 @@ static int w32a_init_audio (w32a_decoder_t *this,
unsigned long in_size=in_fmt_->nBlockAlign;
unsigned long out_size;
audio_buffer_t *audio_buffer;
+ int audio_buffer_mem_size;
in_fmt = (WAVEFORMATEX *) malloc (64);
@@ -999,8 +1000,14 @@ static int w32a_init_audio (w32a_decoder_t *this,
printf("w32codec: (ACM_Decoder) Cannot open audio output device\n");
return 0;
}
+
audio_buffer = this->audio_out->get_buffer (this->audio_out);
+ audio_buffer_mem_size = audio_buffer->mem_size;
+ audio_buffer->num_frames = 0;
+ audio_buffer->vpts = 0;
+ this->audio_out->put_buffer (this->audio_out, audio_buffer);
+
wf.nChannels = in_fmt->nChannels;
wf.nSamplesPerSec = in_fmt->nSamplesPerSec;
wf.nAvgBytesPerSec = 2*wf.nSamplesPerSec*wf.nChannels;
@@ -1030,8 +1037,8 @@ static int w32a_init_audio (w32a_decoder_t *this,
acmStreamSize(this->srcstream, in_size, &out_size, ACM_STREAMSIZEF_SOURCE);
out_size*=2;
- if(out_size < audio_buffer->mem_size)
- out_size=audio_buffer->mem_size;
+ if(out_size < audio_buffer_mem_size)
+ out_size=audio_buffer_mem_size;
printf("w32codec: Audio buffer min. size: %d\n",(int)out_size);
acmStreamSize(this->srcstream, out_size, (LPDWORD) &this->rec_audio_src_size,
@@ -1046,7 +1053,7 @@ static int w32a_init_audio (w32a_decoder_t *this,
return 0;
}
- out_size = audio_buffer->mem_size;
+ out_size = audio_buffer_mem_size;
printf("w32codec: output buffer size: %d\n",(int)out_size);
this->rec_audio_src_size=DS_AudioDecoder_GetSrcSize(this->ds_dec,out_size);