<br><br><div class="gmail_quote">On Mon, Jun 14, 2010 at 3:28 AM, Colin Guthrie <span dir="ltr"><<a href="mailto:gmane@colin.guthr.ie">gmane@colin.guthr.ie</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
'Twas brillig, and Scott Sibley at 14/06/10 08:56 did gyre and gimble:<br>
<div><div></div><div class="h5">> Hello. I'm writing a pulseaudio plugin for a visualization project, and<br>
> I'm going by the recording example from the pulseaudio documentation.<br>
> That example fails to print anything. There's another visualization<br>
> project that uses the async API, and it works fine on my computer, so I<br>
> think pulseaudio is working correctly. What might I be missing to get<br>
> the simple API example working?<br>
><br>
> Here's how I compiled the example.<br>
><br>
> gcc -o test test.c `pkg-config --libs --cflags libpulse libpulse-simple`<br>
<br>
<br>
</div></div>Did you mean to include some example code with this?<br>
<div><div></div><div class="h5"><br>
Col<br>
<br>
--<br>
<br>
Colin Guthrie<br>
gmane(at)<a href="http://colin.guthr.ie" target="_blank">colin.guthr.ie</a><br>
<a href="http://colin.guthr.ie/" target="_blank">http://colin.guthr.ie/</a><br>
<br>
Day Job:<br>
Tribalogic Limited [<a href="http://www.tribalogic.net/" target="_blank">http://www.tribalogic.net/</a>]<br>
Open Source:<br>
Mandriva Linux Contributor [<a href="http://www.mandriva.com/" target="_blank">http://www.mandriva.com/</a>]<br>
PulseAudio Hacker [<a href="http://www.pulseaudio.org/" target="_blank">http://www.pulseaudio.org/</a>]<br>
Trac Hacker [<a href="http://trac.edgewall.org/" target="_blank">http://trac.edgewall.org/</a>]<br>
<br>
_______________________________________________<br>
pulseaudio-discuss mailing list<br>
<a href="mailto:pulseaudio-discuss@mail.0pointer.de">pulseaudio-discuss@mail.0pointer.de</a><br>
<a href="https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss" target="_blank">https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss</a><br></div></div></blockquote><div><br>No I didn't. I'm speaking of the example that comes with the pulse audio documentation. The recording example. <br>
<br>Here's that example:<br><br>/***<br> This file is part of PulseAudio.<br><br> PulseAudio is free software; you can redistribute it and/or modify<br> it under the terms of the GNU Lesser General Public License as published<br>
by the Free Software Foundation; either version 2.1 of the License,<br> or (at your option) any later version.<br><br> PulseAudio is distributed in the hope that it will be useful, but<br> WITHOUT ANY WARRANTY; without even the implied warranty of<br>
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br> General Public License for more details.<br><br> You should have received a copy of the GNU Lesser General Public License<br> along with PulseAudio; if not, write to the Free Software<br>
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307<br> USA.<br>***/<br><br>#ifdef HAVE_CONFIG_H<br>#include <config.h><br>#endif<br><br>#include <stdio.h><br>#include <unistd.h><br>#include <string.h><br>
#include <errno.h><br><br>#include <pulse/simple.h><br>#include <pulse/error.h><br>#include <pulse/gccmacro.h><br><br>#define BUFSIZE 1024<br><br>/* A simple routine calling UNIX write() in a loop */<br>
static ssize_t loop_write(int fd, const void*data, size_t size) {<br> ssize_t ret = 0;<br><br> while (size > 0) {<br> ssize_t r;<br><br> if ((r = write(fd, data, size)) < 0)<br> return r;<br>
<br> if (r == 0)<br> break;<br><br> ret += r;<br> data = (const uint8_t*) data + r;<br> size -= (size_t) r;<br> }<br><br> return ret;<br>}<br><br>int main(int argc, char*argv[]) {<br>
/* The sample type to use */<br> static const pa_sample_spec ss = {<br> .format = PA_SAMPLE_S16LE,<br> .rate = 44100,<br> .channels = 2<br> };<br> pa_simple *s = NULL;<br> int ret = 1;<br>
int error;<br><br> /* Create the recording stream */<br> if (!(s = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error))) {<br> fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));<br>
goto finish;<br> }<br><br> for (;;) {<br> uint8_t buf[BUFSIZE];<br><br> /* Record some data ... */<br> if (pa_simple_read(s, buf, sizeof(buf), &error) < 0) {<br> fprintf(stderr, __FILE__": pa_simple_read() failed: %s\n", pa_strerror(error));<br>
goto finish;<br> }<br><br> /* And write it to STDOUT */<br> if (loop_write(STDOUT_FILENO, buf, sizeof(buf)) != sizeof(buf)) {<br> fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));<br>
goto finish;<br> }<br> }<br><br> ret = 0;<br><br>finish:<br><br> if (s)<br> pa_simple_free(s);<br><br> return ret;<br>}<br><br></div></div><br>