pa_simple_read returns 0 data on success

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2012-03-17 at 10:01 -0700, Laxmikant Rashinkar wrote:
> Hi,
> 
> I'm using the simple API to read from a monitor source like this:
> 
> simple = pa_simple_new(NULL, "xrdp", PA_STREAM_RECORD, NULL,
>                         "record", &samp_spec, NULL, NULL, &error);
> 
> ... perform error checking ...
> 
> bytes_read = pa_simple_read(simple, cptr, AUDIO_BUF_SIZE, &error)) < 0)
> 
> When audio data is available, pa_simple_read() works fine. But when
> there is no audio data available, pa_simple_read() returns with
> success, but the data is always 0. My understanding was that pa_simple_read()
> would block till data was available.

pa_simple_read() does block until data is available. Your problem is
that you expect that there is no data available from the monitor source
when nothing's playing to the sink. But there is data available: if
there's nothing playing to the sink, the sink will play silence to the
sound card, and silence is then what you get from the monitor source.
Usually when nothing is playing to a sink, the sink will suspend itself
after a while, so it stops writing silence, but recording from the
monitor source keeps the sink from suspending. There's the
PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND flag, but you can't use it with the
simple API.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux