Browse Source

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

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
72a203d18b
8 changed files with 38 additions and 22 deletions
  1. +5
    -0
      Timeline/Audio_File.C
  2. +1
    -3
      Timeline/Audio_File.H
  3. +3
    -3
      Timeline/Audio_File_SF.C
  4. +10
    -9
      Timeline/Peaks.C
  5. +11
    -0
      Timeline/Record_DS.C
  6. +5
    -0
      Timeline/Region.C
  7. +3
    -3
      Timeline/Waveform.C
  8. +0
    -4
      Timeline/dsp.C

+ 5
- 0
Timeline/Audio_File.C 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 )


+ 1
- 3
Timeline/Audio_File.H View File

@@ -53,9 +53,7 @@ public:
_length = _channels = 0;
}

virtual ~Audio_File ( )
{
}
virtual ~Audio_File ( );

static Audio_File *from_file ( const char *filename );



+ 3
- 3
Timeline/Audio_File_SF.C 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;
}


+ 10
- 9
Timeline/Peaks.C 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 );



+ 11
- 0
Timeline/Record_DS.C 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" );


+ 5
- 0
Timeline/Region.C 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;


+ 3
- 3
Timeline/Waveform.C 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 ];



+ 0
- 4
Timeline/dsp.C 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-- )


Loading…
Cancel
Save