Fix a number of errors turned up by valgrind. Import new captures.

This commit is contained in:
Jonathan Moore Liles 2008-04-16 13:08:00 -05:00
parent 4684094f6f
commit 72a203d18b
8 changed files with 38 additions and 22 deletions

View File

@ -22,6 +22,11 @@
map <string, Audio_File*> Audio_File::_open_files;
Audio_File::~Audio_File ( )
{
_open_files[ string( _filename ) ] = NULL;
}
/** attmpet to open any supported filetype */
Audio_File *
Audio_File::from_file ( const char * filename )

View File

@ -53,9 +53,7 @@ public:
_length = _channels = 0;
}
virtual ~Audio_File ( )
{
}
virtual ~Audio_File ( );
static Audio_File *from_file ( const char *filename );

View File

@ -163,7 +163,7 @@ Audio_File_SF::read ( sample_t *buf, int channel, nframes_t len )
for ( int i = channel; i < rlen * _channels; i += _channels )
*(buf++) = tmp[ i ];
delete tmp;
delete[] tmp;
}
_current_read += rlen;
@ -177,13 +177,13 @@ Audio_File_SF::read ( sample_t *buf, int channel, nframes_t start, nframes_t end
{
assert( end > start );
open();
// open();
seek( start );
nframes_t len = read( buf, channel, end - start );
close();
// close();
return len;
}

View File

@ -90,7 +90,7 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize
}
/* get chunk size of peak file */
int pfchunksize;
int pfchunksize = 0;
fread( &pfchunksize, sizeof( int ), 1, fp );
int channels = _clip->channels();
@ -108,8 +108,7 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize
/* locate to start position */
fseek( fp, (s * channels / pfchunksize) * sizeof( Peak ), SEEK_CUR );
size_t len;
size_t len = 0;
int i;
for ( i = 0; i < npeaks; ++i )
@ -195,12 +194,12 @@ Peaks::read_source_peaks ( Peak *peaks, int npeaks, int chunksize ) const
int
Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const
{
_clip->open();
// _clip->open();
_clip->seek( s );
int i = read_source_peaks( peaks, npeaks, chunksize );
_clip->close();
// _clip->close();
return i;
}
@ -318,14 +317,16 @@ Peaks::make_peaks ( int chunksize )
if ( current() )
return true;
if ( ! _clip->open() )
return false;
_clip->seek( 0 );
/* if ( ! _clip->open() ) */
/* return false; */
FILE *fp = fopen( peakname( filename ), "w" );
if ( fp == NULL )
{
_clip->close();
// _clip->close();
return false;
}
@ -343,7 +344,7 @@ Peaks::make_peaks ( int chunksize )
}
while ( len );
_clip->close();
// _clip->close();
fclose( fp );

View File

@ -165,9 +165,20 @@ Record_DS::stop ( nframes_t frame )
shutdown();
/* FIXME: flush buffers here? */
char *name = strdup( _af->name() );
delete _af;
_af = NULL;
Audio_File *af = Audio_File::from_file( name );
if ( ! af )
printf( "impossible!\n" );
new Region( af, track(), _frame );
track()->redraw();
_recording = false;
printf( "recording finished\n" );

View File

@ -144,6 +144,9 @@ Region::Region ( Audio_File *c, Track *t, nframes_t o )
int sum = 0;
const char *s = rindex( _clip->name(), '/' );
if ( ! s )
s = _clip->name();
for ( int i = strlen( s ); i--; )
sum += s[ i ];
@ -714,6 +717,8 @@ Region::Fade::apply ( sample_t *buf, Region::Fade::fade_dir_e dir, long start, n
nframes_t n = e - i;
assert( i + n <= nframes );
if ( dir == Fade::Out )
{
fi = 1.0f - fi;

View File

@ -60,7 +60,7 @@ Waveform::draw ( int X, int Y, int W, int H,
if ( Waveform::fill )
{
j = start;
for ( int x = X; x <= X + W; ++x, ++j )
for ( int x = X; x < X + W; ++x, ++j )
{
const Peak p = pbuf[ j ];
@ -104,7 +104,7 @@ Waveform::draw ( int X, int Y, int W, int H,
fl_begin_line();
j = start;
for ( int x = X; x <= X + W; ++x, ++j )
for ( int x = X; x < X + W; ++x, ++j )
{
const Peak p = pbuf[ j ];
@ -116,7 +116,7 @@ Waveform::draw ( int X, int Y, int W, int H,
fl_begin_line();
j = start;
for ( int x = X; x <= X + W; ++x, ++j )
for ( int x = X; x < X + W; ++x, ++j )
{
const Peak p = pbuf[ j ];

View File

@ -55,8 +55,6 @@ buffer_mix_with_gain ( sample_t *dst, sample_t *src, nframes_t nframes, float g
void
buffer_interleave_one_channel ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes )
{
nframes *= channels;
dst += channel;
while ( nframes-- )
@ -69,8 +67,6 @@ buffer_interleave_one_channel ( sample_t *dst, sample_t *src, int channel, int c
void
buffer_interleave_one_channel_and_mix ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes )
{
nframes *= channels;
dst += channel;
while ( nframes-- )