[xiph-commits] r3853 - in libfishsound/trunk: include/fishsound src/libfishsound
conrad at svn.annodex.net
conrad at svn.annodex.net
Fri Feb 20 04:43:43 PST 2009
Author: conrad
Date: 2009-02-20 04:43:43 -0800 (Fri, 20 Feb 2009)
New Revision: 3853
Modified:
libfishsound/trunk/include/fishsound/decode.h
libfishsound/trunk/src/libfishsound/decode.c
libfishsound/trunk/src/libfishsound/speex.c
Log:
speex.c: handle remaining malloc/realloc errors, propagate to decode.c
Towards Mozilla bug 468293
Modified: libfishsound/trunk/include/fishsound/decode.h
===================================================================
--- libfishsound/trunk/include/fishsound/decode.h 2009-02-20 12:43:08 UTC (rev 3852)
+++ libfishsound/trunk/include/fishsound/decode.h 2009-02-20 12:43:43 UTC (rev 3853)
@@ -79,7 +79,9 @@
* \param fsound A FishSound* handle (created with mode FISH_SOUND_DECODE)
* \param decoded The callback to call
* \param user_data Arbitrary user data to pass to the callback
- * \returns 0 on success, -1 on failure
+ * \retval 0 Success
+ * \retval FISH_SOUND_ERR_BAD Not a valid FishSound* handle
+ * \retval FISH_SOUND_ERR_OUT_OF_MEMORY Out of memory
*/
int fish_sound_set_decoded_float (FishSound * fsound,
FishSoundDecoded_Float decoded,
@@ -91,7 +93,9 @@
* \param fsound A FishSound* handle (created with mode FISH_SOUND_DECODE)
* \param decoded The callback to call
* \param user_data Arbitrary user data to pass to the callback
- * \returns 0 on success, -1 on failure
+ * \retval 0 Success
+ * \retval FISH_SOUND_ERR_BAD Not a valid FishSound* handle
+ * \retval FISH_SOUND_ERR_OUT_OF_MEMORY Out of memory
*/
int fish_sound_set_decoded_float_ilv (FishSound * fsound,
FishSoundDecoded_FloatIlv decoded,
@@ -113,6 +117,7 @@
* callback returning FISH_SOUND_STOP_ERR before any input bytes were consumed.
* This will occur when PCM is decoded from previously buffered input, and
* stopping is immediately requested.
+ * \retval FISH_SOUND_ERR_BAD Not a valid FishSound* handle
* \retval FISH_SOUND_ERR_OUT_OF_MEMORY Out of memory
*/
long fish_sound_decode (FishSound * fsound, unsigned char * buf, long bytes);
Modified: libfishsound/trunk/src/libfishsound/decode.c
===================================================================
--- libfishsound/trunk/src/libfishsound/decode.c 2009-02-20 12:43:08 UTC (rev 3852)
+++ libfishsound/trunk/src/libfishsound/decode.c 2009-02-20 12:43:43 UTC (rev 3853)
@@ -58,7 +58,7 @@
{
int ret = 0;
- if (fsound == NULL) return -1;
+ if (fsound == NULL) return FISH_SOUND_ERR_BAD;
#if FS_DECODE
ret = fs_decode_update (fsound, 0);
@@ -80,7 +80,7 @@
{
int ret = 0;
- if (fsound == NULL) return -1;
+ if (fsound == NULL) return FISH_SOUND_ERR_BAD;
#if FS_DECODE
ret = fs_decode_update (fsound, 1);
@@ -101,7 +101,7 @@
{
int format;
- if (fsound == NULL) return -1;
+ if (fsound == NULL) return FISH_SOUND_ERR_BAD;
#if FS_DECODE
if (fsound->info.format == FISH_SOUND_UNKNOWN) {
Modified: libfishsound/trunk/src/libfishsound/speex.c
===================================================================
--- libfishsound/trunk/src/libfishsound/speex.c 2009-02-20 12:43:08 UTC (rev 3852)
+++ libfishsound/trunk/src/libfishsound/speex.c 2009-02-20 12:43:43 UTC (rev 3853)
@@ -291,12 +291,24 @@
fsound->info.channels = channels;
fss->ipcm = fs_malloc (sizeof (float) * fss->frame_size * channels);
+ if (fss->ipcm == NULL) {
+ return FISH_SOUND_ERR_OUT_OF_MEMORY;
+ }
if (channels == 1) {
fss->pcm[0] = fss->ipcm;
} else if (channels == 2) {
fss->pcm[0] = fs_malloc (sizeof (float) * fss->frame_size);
+ if (fss->pcm[0] == NULL) {
+ fs_free (fss->ipcm);
+ return FISH_SOUND_ERR_OUT_OF_MEMORY;
+ }
fss->pcm[1] = fs_malloc (sizeof (float) * fss->frame_size);
+ if (fss->pcm[1] == NULL) {
+ fs_free (fss->pcm[0]);
+ fs_free (fss->ipcm);
+ return FISH_SOUND_ERR_OUT_OF_MEMORY;
+ }
}
if (fss->nframes == 0) fss->nframes = 1;
@@ -617,7 +629,7 @@
ipcm_new = (float *)fs_realloc (fss->ipcm,
pcm_size * fss->frame_size * fsound->info.channels);
- if (ipcm_new == NULL) return -1;
+ if (ipcm_new == NULL) return FISH_SOUND_ERR_OUT_OF_MEMORY;
fss->ipcm = ipcm_new;
@@ -636,13 +648,13 @@
} else if (fsound->info.channels == 2) {
pcm0 = fs_realloc (fss->pcm[0], pcm_size * fss->frame_size);
if (pcm0 == NULL) {
- return -1;
+ return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
pcm1 = fs_realloc (fss->pcm[1], pcm_size * fss->frame_size);
if (pcm1 == NULL) {
fs_free (pcm0);
- return -1;
+ return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
fss->pcm[0] = pcm0;
More information about the commits
mailing list