Avoid opening libsndfile sources in RDWR mode (doesn't work with FLAC)
This commit is contained in:
parent
7980d4b147
commit
d426aac08d
|
@ -69,6 +69,7 @@ Audio_File_SF::from_file ( const char *filename )
|
|||
|
||||
c = new Audio_File_SF;
|
||||
|
||||
c->_peak_writer = NULL;
|
||||
c->_current_read = 0;
|
||||
c->_filename = strdup( filename );
|
||||
c->_length = si.frames;
|
||||
|
@ -124,7 +125,7 @@ Audio_File_SF::create ( const char *filename, nframes_t samplerate, int channels
|
|||
c->_in = out;
|
||||
|
||||
/* FIXME: 256 ? */
|
||||
c->_peak_writer = new Peak_Writer( filename, 256, channels );
|
||||
c->_peak_writer = new Peak_Writer( name, 256, channels );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -893,10 +893,6 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co
|
|||
|
||||
/* now that we know how much and where to read, get on with it */
|
||||
|
||||
/* FIXME: seeking can be very expensive. Esp. with compressed
|
||||
* formats. We should attempt to avoid it. But here or in the
|
||||
* Audio_File class? */
|
||||
|
||||
// printf( "reading region ofs = %lu, sofs = %lu, %lu-%lu\n", ofs, sofs, start, end );
|
||||
|
||||
cnt = _clip->read( buf + ofs, channel, start, end );
|
||||
|
@ -947,19 +943,23 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co
|
|||
/** write /nframes/ from /buf/ to source. /buf/ is interleaved and
|
||||
must match the channel layout of the write source! */
|
||||
nframes_t
|
||||
Region::write ( sample_t *buf, nframes_t nframes )
|
||||
Region::write ( nframes_t nframes )
|
||||
{
|
||||
nframes_t l = _clip->write( buf, nframes );
|
||||
|
||||
_range.end += l;
|
||||
_range.end += nframes;
|
||||
|
||||
/* FIXME: too much? */
|
||||
// _track->damage( FL_DAMAGE_EXPOSE, x() + w(), y(), 10/* FIXME: guess */, h() );
|
||||
|
||||
if ( 0 == ( timeline->ts_to_x( _range.end ) % 20 ) )
|
||||
redraw();
|
||||
{
|
||||
/* FIXME: hack to get new size */
|
||||
_clip->close();
|
||||
_clip->open();
|
||||
|
||||
return l;
|
||||
redraw();
|
||||
}
|
||||
|
||||
return nframes;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ public:
|
|||
|
||||
/* Engine */
|
||||
nframes_t read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) const;
|
||||
nframes_t write ( sample_t *buf, nframes_t nframes );
|
||||
nframes_t write ( nframes_t nframes );
|
||||
void prepare ( void );
|
||||
bool finalize ( void );
|
||||
|
||||
|
|
|
@ -643,8 +643,16 @@ Track::record ( nframes_t frame )
|
|||
|
||||
snprintf( pat, sizeof( pat ), "%s-%llu", name(), uuid() );
|
||||
|
||||
/* FIXME: hack */
|
||||
Audio_File *af = Audio_File_SF::create( pat, 48000, input.size(), Track::capture_format );
|
||||
_capture_af = Audio_File_SF::create( pat, 48000, input.size(), Track::capture_format );
|
||||
|
||||
if ( ! _capture_af )
|
||||
{
|
||||
/* ERROR */
|
||||
|
||||
}
|
||||
|
||||
/* open it again for reading in the GUI thread */
|
||||
Audio_File *af = Audio_File::from_file( _capture_af->name() );
|
||||
|
||||
_capture = new Region( af, track(), frame );
|
||||
|
||||
|
@ -656,7 +664,9 @@ Track::record ( nframes_t frame )
|
|||
void
|
||||
Track::write ( sample_t *buf, nframes_t nframes )
|
||||
{
|
||||
_capture->write( buf, nframes );
|
||||
nframes_t l = _capture_af->write( buf, nframes );
|
||||
|
||||
_capture->write( l );
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -45,6 +45,7 @@ class Playback_DS;
|
|||
class Record_DS;
|
||||
class Port;
|
||||
class Region;
|
||||
class Audio_File;
|
||||
|
||||
class Track : public Fl_Group, public Loggable
|
||||
{
|
||||
|
@ -75,6 +76,7 @@ private:
|
|||
Sequence *_track;
|
||||
|
||||
Region *_capture; /* capture region */
|
||||
Audio_File *_capture_af; /* capture write source */
|
||||
|
||||
bool configure_outputs ( int n );
|
||||
bool configure_inputs ( int n );
|
||||
|
|
Loading…
Reference in New Issue