Skip to contentSkip to conversation

Problem with: Broken Pipe

DISCUSSION Holger Rostalski 2 participants 2 messages Jul 24, 2003

lore
Share & tools
lore
#0 lore raw

moin.
i have a problem with development of a soundapplication for Linux 8.2 with ALSA 0.9.0

if i take the "Minimal Interrupt Driven -Program" from the tutorial (in attachments) and changed a little bit the play_callback-methode, i got at start a
"broken Pipe" error.

what means it?

my changes:
================

      int
	playback_callback (snd_pcm_sframes_t nframes)
	{
		int err;
	
		printf ("playback callback called with %u frames\n", nframes);
		unsigned char data[4*4096];
		for (int x=0; x<4096; x++)
		{
			buf[x]=10*x;
				data[4*x]=(unsigned char) buf[x];
				data[4*x+1]=buf[x] >> 8;
				data[4*x+2]=(unsigned char) buf[x];
				data[4*x+3]=buf[x] >> 8;
			cout << "test" << x;

			
		};
	
		if ((err = snd_pcm_writei (playback_handle, data, 4096)) < 0) {
			fprintf (stderr, "write failed (%s)\n", 	snd_strerror (err));
		}
	
		return err;
	}

-> if i delete the cout-command, the programm works fine...but with cout (or with fprint ) i got "broken pipe". ...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

this is only the simplest way to reproduce the error. my programm has much more code. <<<<<<<<<<<<<<<<<<<<<

greetz
Holger

#1 lore raw
Quoted 8 lines

i have a problem with development of a soundapplication for Linux 8.2 with ALSA 0.9.0

if i take the "Minimal Interrupt Driven -Program" from the tutorial (in attachments) and changed a little bit the play_callback-methode, i got at start a
"broken Pipe" error.

how many channels are you configuring? you are telling writei() that you are supplying 4096 *frames* of data, yet from what i can tell, you are actually trying to write data for, well, i don't know. could be 2 16 bit channels, or 1 32 bit channel, or 4 8 bit channels. i suspect that is the source of the problem: you are not supplying enough data to keep up with the card.

please remember that the arguments to almost every ALSA function that measures "an amount of audio" are in units of *frames*, not bytes and not samples.

--p

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01