diff -ru rockboxC/apps/codecs/libogg/framing.c rockboxD/apps/codecs/libogg/framing.c
--- rockboxC/apps/codecs/libogg/framing.c	2006-06-27 16:01:48.000000000 +0200
+++ rockboxD/apps/codecs/libogg/framing.c	2006-06-27 21:43:09.000000000 +0200
@@ -501,6 +501,16 @@
   }
   return(0);
 }
+void ogg_alloc_buffer(ogg_sync_state *oy, long size){
+    long newsize=size+oy->fill+size; /* an extra page to be nice */
+    if(oy->data){
+      oy->data=_ogg_realloc(oy->data,newsize);
+	printf("Realloc buffer\n");
+    }else
+      oy->data=_ogg_malloc(newsize);
+    oy->storage=newsize;
+    return;
+}
 
 char *ogg_sync_buffer(ogg_sync_state *oy, long size){
 
@@ -515,10 +525,10 @@
   if(size>oy->storage-oy->fill){
     /* We need to extend the internal buffer */
     long newsize=size+oy->fill+4096; /* an extra page to be nice */
-
-    if(oy->data)
+    if(oy->data){
       oy->data=_ogg_realloc(oy->data,newsize);
-    else
+	printf("Realloc buffer\n");
+    }else
       oy->data=_ogg_malloc(newsize);
     oy->storage=newsize;
   }
diff -ru rockboxC/apps/codecs/libogg/ogg/ogg.h rockboxD/apps/codecs/libogg/ogg/ogg.h
--- rockboxC/apps/codecs/libogg/ogg/ogg.h	2006-06-27 16:01:48.000000000 +0200
+++ rockboxD/apps/codecs/libogg/ogg/ogg.h	2006-06-27 21:43:21.000000000 +0200
@@ -168,6 +168,7 @@
 extern int      ogg_sync_reset(ogg_sync_state *oy);
 extern int	ogg_sync_destroy(ogg_sync_state *oy);
 
+extern void     ogg_alloc_buffer(ogg_sync_state *oy, long size);
 extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
 extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
 extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
diff -ru rockboxC/apps/codecs/speex.c rockboxD/apps/codecs/speex.c
--- rockboxC/apps/codecs/speex.c	2006-06-27 16:07:28.000000000 +0200
+++ rockboxD/apps/codecs/speex.c	2006-06-27 21:45:40.000000000 +0200
@@ -17,8 +17,12 @@
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  * KIND, either express or implied.
  *
- ****************************************************************************/
-
+ *******************
+*********************************************************/
+//22000,26000,40000,44000,48000,52000,56000,60000,66000,70000,
+//4096: 102400
+//8192:106496
+//262144
 #include "codeclib.h"
 // #include "Tremor/ivorbisfile.h"
 //#include "libspeex/speex/speex_bits.h"
@@ -31,8 +35,8 @@
 #include "libspeex/speex/speex_callbacks.h"
 #include "codeclib.h"
 #define MAX_FRAME_SIZE 2000
-#define CHUNKSIZE 5000  /*5kb*/
-#define SEEK_CHUNKSIZE 10*CHUNKSIZE
+#define CHUNKSIZE 10000  /*2kb*/
+#define SEEK_CHUNKSIZE 7*CHUNKSIZE
 #include <stdio.h>
 
 CODEC_HEADER
@@ -380,7 +384,7 @@
     rb->memcpy(iramstart, iramcopy, iramend - iramstart);
     rb->memset(iedata, 0, iend - iedata);
     #endif
-
+    rb->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(CHUNKSIZE*128));
     //rb->configure(CODEC_DSP_ENABLE, (bool *)true);
     
     rb->configure(DSP_DITHER, (bool *)false);
@@ -394,6 +398,7 @@
 	goto exit;
     }
     ogg_sync_init(&oy);
+    ogg_alloc_buffer(&oy,2*CHUNKSIZE);
     samplerate=rb->id3->frequency; //get samplerate from metadata 
 				   //parsing to support start offset
     //codec_set_replaygain(rb->id3);
@@ -414,6 +419,15 @@
 				rb->seek_time,
 				(page_granule/samplerate)*1000,
 				samplerate);
+#ifdef SIMULATOR
+				printf("Speex seek page:%d,%d,%d,%d\n",
+				((ogg_int64_t)rb->seek_time/1000)*(ogg_int64_t)samplerate,
+				page_granule,
+				((ogg_int64_t)rb->id3->length/1000)*(ogg_int64_t)samplerate,
+				rb->seek_time,
+				(page_granule/samplerate)*1000,
+				samplerate);
+#endif
 			speex_seek_page_granule(
 				((ogg_int64_t)rb->seek_time/1000)*(ogg_int64_t)samplerate,
 				page_granule,
@@ -429,18 +443,22 @@
 
 	int j;
 next_page:
-       /*Get the ogg buffer for writing*/
- 	if(get_more_data(&oy,&cur_offset,rb)<1){//read error
- 		//DEBUGF("Decoding, read error\n");
- 		error=CODEC_ERROR;
- 		goto done;
- 	}
-
+// 	get_next_page(&oy,&og,&cur_offset,0,rb);
+// 	lclpageno=-1;
+//      }else{
+	/*Get the ogg buffer for writing*/
+	if(get_more_data(&oy,&cur_offset,rb)<1){//read error
+		//DEBUGF("Decoding, read error\n");
+		error=CODEC_ERROR;
+		goto done;
+	}
+// /*      }*/
+      
 	/*Loop for all complete pages we got (most likely only one)*/
       
       while (ogg_sync_pageout(&oy, &og)==1)
       {
-	 int packet_no;
+	int packet_no;
          if (stream_init == 0) {
 	    ogg_stream_init(&os, ogg_page_serialno(&og));
             stream_init = 1;
@@ -495,9 +513,7 @@
 			}
                }
 	       //int lost=0;
-               packet_no++;
-
-               /*End of stream condition*/
+               packet_no++;              /*End of stream condition*/
                if (op.e_o_s)
                   eos=1;
 
@@ -510,6 +526,7 @@
                {
                   int ret;
                   /*Decode frame*/
+		  //printf("Dcf:%d\n",cur_granule);
                   ret = speex_decode_int(st, &vf, output);
 /* 		  printf("\nDecoded:");
  		  for (i=frame_size;i<frame_size*channels;i++)
@@ -537,7 +554,7 @@
                   {
                      //int frame_offset = 0;
                      int new_frame_size = frame_size;
-
+		     
                      if (new_frame_size>0)
                      {  
 			while (!rb->pcmbuf_insert_split((const char*)output,(const char*)output,sizeof(short) * new_frame_size*channels)) {
