<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2722" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=4>Mon,</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=4>Here is&nbsp;feedback that I got concerning the 
access violation, i.e. the failure of the while loop below.&nbsp; Does this 
solve the problem?</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=4>Steve</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT>&nbsp;</DIV>
<DIV>My guess is that speex_decoder_init() should be outside the while().. 
loop<BR>as speex_decoder_destroy() is also outside.</DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=mowin.dev@gmail.com href="mailto:mowin.dev@gmail.com">Mo Win</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=speex-dev@xiph.org 
  href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, October 17, 2005 8:05 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [Speex-dev] Error Executing 
  sampledec in VC++</DIV>
  <DIV><BR></DIV>hey guys, I just compiled an application similar to sampledec.c 
  (for speex 1.1.10) and it was fine but when I executed it, the app exited 
  without doing anything. I'm using MS VC 6.0 and this was all I got -<SPAN 
  style="FONT-WEIGHT: bold"> First-chance exception in sampledec.exe : 
  0xC0000005: Access Violation. </SPAN>Has anyone encountered this / does anyone 
  know how to deal with it? by the way, sampleenc executed perfectly... 
  <BR><BR>When I removed the "while" loop in sampledec, the program executed 
  fine (I placed printf's to check which lines were executed). I also tried 
  running the loop only once (erasing only the while statement and retaining the 
  code within it) and it worked fine again. Something seems to be happening 
  during loop iteration that causes the program to terminate abnormally.. any 
  clues? thanks very much for any tip..<BR><BR>In 
  gratitude,<BR>Mon<BR><BR>(Below is my code. it's almost exactly like sampleenc 
  except I read a file stream instead of stdin)<BR><BR>#include 
  "speex/speex.h"<BR><BR>#include &lt;stdio.h&gt;<BR>#include 
  &lt;iostream.h&gt;<BR><BR>void main ()<BR>{<BR>&nbsp;&nbsp;&nbsp; <SPAN 
  style="COLOR: rgb(153,255,153)">// Definitions</SPAN><BR>&nbsp;&nbsp;&nbsp; 
  #define FRAME_SIZE 160<BR>&nbsp;&nbsp;&nbsp; #define 
  FIXED_POINT<BR><BR>&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: rgb(153,255,153)"> // 
  Variable Declarations</SPAN><BR>&nbsp;&nbsp;&nbsp; FILE *fo, 
  *fs;<BR>&nbsp;&nbsp;&nbsp; short spx [FRAME_SIZE];<BR>&nbsp;&nbsp;&nbsp; float 
  pcm [FRAME_SIZE];<BR>&nbsp;&nbsp;&nbsp; char cbits 
  [200];<BR>&nbsp;&nbsp;&nbsp; int nbBytes, n, temp;<BR><BR>&nbsp;&nbsp;&nbsp; 
  void *decstate;<BR>&nbsp;&nbsp;&nbsp; SpeexBits 
  spxbits;<BR><BR><BR>&nbsp;&nbsp;&nbsp; <SPAN 
  style="COLOR: rgb(153,255,153)">// Program starts 
  here:</SPAN><BR>&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Starting 
  spxdec...\n";<BR>&nbsp;&nbsp;&nbsp; fo = 
  fopen("samp.spx","rb");<BR><BR>&nbsp;&nbsp;&nbsp; if (fo == 
  NULL)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout &lt;&lt; 
  "Error!\n";<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp; cout &lt;&lt; "Okay!\n";<BR><BR>&nbsp;&nbsp;&nbsp; fs = 
  fopen ("pcmfile", "wb");<BR><BR>&nbsp;&nbsp;&nbsp; if (fs == 
  NULL)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout &lt;&lt; "Error creating 
  file!\n";<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  cout &lt;&lt; "File created!\n";<BR><BR><BR>&nbsp;&nbsp;&nbsp; while 
  (!(feof(fo)))<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; decstate = 
  speex_decoder_init (&amp;speex_nb_mode);<BR><BR>&nbsp;&nbsp;&nbsp; // Set 
  default options for decoding:<BR>&nbsp;&nbsp;&nbsp; temp = 
  1;<BR>&nbsp;&nbsp;&nbsp; speex_decoder_ctl(decstate, SPEEX_SET_ENH, 
  &amp;temp);<BR><BR><BR>&nbsp;&nbsp;&nbsp; // Initialize spxbits (structure 
  SpeexBits)<BR>&nbsp;&nbsp;&nbsp; speex_bits_init 
  (&amp;spxbits);<BR><BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fread 
  (&amp;nbBytes, sizeof(int), 1, fo);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  fread (cbits, 1, nbBytes, fo);<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  cout &lt;&lt; "1"; // just to see whether the loop 
  iterates<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; speex_bits_read_from 
  (&amp;spxbits, cbits, nbBytes);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  speex_decode (decstate, &amp;spxbits, pcm);<BR><BR><BR>&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp; // Copy 1 frame from float pcm to short 
  spx<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (n=0; n&lt;FRAME_SIZE; 
  n++)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; spx [n] = pcm 
  [n];<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fwrite (spx, sizeof(short), 
  FRAME_SIZE, fs);<BR><BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;// 
  end of&nbsp; loop<BR>&nbsp;&nbsp;&nbsp; // Entire file has been read, decoded 
  and saved<BR><BR>&nbsp;&nbsp;&nbsp; speex_decoder_destroy 
  (decstate);<BR>&nbsp;&nbsp;&nbsp; speex_bits_destroy 
  (&amp;spxbits);<BR>&nbsp;&nbsp;&nbsp; fclose (fo);<BR>&nbsp;&nbsp;&nbsp; 
  fclose (fs);<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; cout &lt;&lt; 
  "Finished processing!\n";<BR>}<BR><BR>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>Speex-dev mailing 
  list<BR>Speex-dev@xiph.org<BR>http://lists.xiph.org/mailman/listinfo/speex-dev<BR></BLOCKQUOTE></BODY></HTML>