[speex-dev] LIB usage

Jean-Marc Valin jean-marc.valin at hermes.usherb.ca
Tue Mar 4 12:41:23 PST 2003

(sorry for the delay)
Looking at your code, I see a couple errors, but I don't see how they
can result in a crash. First, I don't see why you read 1024 samples at a
time, while it should be frame_size. Also, you don't really need
nBytesFrame, as the 3rd argument to speex_bits_write is just the max
size of your array (just to prevent possible overflows), not the exact
amount you want to read.

The only thing I see is if your byte_ptr array is too small to hold one
frame, it may crash. Otherwise, maybe if you tell me where exactly the
crash occurs (preferable using ElectricFence or valgrind), it would


> I'm trying to use the speexlib but I just can't do it. I've made just like the 
> example (on the site) says. Some times I get SIGFAULT. Also, I'm reading the 
> input_frames from /dev/dsp (directly). What is missing here?
>   speex_bits_init(&bits);
>   enc_state = speex_encoder_init(&speex_nb_mode);
>   speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &frame_size);
>   for(n=0; n<100; n++)
>   {
>     read_from_dev(fd1, (float *)input_frame, 1024);
>     speex_bits_reset(&bits);
>     speex_encode(enc_state, input_frame, &bits);
>     nBytesFrame = speex_bits_nbytes(&bits);     
>     nbBytes = speex_bits_write(&bits, byte_ptr, nBytesFrame);
>     write_to_file(fd2, byte_ptr, nbBytes);
>   }
>   speex_bits_destroy(&bits);
>   speex_encoder_destroy(enc_state);
> Thank you
> Bruno Rodrigues
> --- >8 ----
> List archives:  http://www.xiph.org/archives/
> Ogg project homepage: http://www.xiph.org/ogg/
> To unsubscribe from this list, send a message to 'speex-dev-request at xiph.org'
> containing only the word 'unsubscribe' in the body.  No subject is needed.
> Unsubscribe messages sent to the list will be ignored/filtered.

Jean-Marc Valin, M.Sc.A.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 242 bytes
Desc: signature.asc
Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20030304/e12809f5/signature-0001.pgp

More information about the Speex-dev mailing list