diff options
-rw-r--r-- | libspeex/bits.c | 10 | ||||
-rw-r--r-- | libspeex/misc.c | 15 | ||||
-rw-r--r-- | libspeex/misc.h | 7 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 8 | ||||
-rw-r--r-- | libspeex/sb_celp.c | 2 | ||||
-rw-r--r-- | libspeex/speex_header.c | 4 |
6 files changed, 31 insertions, 15 deletions
diff --git a/libspeex/bits.c b/libspeex/bits.c index 6ea495f..5c4cb0e 100644 --- a/libspeex/bits.c +++ b/libspeex/bits.c @@ -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; diff --git a/libspeex/misc.c b/libspeex/misc.c index 97b35b3..c7ce7a8 100644 --- a/libspeex/misc.c +++ b/libspeex/misc.c @@ -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 diff --git a/libspeex/misc.h b/libspeex/misc.h index 1d6c6cb..25cf1c0 100644 --- a/libspeex/misc.h +++ b/libspeex/misc.h @@ -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); diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 44f03b8..1828aed 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -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; } diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c index e2cb940..50b9824 100644 --- a/libspeex/sb_celp.c +++ b/libspeex/sb_celp.c @@ -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; } } diff --git a/libspeex/speex_header.c b/libspeex/speex_header.c index 7fc2f5a..8e10851 100644 --- a/libspeex/speex_header.c +++ b/libspeex/speex_header.c @@ -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; } |