[xiph-commits] r11196 - branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex

illiminable at svn.xiph.org illiminable at svn.xiph.org
Fri Apr 21 02:07:21 PDT 2006


Author: illiminable
Date: 2006-04-21 02:07:16 -0700 (Fri, 21 Apr 2006)
New Revision: 11196

Modified:
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h
Log:
* Add better error feedback on speex wrapper

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp	2006-04-20 23:35:56 UTC (rev 11195)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp	2006-04-21 09:07:16 UTC (rev 11196)
@@ -27,7 +27,7 @@
 	return false;
 }
 
-bool SpeexDecoder::decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize)
+SpeexDecoder::eSpeexResult SpeexDecoder::decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize)
 {
 	if (mPacketCount == 0) {
 		mPacketCount++;
@@ -35,11 +35,11 @@
 	} else if (mPacketCount == 1) {
 		//Comment
 		mPacketCount++;
-		return true;
+		return SPEEX_COMMENT_OK;
 	} else if (mPacketCount < 2+mNumExtraHeaders) {
 		//Ignore
 		mPacketCount++;
-		return true;
+		return SPEEX_EXTRA_HEADER_OK;
 	} else {
 		mPacketCount++;
 
@@ -52,12 +52,12 @@
 				break;
 			} else if (locRet == -2) {
 				//Corrupted
-				return false;
+				return SPEEX_CORRUPTED_BITSTREAM;
 			}
 
 			if (speex_bits_remaining(&mSpeexBits) < 0) {
 				//Corrupted
-				return false;
+				return SPEEX_CORRUPTED_UNDERFLOW;
 			}
 
 
@@ -65,13 +65,13 @@
 				speex_decode_stereo_int(outSamples, mFrameSize, mStereoState);
 			}
 		}
-		return true;
+		return SPEEX_DATA_OK;
 
 		
 	}
 }
 
-bool SpeexDecoder::decodeHeader(StampedOggPacket* inPacket)
+SpeexDecoder::eSpeexResult SpeexDecoder::decodeHeader(StampedOggPacket* inPacket)
 {
 
 	SpeexHeader* locSpeexHeader = NULL;
@@ -84,7 +84,7 @@
 
 	if (locSpeexHeader == NULL) {
 		//Can't read header
-		return false;
+		return SPEEX_BAD_HEADER;
 	}
 
 	//Check modes?
@@ -94,7 +94,7 @@
 
 	if (locSpeexHeader->speex_version_id > 1) {
 		//Invalid version
-		return false;
+		return SPEEX_INVALID_SPEEX_VERSION;
 	}
 
 	//TODO::: Other bitstream version checks
@@ -103,7 +103,7 @@
 
 	if (locState == NULL) {
 		//Init failed
-		return false;
+		return SPEEX_INITIALISATION_FAILED;
 	}
 
 	speex_decoder_ctl(locState, SPEEX_SET_ENH, &mDecoderSettings.mPerceptualEnhancement);
@@ -137,7 +137,7 @@
 
 	speex_bits_init(&mSpeexBits);
 
-	return true;
+	return SPEEX_HEADER_OK;
 
 
 }
\ No newline at end of file

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h	2006-04-20 23:35:56 UTC (rev 11195)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h	2006-04-21 09:07:16 UTC (rev 11196)
@@ -16,13 +16,26 @@
 	SpeexDecoder(void);
 	~SpeexDecoder(void);
 
+	enum eSpeexResult {
+		SPEEX_DATA_OK,
+		SPEEX_HEADER_OK,
+		SPEEX_COMMENT_OK,
+		SPEEX_EXTRA_HEADER_OK,
+		SPEEX_BAD_HEADER = 64,
+		SPEEX_CORRUPTED_BITSTREAM,
+		SPEEX_CORRUPTED_UNDERFLOW,
+		SPEEX_INVALID_SPEEX_VERSION,
+		SPEEX_INITIALISATION_FAILED,
+
+	};
+
 	bool setDecodeParams(SpeexDecodeSettings inSettings);
-	bool decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize); 
+	eSpeexResult decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize); 
 
 	int frameSize()	{	return mFrameSize;	}
 	int numChannels()	{	return mNumChannels;	}
 protected:
-	bool decodeHeader(StampedOggPacket* inPacket);
+	eSpeexResult decodeHeader(StampedOggPacket* inPacket);
 	unsigned long mPacketCount;
 
 	int mFrameSize;



More information about the commits mailing list