fixed OSS and SDL
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@428 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
||||
2006-11-15 Javier Serrano Polo <jasp00/at/terra/dot/es>
|
||||
|
||||
* include/audio_alsa.h:
|
||||
* src/audio/audio_alsa.cpp:
|
||||
* src/audio/audio_device.cpp:
|
||||
* src/audio/audio_file_wave.cpp:
|
||||
convert-endian-based conversion instead of little-endian-based,
|
||||
fixes OSS and SDL
|
||||
|
||||
* include/audio_sdl.h:
|
||||
* src/audio/audio_sdl.cpp:
|
||||
fill the whole audio buffer
|
||||
|
||||
2006-11-11 Javier Serrano Polo <jasp00/at/terra/dot/es>
|
||||
|
||||
* src/core/piano_roll.cpp:
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT(lmms, 0.2.1-svn20061111, lmms-devel/at/lists/dot/sf/dot/net)
|
||||
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20061111)
|
||||
AC_INIT(lmms, 0.2.1-svn20061115, lmms-devel/at/lists/dot/sf/dot/net)
|
||||
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20061115)
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
snd_pcm_hw_params_t * m_hwParams;
|
||||
snd_pcm_sw_params_t * m_swParams;
|
||||
|
||||
bool m_littleEndian;
|
||||
bool m_convertEndian;
|
||||
volatile bool m_quit;
|
||||
|
||||
} ;
|
||||
|
||||
@@ -80,10 +80,14 @@ private:
|
||||
virtual void stopProcessing( void );
|
||||
|
||||
static void sdlAudioCallback( void * _udata, Uint8 * _buf, int _len );
|
||||
void sdlAudioCallback( Uint8 * _buf, int _len );
|
||||
|
||||
SDL_AudioSpec m_audioHandle;
|
||||
|
||||
surroundSampleFrame * m_outBuf;
|
||||
Uint8 * m_convertedBuf;
|
||||
int m_convertedBuf_pos;
|
||||
int m_convertedBuf_size;
|
||||
|
||||
bool m_convertEndian;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful,
|
||||
m_handle( NULL ),
|
||||
m_hwParams( NULL ),
|
||||
m_swParams( NULL ),
|
||||
m_littleEndian( isLittleEndian() ),
|
||||
m_convertEndian( FALSE ),
|
||||
m_quit( FALSE )
|
||||
{
|
||||
_success_ful = FALSE;
|
||||
@@ -228,7 +228,7 @@ void audioALSA::run( void )
|
||||
const f_cnt_t frames = getNextBuffer( temp );
|
||||
|
||||
convertToS16( temp, frames, getMixer()->masterGain(), outbuf,
|
||||
m_littleEndian );
|
||||
m_convertEndian );
|
||||
|
||||
f_cnt_t frame = 0;
|
||||
int_sample_t * ptr = outbuf;
|
||||
@@ -298,7 +298,11 @@ int audioALSA::setHWParams( const sample_rate_t _sample_rate,
|
||||
"playback: %s\n", snd_strerror( err ) );
|
||||
return( err );
|
||||
}
|
||||
m_littleEndian = FALSE;
|
||||
m_convertEndian = isLittleEndian();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_convertEndian = !isLittleEndian();
|
||||
}
|
||||
|
||||
// set the count of channels
|
||||
|
||||
@@ -297,23 +297,9 @@ Uint32 FASTCALL audioDevice::convertToS16( const surroundSampleFrame * _ab,
|
||||
const fpab_t _frames,
|
||||
const float _master_gain,
|
||||
int_sample_t * _output_buffer,
|
||||
const bool _little_endian )
|
||||
const bool _convert_endian )
|
||||
{
|
||||
if( _little_endian )
|
||||
{
|
||||
for( fpab_t frame = 0; frame < _frames; ++frame )
|
||||
{
|
||||
for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl )
|
||||
{
|
||||
( _output_buffer + frame * channels() )[chnl] =
|
||||
static_cast<int_sample_t>(
|
||||
mixer::clip( _ab[frame][chnl] *
|
||||
_master_gain ) *
|
||||
OUTPUT_SAMPLE_MULTIPLIER );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if( _convert_endian )
|
||||
{
|
||||
Uint16 temp;
|
||||
for( fpab_t frame = 0; frame < _frames; ++frame )
|
||||
@@ -331,6 +317,20 @@ Uint32 FASTCALL audioDevice::convertToS16( const surroundSampleFrame * _ab,
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( fpab_t frame = 0; frame < _frames; ++frame )
|
||||
{
|
||||
for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl )
|
||||
{
|
||||
( _output_buffer + frame * channels() )[chnl] =
|
||||
static_cast<int_sample_t>(
|
||||
mixer::clip( _ab[frame][chnl] *
|
||||
_master_gain ) *
|
||||
OUTPUT_SAMPLE_MULTIPLIER );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return( _frames * channels() * BYTES_PER_INT_SAMPLE );
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void FASTCALL audioFileWave::writeBuffer( const surroundSampleFrame * _ab,
|
||||
int_sample_t * outbuf = bufferAllocator::alloc<int_sample_t>(
|
||||
_frames * channels() );
|
||||
Uint32 bytes = convertToS16( _ab, _frames, _master_gain, outbuf,
|
||||
TRUE );
|
||||
!isLittleEndian() );
|
||||
writeData( outbuf, bytes );
|
||||
|
||||
bufferAllocator::free( outbuf );
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "debug.h"
|
||||
#include "config_mgr.h"
|
||||
#include "gui_templates.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
|
||||
@@ -55,10 +56,16 @@ audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful,
|
||||
audioDevice( _sample_rate, DEFAULT_CHANNELS, _mixer ),
|
||||
m_outBuf( bufferAllocator::alloc<surroundSampleFrame>(
|
||||
getMixer()->framesPerAudioBuffer() ) ),
|
||||
m_convertedBuf_pos( 0 ),
|
||||
m_convertEndian( FALSE )
|
||||
{
|
||||
_success_ful = FALSE;
|
||||
|
||||
m_convertedBuf_size = getMixer()->framesPerAudioBuffer() * channels()
|
||||
* sizeof( int_sample_t );
|
||||
m_convertedBuf = (Uint8 *)bufferAllocator::allocBytes(
|
||||
m_convertedBuf_size );
|
||||
|
||||
/* // if device is set, we set AUDIODEV-environment-variable, so that
|
||||
// SDL can evaluate and use it
|
||||
QString dev = configManager::inst()->value( "audiosdl", "device" );
|
||||
@@ -110,6 +117,7 @@ audioSDL::~audioSDL()
|
||||
stopProcessing();
|
||||
SDL_CloseAudio();
|
||||
SDL_Quit();
|
||||
bufferAllocator::free( m_convertedBuf );
|
||||
bufferAllocator::free( m_outBuf );
|
||||
}
|
||||
|
||||
@@ -145,12 +153,33 @@ void audioSDL::sdlAudioCallback( void * _udata, Uint8 * _buf, int _len )
|
||||
assert( _this != NULL );
|
||||
#endif
|
||||
|
||||
const fpab_t frames = _this->getNextBuffer( _this->m_outBuf );
|
||||
_this->sdlAudioCallback( _buf, _len );
|
||||
}
|
||||
|
||||
_this->convertToS16( _this->m_outBuf, frames,
|
||||
_this->getMixer()->masterGain(),
|
||||
(int_sample_t *)( _buf ),
|
||||
_this->m_convertEndian );
|
||||
|
||||
|
||||
|
||||
void audioSDL::sdlAudioCallback( Uint8 * _buf, int _len )
|
||||
{
|
||||
while( _len )
|
||||
{
|
||||
if( m_convertedBuf_pos == 0 )
|
||||
{
|
||||
const fpab_t frames = getNextBuffer( m_outBuf );
|
||||
|
||||
convertToS16( m_outBuf, frames,
|
||||
getMixer()->masterGain(),
|
||||
(int_sample_t *)m_convertedBuf,
|
||||
m_convertEndian );
|
||||
}
|
||||
int min_len = tMin( _len, m_convertedBuf_size
|
||||
- m_convertedBuf_pos );
|
||||
memcpy( _buf, m_convertedBuf + m_convertedBuf_pos, min_len );
|
||||
_buf += min_len;
|
||||
_len -= min_len;
|
||||
m_convertedBuf_pos += min_len;
|
||||
m_convertedBuf_pos %= m_convertedBuf_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user