mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 02:57:35 -05:00
Issue #47 - work in progress
This commit is contained in:
@@ -186,11 +186,40 @@ public class MonoAudioOutput extends AudioOutput
|
|||||||
{
|
{
|
||||||
shortBuffer.put( (short)( sample * Short.MAX_VALUE ) );
|
shortBuffer.put( (short)( sample * Short.MAX_VALUE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutput.write( buffer.array(), 0,
|
if( mOutput.available() >= buffer.array().length )
|
||||||
buffer.array().length );
|
{
|
||||||
|
mOutput.write( buffer.array(), 0,
|
||||||
checkStart();
|
buffer.array().length );
|
||||||
|
|
||||||
|
checkStart();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int wrote = 0;
|
||||||
|
|
||||||
|
int toWrite = buffer.array().length;
|
||||||
|
|
||||||
|
while( toWrite > 0 )
|
||||||
|
{
|
||||||
|
int available = mOutput.available();
|
||||||
|
|
||||||
|
if( available < toWrite )
|
||||||
|
{
|
||||||
|
wrote += mOutput.write( buffer.array(), wrote,
|
||||||
|
available );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wrote += mOutput.write( buffer.array(), wrote,
|
||||||
|
toWrite );
|
||||||
|
}
|
||||||
|
|
||||||
|
checkStart();
|
||||||
|
|
||||||
|
toWrite = buffer.array().length - wrote;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
broadcast( packet.getAudioMetadata() );
|
broadcast( packet.getAudioMetadata() );
|
||||||
|
|
||||||
|
|||||||
@@ -141,9 +141,8 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
private ByteBuffer convert( float[] samples )
|
private ByteBuffer convert( float[] samples )
|
||||||
{
|
{
|
||||||
/* Little-endian byte buffer */
|
/* Little-endian byte buffer */
|
||||||
ByteBuffer buffer =
|
ByteBuffer buffer = ByteBuffer.allocate( samples.length * 4 )
|
||||||
ByteBuffer.allocate( samples.length * 4 )
|
.order( ByteOrder.LITTLE_ENDIAN );
|
||||||
.order( ByteOrder.LITTLE_ENDIAN );
|
|
||||||
|
|
||||||
ShortBuffer shortBuffer = buffer.asShortBuffer();
|
ShortBuffer shortBuffer = buffer.asShortBuffer();
|
||||||
|
|
||||||
@@ -203,10 +202,39 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
ByteBuffer buffer = convert(
|
ByteBuffer buffer = convert(
|
||||||
packet.getAudioBuffer().getSamples() );
|
packet.getAudioBuffer().getSamples() );
|
||||||
|
|
||||||
mOutput.write( buffer.array(), 0,
|
if( mOutput.available() >= buffer.array().length )
|
||||||
buffer.array().length );
|
{
|
||||||
|
mOutput.write( buffer.array(), 0,
|
||||||
checkStart();
|
buffer.array().length );
|
||||||
|
|
||||||
|
checkStart();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int wrote = 0;
|
||||||
|
|
||||||
|
int toWrite = buffer.array().length;
|
||||||
|
|
||||||
|
while( toWrite > 0 )
|
||||||
|
{
|
||||||
|
int available = mOutput.available();
|
||||||
|
|
||||||
|
if( available < toWrite )
|
||||||
|
{
|
||||||
|
wrote += mOutput.write( buffer.array(), wrote,
|
||||||
|
available );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wrote += mOutput.write( buffer.array(), wrote,
|
||||||
|
toWrite );
|
||||||
|
}
|
||||||
|
|
||||||
|
checkStart();
|
||||||
|
|
||||||
|
toWrite = buffer.array().length - wrote;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
broadcast( packet.getAudioMetadata() );
|
broadcast( packet.getAudioMetadata() );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user