<!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>I mis-read the number of loops below,
earlier in the day, and made an obviously incorrect recommendation about moving
fclose( ). However, being very interested myself in being able to decode
Speex files on the fly in my MFC project, I am in the process of asking an
audio expert about this while loop problem. I don't think I have
ever gotten any further than the access violation you report.</FONT></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 <stdio.h><BR>#include
<iostream.h><BR><BR>void main ()<BR>{<BR> <SPAN
style="COLOR: rgb(153,255,153)">// Definitions</SPAN><BR>
#define FRAME_SIZE 160<BR> #define
FIXED_POINT<BR><BR> <SPAN style="COLOR: rgb(153,255,153)"> //
Variable Declarations</SPAN><BR> FILE *fo,
*fs;<BR> short spx [FRAME_SIZE];<BR> float
pcm [FRAME_SIZE];<BR> char cbits
[200];<BR> int nbBytes, n, temp;<BR><BR>
void *decstate;<BR> SpeexBits
spxbits;<BR><BR><BR> <SPAN
style="COLOR: rgb(153,255,153)">// Program starts
here:</SPAN><BR> cout << "Starting
spxdec...\n";<BR> fo =
fopen("samp.spx","rb");<BR><BR> if (fo ==
NULL)<BR> cout <<
"Error!\n";<BR> else<BR>
cout << "Okay!\n";<BR><BR> fs =
fopen ("pcmfile", "wb");<BR><BR> if (fs ==
NULL)<BR> cout << "Error creating
file!\n";<BR> else<BR>
cout << "File created!\n";<BR><BR><BR> while
(!(feof(fo)))<BR> {<BR> decstate =
speex_decoder_init (&speex_nb_mode);<BR><BR> // Set
default options for decoding:<BR> temp =
1;<BR> speex_decoder_ctl(decstate, SPEEX_SET_ENH,
&temp);<BR><BR><BR> // Initialize spxbits (structure
SpeexBits)<BR> speex_bits_init
(&spxbits);<BR><BR><BR> fread
(&nbBytes, sizeof(int), 1, fo);<BR>
fread (cbits, 1, nbBytes, fo);<BR><BR>
cout << "1"; // just to see whether the loop
iterates<BR><BR> speex_bits_read_from
(&spxbits, cbits, nbBytes);<BR>
speex_decode (decstate, &spxbits, pcm);<BR><BR><BR>
// Copy 1 frame from float pcm to short
spx<BR> for (n=0; n<FRAME_SIZE;
n++)<BR> spx [n] = pcm
[n];<BR><BR> fwrite (spx, sizeof(short),
FRAME_SIZE, fs);<BR><BR> }<BR> //
end of loop<BR> // Entire file has been read, decoded
and saved<BR><BR> speex_decoder_destroy
(decstate);<BR> speex_bits_destroy
(&spxbits);<BR> fclose (fo);<BR>
fclose (fs);<BR> <BR> cout <<
"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>