convert soft tabs to hard tabs and add a modeline

This commit is contained in:
Andrew Kelley committed 2009-07-16 03:30:31 -07:00
1 parent 2009d71015
commit c7205351c2
6 files changed
+462 -452

No files matched your search

+111 -109
View File
@@ -194,22 +194,22 @@ void sampleBuffer::update( bool _keep_settings )
"than 100 MB" );
}
else
{
// PCM wave
if( m_frames == 0 )
m_frames = decodeSampleSF( f, buf, channels, samplerate );
{
// PCM wave
if( m_frames == 0 )
m_frames = decodeSampleSF( f, buf, channels, samplerate );
#ifdef LMMS_HAVE_OGGVORBIS
if( m_frames == 0 )
m_frames = decodeSampleOGGVorbis(f, buf, channels, samplerate);
if( m_frames == 0 )
m_frames = decodeSampleOGGVorbis(f, buf, channels, samplerate);
#endif
if( m_frames == 0 )
m_frames = decodeSampleDS( f, buf, channels, samplerate );
if( m_frames == 0 )
m_frames = decodeSampleDS( f, buf, channels, samplerate );
// MP3
if( m_frames == 0 )
m_frames = decodeSampleMp3( file, buf, channels, samplerate );
// MP3
if( m_frames == 0 )
m_frames = decodeSampleMp3( file, buf, channels, samplerate );
delete[] f;
delete[] f;
}
if( m_frames > 0 && buf != NULL )
@@ -260,15 +260,15 @@ void sampleBuffer::update( bool _keep_settings )
m_loopStartFrame = m_startFrame = 0;
m_loopEndFrame = m_endFrame = 1;
QString decoders = tr( "wav, ogg, mp3" );
QMessageBox::information( NULL,
QObject::tr( "Unrecognized audio format" ),
QObject::tr( "None of the available audio decoders "
"recognized the format you are trying to load. Try "
"converting the file to a format LMMS understands.\n\n"
"Your file: %1\n"
"Available decoders: %2\n").arg( file, decoders ),
QMessageBox::Ok | QMessageBox::Default );
QString decoders = tr( "wav, ogg, mp3" );
QMessageBox::information( NULL,
QObject::tr( "Unrecognized audio format" ),
QObject::tr( "None of the available audio decoders "
"recognized the format you are trying to load. Try "
"converting the file to a format LMMS understands.\n\n"
"Your file: %1\n"
"Available decoders: %2\n").arg( file, decoders ),
QMessageBox::Ok | QMessageBox::Default );
}
}
@@ -500,112 +500,112 @@ f_cnt_t sampleBuffer::decodeSampleOGGVorbis( const char * _f,
int lame_decode_fromfile(QFile &in, short pcm_l[], short pcm_r[],
mp3data_struct * mp3data, LameLibrary &lame)
mp3data_struct * mp3data, LameLibrary &lame)
{
int ret = 0;
size_t len = 0;
unsigned char buf[1024];
int ret = 0;
size_t len = 0;
unsigned char buf[1024];
/* first see if we still have data buffered in the decoder: */
ret = lame.lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
if (ret != 0)
return ret;
/* first see if we still have data buffered in the decoder: */
ret = lame.lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
if (ret != 0)
return ret;
/* read until we get a valid output frame */
while (1) {
len = in.read((char *)buf, 1024);
if (len == 0) {
/* we are done reading the file, but check for buffered data */
ret = lame.lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
if (ret <= 0) {
//lame.lame_decode_exit(); /* release mp3decoder memory */
//return -1; /* done with file */
/* read until we get a valid output frame */
while (1) {
len = in.read((char *)buf, 1024);
if (len == 0) {
/* we are done reading the file, but check for buffered data */
ret = lame.lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
if (ret <= 0) {
//lame.lame_decode_exit(); /* release mp3decoder memory */
//return -1; /* done with file */
return 0;
}
break;
}
return 0;
}
break;
}
ret = lame.lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
if (ret == -1) {
lame.lame_decode_exit(); /* release mp3decoder memory */
return -1;
}
if (ret > 0)
break;
}
return ret;
ret = lame.lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
if (ret == -1) {
lame.lame_decode_exit(); /* release mp3decoder memory */
return -1;
}
if (ret > 0)
break;
}
return ret;
}
f_cnt_t sampleBuffer::decodeSampleMp3( QString & file, int_sample_t * & _buf,
ch_cnt_t & _channels, sample_rate_t & _samplerate )
ch_cnt_t & _channels, sample_rate_t & _samplerate )
{
// create instance of LameLibrary to decode
LameLibrary lame;
// open the file
QFile in(file);
// create instance of LameLibrary to decode
LameLibrary lame;
// open the file
QFile in(file);
if( ! in.open(QIODevice::ReadOnly) ){
printf("sampleBuffer::decodeSampleMp3: error opening %s for reading\n",
file.toStdString().c_str());
return 0;
}
if( ! in.open(QIODevice::ReadOnly) ){
printf("sampleBuffer::decodeSampleMp3: error opening %s for reading\n",
file.toStdString().c_str());
return 0;
}
// initialize lame decoder
lame.lame_decode_init();
// initialize lame decoder
lame.lame_decode_init();
short int pcm_l[1152];
short int pcm_r[1152];
mp3data_struct mp3data;
short int pcm_l[1152];
short int pcm_r[1152];
mp3data_struct mp3data;
// TODO: calc _buf size
// TODO: calc _buf size
int bufPos = 0;
bool initBuf = false;
int bufPos = 0;
bool initBuf = false;
while(1)
{
int ret = lame_decode_fromfile(in, pcm_l, pcm_r, &mp3data, lame);
if( ret == -1 ){
delete[] _buf;
printf("error decoding mp3\n");
return 0;
} else if( ret == 0 ) {
break;
}
while(1)
{
int ret = lame_decode_fromfile(in, pcm_l, pcm_r, &mp3data, lame);
if( ret == -1 ){
delete[] _buf;
printf("error decoding mp3\n");
return 0;
} else if( ret == 0 ) {
break;
}
if( ! initBuf )
{
if( mp3data.header_parsed == 0 )
{
printf("failed to parse header\n");
return 0;
}
else
{
// process header
_samplerate = mp3data.samplerate;
_channels = mp3data.stereo;
_buf = new int_sample_t[mp3data.totalframes *
mp3data.framesize * _channels];
initBuf = true;
}
}
if( ! initBuf )
{
if( mp3data.header_parsed == 0 )
{
printf("failed to parse header\n");
return 0;
}
else
{
// process header
_samplerate = mp3data.samplerate;
_channels = mp3data.stereo;
_buf = new int_sample_t[mp3data.totalframes *
mp3data.framesize * _channels];
initBuf = true;
}
}
// convert the decoded PCM into sample
for(int i = 0; i<ret; ++i)
{
_buf[bufPos++] = pcm_l[i];
if( _channels == 2 )
_buf[bufPos++] = pcm_r[i];
}
}
lame.lame_decode_exit();
// convert the decoded PCM into sample
for(int i = 0; i<ret; ++i)
{
_buf[bufPos++] = pcm_l[i];
if( _channels == 2 )
_buf[bufPos++] = pcm_r[i];
}
}
lame.lame_decode_exit();
return bufPos / _channels;
}
@@ -1327,3 +1327,5 @@ sampleBuffer::handleState::~handleState()
#endif
/* vim: set tw=0 expandtab: */