Hi Takashi,
Can't you reopen (as feedback)?
Oh, perhaps I could; I haven't used Mantis before and didn't look that carefully :(
Also, I'm still encountering bug 2601 (a separate assert failure that happens if period_size == 0) even with the patch to pcm_ioplug.c. I think that PERIOD_TIME and PERIODS need to be constrained; I added a couple of comments to the bug.Hm, does it happen with the latest HG tree, too?
Yes (at least with the latest hg tree that was accessible via hg-mirror a few minutes ago). I put a patch on the bug that does make things work. Test case attached (adapted from flite mostly)
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <unistd.h> #include <alsa/asoundlib.h> static int getAvailableFrames(snd_pcm_t *pcm, int *xrunOccurred) { snd_pcm_sframes_t framesAvail = snd_pcm_avail_update( pcm ); *xrunOccurred = 0; if( -EPIPE == framesAvail ) { *xrunOccurred = 1; framesAvail = 0; } return framesAvail; } static char *buf; snd_pcm_t *audio_open_alsa(const char *pcm_dev_name, int sps, int channels) { unsigned int real_rate; int err; unsigned long bufSz = 1411; snd_pcm_t *pcm_handle; snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; snd_pcm_hw_params_t *hwparams; snd_pcm_format_t format; snd_pcm_access_t access = SND_PCM_ACCESS_RW_INTERLEAVED; /* Allocate the snd_pcm_hw_params_t structure on the stack. */ snd_pcm_hw_params_alloca(&hwparams); /* Open pcm device */ err = snd_pcm_open(&pcm_handle, pcm_dev_name, stream, 0); if (err < 0) { return NULL; } /* Init hwparams with full configuration space */ err = snd_pcm_hw_params_any(pcm_handle, hwparams); if (err < 0) { snd_pcm_close(pcm_handle); return NULL; } /* Set access mode */ err = snd_pcm_hw_params_set_access(pcm_handle, hwparams, access); if (err < 0) { snd_pcm_close(pcm_handle); return NULL; } format = SND_PCM_FORMAT_S16_LE; /* Set samble format */ err = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format); if (err <0) { snd_pcm_close(pcm_handle); return NULL; } /* Set sample rate near the disired rate */ real_rate = sps; err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0); if (err < 0) { snd_pcm_close(pcm_handle); return NULL; } /* Set number of channels */ assert(channels >0); err = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, channels); if (err < 0) { snd_pcm_close(pcm_handle); return NULL; } snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &bufSz); /* Commit hardware parameters */ err = snd_pcm_hw_params(pcm_handle, hwparams); if (err < 0) { snd_pcm_close(pcm_handle); return NULL; } /* Make sure the device is ready to accept data */ assert(snd_pcm_state(pcm_handle) == SND_PCM_STATE_PREPARED); return pcm_handle; } main(int argc, const char *argv[]) { snd_pcm_t *pcm; buf = (char *)malloc(1000000); pcm = audio_open_alsa("default", 22050, 1); int xrun; int result; pthread_t th; if (!pcm) { fprintf(stderr, "Couldn't open pcm\n"); exit(1); } unsigned long avail = snd_pcm_avail_update(pcm); if (avail > 100000) avail = 100000; result = snd_pcm_writei(pcm, buf, avail); }
_______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel