snd_pcm_start fails
I am stumped. This short and simple program fails for me:
---
#include <alsa/asoundlib.h>
#include <assert.h>
#define NOFAIL == 0 || (assert(0), 1)
int main() {
snd_pcm_t *playback_handle;
snd_pcm_hw_params_t *hw_params;
snd_output_t *debug;
snd_output_stdio_attach(&debug, stdout, 0) NOFAIL;
/* I have tried both hw:0 and plughw:0 */
snd_pcm_open( &playback_handle, "hw:0", SND_PCM_STREAM_PLAYBACK, 0) NOFAIL;
snd_pcm_hw_params_malloc( &hw_params ) NOFAIL;
snd_pcm_hw_params_any( playback_handle, hw_params ) NOFAIL;
snd_pcm_hw_params_set_access( playback_handle, hw_params, SND_PCM_ACCESS_MMAP_INTERLEAVED ) NOFAIL;
snd_pcm_hw_params_set_format( playback_handle, hw_params,SND_PCM_FORMAT_S16 ) NOFAIL;
snd_pcm_hw_params_set_rate( playback_handle, hw_params, 44100, 0 ) NOFAIL;
snd_pcm_hw_params_set_channels( playback_handle, hw_params, 2 ) NOFAIL;
snd_pcm_hw_params_set_period_size( playback_handle, hw_params, 2048, 0 ) NOFAIL;
snd_pcm_hw_params( playback_handle, hw_params ) NOFAIL;
snd_pcm_prepare( playback_handle ) NOFAIL;
snd_pcm_dump( playback_handle, debug );
snd_pcm_start( playback_handle ) NOFAIL;
}---
Everything seems to be in good shape up until the call to snd_pcm_start, but then the snd_pcm_start fails. Here is the output:
---
Hardware PCM card 0 'Sound Blaster Live!' device 0 subdevice -1
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16buffer_size : 16384period_size : 2048period_time : 46439tick_time : 10000tstamp_mode : NONEperiod_step : 1sleep_min : 0avail_min : 2048xfer_align : 2048start_threshold : 1stop_threshold : 16384silence_threshold: 0silence_size : 0
boundary : 1073741824
ALSA lib pcm_hw.c:384:(snd_pcm_hw_start) SNDRV_PCM_IOCTL_START failed: Broken pipe
display: display.c:29: main: Assertion `0' failed.
Aborted
---
Any ideas?? This is ALSA 0.9.0rc1, kernel 2.4.17, emu10k1 as you can see. Other ALSA apps such as alsaplayer and JACK work fine.
Josh
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf
Quoted 1 line · * To [email protected] ([email protected]) wrote:
I am stumped. This short and simple program fails for me:
Wingo solved the mystery for me. Apparently you are required to do an mmap_begin and mmap_commit before you can call snd_pcm_start.
Josh
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf
Quoted 5 lines · * To [email protected] ([email protected]) wrote:
Quoted 1 line
I am stumped. This short and simple program fails for me:
Wingo solved the mystery for me. Apparently you are required to do an
mmap_beginandmmap_commitbefore you can callsnd_pcm_start.
or more generally: you have to put some data in place (somehow) before calling start, unless you used the "start on data ready" flag during setup.
--p
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Bringing you mounds of caffeinated joy.
http://thinkgeek.com/sf