Hi amjadqau -
I have to admit that I'm not a C programmer, and so I can't do much more than modify existing NI example programs. Have you checked for a memory leak during runtime? That's the only explanation I can offer for the program stopping or crashing after a long time. It could be coming from your Lame code or some other part of the program, too.
Offhand, removing the *2 from the allocation size worked because it was trying to allocate too much memory for your system. To be safe, I gave it a very large allocation so the default buffer size wouldn't be used for small values of RATE and PERIOD. If RATE and PERIOD are large (like 32k and 60), then you can safely remove the *2 factor and still have a custom buffer allocation.
David Staab, CLA
Staff Systems Engineer
National Instruments