Sound complications

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

 



On Tue, 2016-04-19 at 18:48 +0000, John Promersberger wrote:
> So due to complications with a required OS/HW migration, I have been
> forced to write a JNI that allows a Java UI to play sounds thru pulse
> audio.  Seems to work pretty well.
> 
> 
> So I open a stream, write the sound to the stream.  When the user
> acknowledges the sound I destroy the stream, or the sound is to be
> interrupted by a more important sound, I destroy the stream and
> create a new stream for the new sound.
> 
> 
> 1.  Would it be improper to leave the stream open (for the entire
> length of time that my user interface is running) and not destroy
> it?  I would just write the new data to the existing stream.

You can leave the stream open. It's good to cork (i.e. pause) the
stream when not in use, though. This allows pulseaudio to release the
sound card when it's not being used. You can use pa_stream_cork() for
that, assuming that you're not using the simple API, which doesn't
support stream corking.

> 2.  I only have a couple of sounds.  Ideally I would much prefer to
> upload my sounds as samples, but my sounds need to be looped if
> possible.  I don't think a sample cache will work for me because I
> don't see the ability to set a callback to let me know when a sample
> cache is done playing so that I can tell it to restart.  Please let
> me know if there is a way?

You can monitor what sink inputs exist in the system. When you play a
sample, a new sink input is created for it, and you can detect when it
goes away. If the sample looping must have no gap, however then any
kind of manual restarting won't work, because there will necessarily be
a gap in the audio between the previous sample ending, your application
getting a notification about that, and sending a command to play the
sample again.

-- 
Tanu


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

  Powered by Linux