<Sound Dev> SourceDataLine behavior on Linux and Windows

View: New views
2 Messages — Rating Filter:   Alert me  

<Sound Dev> SourceDataLine behavior on Linux and Windows

by Bugzilla from cy6erGn0m@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

DataLine has a different behavior on Linux and Windows. I do not know, it it a bug or feature... may be documentation is not a full?

So, steps to reproduce:
1. Create and open data line and start() on it.
2. Write data to line in a separate thread.
3. Stop line with a stop() method but do not stop thread from (2).

On Windows:
Thread that writes data to data line will fill line's buffer and then blocks (sleeps) when buffer reaches full.

On Linux:
Thread that writes data to line will spin around method write and eat CPU, because stopped line can't be written and write method returns 0  (no bytes written). This happens before line's buffer reaches full (available() > 0).

Of course workaround present, but this behavior looks strange...

Re: <Sound Dev> SourceDataLine behavior on Linux and Windows

by i30817 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you trying to make a pause() method in a streaming audioplayer
implementation? If you are can you tell any pointers to do it. In fact
 can AudioInputStream do it? The documentation implies that mark can
work.

On Thu, Oct 15, 2009 at 11:18 PM, cyberGn0m <cy6ergn0m@...> wrote:

> DataLine has a different behavior on Linux and Windows. I do not know, it it
> a bug or feature... may be documentation is not a full?
>
> So, steps to reproduce:
> 1. Create and open data line and start() on it.
> 2. Write data to line in a separate thread.
> 3. Stop line with a stop() method but do not stop thread from (2).
>
> On Windows:
> Thread that writes data to data line will fill line's buffer and then blocks
> (sleeps) when buffer reaches full.
>
> On Linux:
> Thread that writes data to line will spin around method write and eat CPU,
> because stopped line can't be written and write method returns 0  (no bytes
> written). This happens before line's buffer reaches full (available() > 0).
>
> Of course workaround present, but this behavior looks strange...
>