Commit b292d626 authored by jm's avatar jm
Browse files

Replaced some warnings by notifications when it's not necessarily caused

by a programming error.


git-svn-id: http://svn.xiph.org/trunk/speex@12775 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 145414db
......@@ -97,7 +97,7 @@ void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
int nchars = len / BYTES_PER_CHAR;
if (nchars > bits->buf_size)
{
speex_warning_int("Packet is larger than allocated buffer: ", len);
speex_notify("Packet is larger than allocated buffer");
if (bits->owner)
{
char *tmp = (char*)speex_realloc(bits->chars, nchars);
......@@ -110,7 +110,7 @@ void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
speex_warning("Could not resize input buffer: truncating input");
}
} else {
speex_warning("Do not own input buffer: truncating input");
speex_warning("Do not own input buffer: truncating oversize input");
nchars=bits->buf_size;
}
}
......@@ -159,10 +159,10 @@ void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes)
bits->chars=tmp;
} else {
nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1;
speex_warning("Could not resize input buffer: truncating input");
speex_warning("Could not resize input buffer: truncating oversize input");
}
} else {
speex_warning("Do not own input buffer: truncating input");
speex_warning("Do not own input buffer: truncating oversize input");
nchars=bits->buf_size;
}
}
......@@ -223,7 +223,7 @@ void speex_bits_pack(SpeexBits *bits, int data, int nbBits)
if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size)
{
speex_warning("Buffer too small to pack bits");
speex_notify("Buffer too small to pack bits");
if (bits->owner)
{
int new_nchars = ((bits->buf_size+5)*3)>>1;
......
......@@ -132,7 +132,7 @@ void *speex_move (void *dest, void *src, int n)
#ifndef OVERRIDE_SPEEX_ERROR
void speex_error(const char *str)
{
fprintf (stderr, "Fatal error: %s\n", str);
fprintf (stderr, "Fatal (internal) error: %s\n", str);
exit(1);
}
#endif
......@@ -140,14 +140,27 @@ void speex_error(const char *str)
#ifndef OVERRIDE_SPEEX_WARNING
void speex_warning(const char *str)
{
#ifndef DISABLE_WARNINGS
fprintf (stderr, "warning: %s\n", str);
#endif
}
#endif
#ifndef OVERRIDE_SPEEX_WARNING_INT
void speex_warning_int(const char *str, int val)
{
#ifndef DISABLE_WARNINGS
fprintf (stderr, "warning: %s %d\n", str, val);
#endif
}
#endif
#ifndef OVERRIDE_SPEEX_NOTIFY
void speex_notify(const char *str)
{
#ifndef DISABLE_NOTIFICATIONS
fprintf (stderr, "notification: %s\n", str);
#endif
}
#endif
......
......@@ -98,15 +98,18 @@ void speex_free_scratch (void *ptr);
/** Speex wrapper for mem_move */
void *speex_move (void *dest, void *src, int n);
/** Print error message to stderr */
/** Abort with an error message to stderr (internal Speex error) */
void speex_error(const char *str);
/** Print warning message to stderr */
/** Print warning message to stderr (programming error) */
void speex_warning(const char *str);
/** Print warning message with integer argument to stderr */
void speex_warning_int(const char *str, int val);
/** Print notification message to stderr */
void speex_notify(const char *str);
/** Generate a random number */
spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed);
......
......@@ -1257,7 +1257,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);
if (advance < 0)
{
speex_warning ("Invalid wideband mode encountered. Corrupted stream?");
speex_notify("Invalid mode encountered. The stream is corrupted.");
return -2;
}
advance -= (SB_SUBMODE_BITS+1);
......@@ -1272,7 +1272,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);
if (advance < 0)
{
speex_warning ("Invalid wideband mode encountered: corrupted stream?");
speex_notify("Invalid mode encountered. The stream is corrupted.");
return -2;
}
advance -= (SB_SUBMODE_BITS+1);
......@@ -1280,7 +1280,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
wideband = speex_bits_unpack_unsigned(bits, 1);
if (wideband)
{
speex_warning ("More than two wideband layers found: corrupted stream?");
speex_notify("More than two wideband layers found. The stream is corrupted.");
return -2;
}
......@@ -1305,7 +1305,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
return ret;
} else if (m>8) /* Invalid mode */
{
speex_warning("Invalid mode encountered: corrupted stream?");
speex_notify("Invalid mode encountered. The stream is corrupted.");
return -2;
}
......
......@@ -931,7 +931,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
}
if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL)
{
speex_warning("Invalid mode encountered: corrupted stream?");
speex_notify("Invalid mode encountered. The stream is corrupted.");
return -2;
}
}
......
......@@ -133,14 +133,14 @@ SpeexHeader *speex_packet_to_header(char *packet, int size)
for (i=0;i<8;i++)
if (packet[i]!=h[i])
{
speex_warning ("This doesn't look like a Speex file");
speex_notify("This doesn't look like a Speex file");
return NULL;
}
/*FIXME: Do we allow larger headers?*/
if (size < (int)sizeof(SpeexHeader))
{
speex_warning("Speex header too small");
speex_notify("Speex header too small");
return NULL;
}
......
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