Commit df657969 authored by Sam Hocevar's avatar Sam Hocevar

* ./modules/audio_filter/converter/s16tofloat32swab.c: compilation fix for

    systems which don't have swab(). Fixed a memory leak.
parent 1522351e
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* with endianness change * with endianness change
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: s16tofloat32swab.c,v 1.1 2002/09/18 01:28:04 henri Exp $ * $Id: s16tofloat32swab.c,v 1.2 2002/09/18 12:20:37 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
#include <string.h> #include <string.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "audio_output.h" #include "audio_output.h"
#include "aout_internal.h" #include "aout_internal.h"
...@@ -94,25 +99,29 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, ...@@ -94,25 +99,29 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
#ifdef HAVE_SWAB #ifdef HAVE_SWAB
s16 * p_swabbed = malloc( i * sizeof(s16) ); s16 * p_swabbed = malloc( i * sizeof(s16) );
swab( p_in_buf->p_buffer, p_swabbed, swab( p_in_buf->p_buffer, p_swabbed, i * sizeof(s16) );
i * sizeof(s16) );
p_in = p_swabbed +i - 1; p_in = p_swabbed + i - 1;
#else #else
byte_t temp; byte_t p_tmp[2];
#endif #endif
while( i-- ) while( i-- )
{ {
#ifndef HAVE_SWAB #ifndef HAVE_SWAB
temp = *(byte_t*)p_in; p_tmp[0] = ((byte_t*)p_in)[1];
*(byte_t*)p_in = *(byte_t*)p_in+1; p_tmp[1] = ((byte_t*)p_in)[0];
*(byte_t*)p_in+1 = temp; *p_out = (float)*p_tmp / 32768.0;
#endif #else
*p_out = (float)*p_in / 32768.0; *p_out = (float)*p_in / 32768.0;
#endif
p_in--; p_out--; p_in--; p_out--;
} }
#ifdef HAVE_SWAB
free( p_swabbed );
#endif
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 2; p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 2;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment