summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Courtier-Dutton <jcdutton@users.sourceforge.net>2003-09-01 13:19:28 +0000
committerJames Courtier-Dutton <jcdutton@users.sourceforge.net>2003-09-01 13:19:28 +0000
commit86827e34dbf2aec4151c1735958644029a5d1e32 (patch)
treef14c5bf3bc0417d71de2864777dbcd5f3882539b
parentb822540787bcecffb5170ac808ebb7df9f01a0d1 (diff)
downloadxine-lib-86827e34dbf2aec4151c1735958644029a5d1e32.tar.gz
xine-lib-86827e34dbf2aec4151c1735958644029a5d1e32.tar.bz2
Add warning and check, so that xine does not try to play
.WAV files with badly contructed headers. CVS patchset: 5325 CVS date: 2003/09/01 13:19:28
-rw-r--r--src/demuxers/demux_wav.c14
-rw-r--r--src/liblpcm/xine_decoder.c6
2 files changed, 14 insertions, 6 deletions
diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c
index d318c5998..f8370412f 100644
--- a/src/demuxers/demux_wav.c
+++ b/src/demuxers/demux_wav.c
@@ -22,7 +22,7 @@
* MS WAV File Demuxer by Mike Melanson (melanson@pcisys.net)
* based on WAV specs that are available far and wide
*
- * $Id: demux_wav.c,v 1.46 2003/08/25 21:51:39 f1rmb Exp $
+ * $Id: demux_wav.c,v 1.47 2003/09/01 13:19:28 jcdutton Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -357,6 +357,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input) {
demux_wav_t *this;
+ uint32_t align;
this = xine_xmalloc (sizeof (demux_wav_t));
this->stream = stream;
@@ -409,8 +410,15 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
/* special block alignment hack so that the demuxer doesn't send
* packets with individual PCM samples */
if ((this->wave->nAvgBytesPerSec / this->wave->nBlockAlign) ==
- this->wave->nSamplesPerSec)
- this->wave->nBlockAlign = PCM_BLOCK_ALIGN;
+ this->wave->nSamplesPerSec) {
+ align = PCM_BLOCK_ALIGN / this->wave->nBlockAlign;
+ align = align * this->wave->nBlockAlign;
+ this->wave->nBlockAlign = align;
+ } else {
+ printf("demux_wav: WAV header inconsistent, cannot play WAV file.\n");
+ free (this);
+ return NULL;
+ }
return &this->demux_plugin;
}
diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c
index e562933ca..a363f9e24 100644
--- a/src/liblpcm/xine_decoder.c
+++ b/src/liblpcm/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.43 2003/08/25 21:51:42 f1rmb Exp $
+ * $Id: xine_decoder.c,v 1.44 2003/09/01 13:19:29 jcdutton Exp $
*
* 31-8-2001 Added LPCM rate sensing.
* (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk
@@ -140,11 +140,11 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
return;
audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
-
+
/* Swap LPCM samples into native byte order, if necessary */
buf->type &= 0xffff0000;
stream_be = ( buf->type == BUF_AUDIO_LPCM_BE );
-
+
if( this->bits_per_sample == 16 ){
if (stream_be != this->cpu_be)
swab (sample_buffer, audio_buffer->mem, buf->size);