ALSA PCM play one small problem



Hello

I wonder why this code below makes a Seg. Fault, after playing one
period of PCM samples, when I comment infinite while loop ?

while (1) {
make_sine(areas, 0, period_size, &phase);
ptr = samples;
cptr = period_size;
while (cptr > 0) {
err = snd_pcm_writei(handle, ptr, cptr);
if (err == -EAGAIN)
continue;
if (err < 0) {
if (xrun_recovery(handle, err) < 0) {
printf("Write error: %s\n",
snd_strerror(err));
exit(EXIT_FAILURE);
}
break; /* skip one period */
}
ptr += err;
cptr -= err;
}

}

This is a part of example from: http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html
(functions make_sine and xrun_recovery was taken from there).

All I want to do is to play only one period of sine sound, than change
sine frequency and play again the sound (in real time). I need it for
AFSK (http://en.wikipedia.org/wiki/AFSK) modulation, so if anyone can
explain to me why this code make seg. fault I will be grateful.

Ign.
.



Relevant Pages

  • djgpp v2 : Control register access segfaults
    ... I'm upgrading my application from djgpp v1 to djgpp v2 and am seeing a seg ... write) control registers (specifically CR4). ... The seg fault always occurs on "movl %%cr4, ...
    (comp.os.msdos.djgpp)
  • LD_ASSUME_KERNEL
    ... When I stop the execution I have a seg ... is 2.4.20 I have a seg fault. ... So it seems that my program works with LinuxThread code but not NPTL ...
    (comp.programming.threads)
  • Re: pointer to an int array
    ... "gooch" writes: ... > fault but that may not be the case. ... it's not true that "in most cases you would get a seg ... Attempting to access an array beyond its bounds is very ...
    (comp.lang.c)
  • Seg Fault on C library
    ... fault on one of my threads. ... seg fault and after I loaded GDB and did a trace, ... stack trace below. ...
    (comp.os.linux.development.system)