fixes for libsndfile conversion issues, tape track waveform display and overloaded virtual functions

git-svn-id: svn://localhost/ardour2/trunk@624 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2006-06-20 18:50:38 +00:00
parent c03dbd7568
commit be362ae53c
34 changed files with 117 additions and 137 deletions

View file

@ -408,10 +408,6 @@ libraries['pbd3'] = LibraryInfo (LIBS='pbd', LIBPATH='#libs/pbd3', CPPPATH='#
libraries['gtkmm2ext'] = LibraryInfo (LIBS='gtkmm2ext', LIBPATH='#libs/gtkmm2ext', CPPPATH='#libs/gtkmm2ext')
#libraries['cassowary'] = LibraryInfo(LIBS='cassowary', LIBPATH='#libs/cassowary', CPPPATH='#libs/cassowary')
libraries['fst'] = LibraryInfo()
if env['VST']:
libraries['fst'].ParseConfig('pkg-config --cflags --libs libfst')
#
# Check for libusb
@ -532,6 +528,9 @@ if env['SYSLIBS']:
'libs/ardour'
]
if env['VST']:
subdirs = ['libs/fst'] + subdirs + ['vst']
gtk_subdirs = [
# 'libs/flowcanvas',
'libs/gtkmm2ext',
@ -585,6 +584,9 @@ else:
'libs/ardour'
]
if env['VST']:
subdirs = ['libs/fst'] + subdirs + ['vst']
gtk_subdirs = [
'libs/glibmm2',
'libs/gtkmm2/pango',
@ -787,10 +789,11 @@ if env['DEBUG'] == 1:
else:
env.Append(CCFLAGS=" ".join (opt_flags))
env.Append(CCFLAGS="-Wall")
#
# warnings flags
#
if env['VST']:
env.Append(CCFLAGS="-DVST_SUPPORT")
env.Append(CCFLAGS="-Wall -Woverloaded-virtual")
if env['LIBLO']:
env.Append(CCFLAGS="-DHAVE_LIBLO")

View file

@ -58,9 +58,6 @@ if gtkardour['FFT_ANALYSIS']:
gtkardour.Merge ([libraries['fftw3f']])
gtkardour.Append(CCFLAGS='-DFFT_ANALYSIS')
if gtkardour['VST']:
gtkardour.Merge ([ libraries['fst']])
skipped_files=Split("""
connection_editor.cc
""")
@ -203,15 +200,16 @@ itest.cc
""")
extra_sources = []
vst_files = [ 'vst_pluginui.cc' ]
if env['VST']:
extra_sources += vst_files
extra_sources += vst_files
gtkardour.Append (CCFLAGS="-DVST_SUPPORT", CPPPATH="#libs/fst")
if env['FFT_ANALYSIS']:
extra_sources += fft_analysis_files
intl_files += extra_sources
gtkardour.Append(CCFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
@ -226,6 +224,8 @@ gtkardour.VersionBuild(['version.cc','version.h'], 'SConscript')
executable = 'ardour.bin'
ardour = gtkardour.Program(target = executable, source = gtkardour_files + extra_sources)
ardourlib = gtkardour.SharedLibrary(target = 'ardourgtk', source = gtkardour_files + extra_sources)
mtest = gtkardour.Program(target = 'mtest', source = mtest_files)
itest = gtkardour.Program(target = 'itest', source = itest_files)
@ -235,21 +235,28 @@ my_subst_dict['%INSTALL_PREFIX%'] = install_prefix
ardoursh = env.SubstInFile ('ardour.sh','ardour.sh.in', SUBST_DICT = my_subst_dict);
env.AddPostAction (ardoursh, Chmod ('$TARGET', 0755))
Default(ardour)
if env['VST']:
Default(ardourlib)
# the library - into the library dir
env.Alias('install', env.Install(os.path.join(install_prefix, 'lib/ardour2'), ardourlib))
else:
if env['VERSIONED']:
Default (env.VersionedExecutable ('tagged_executable', ardour))
if env['VERSIONED']:
Default (env.VersionedExecutable ('tagged_executable', ardour))
else:
Default(ardour)
#install
# the executable - into the library dir
env.Alias('install', env.Install(os.path.join(install_prefix, 'lib/ardour2'), ardour))
# the script - into the bin dir
env.Alias('install', env.InstallAs(os.path.join(install_prefix, 'bin')+'/ardour2', ardoursh))
if env['NLS']:
Export('gtkardour', 'intl_files')
SConscript ('po/SConscript')
Export('gtkardour', 'intl_files')
SConscript ('po/SConscript')
#install
# the executable - into the library dir
env.Alias('install', env.Install(os.path.join(install_prefix, 'lib/ardour2'), ardour))
# the script - into the bin dir
env.Alias('install', env.InstallAs(os.path.join(install_prefix, 'bin')+'/ardour2', ardoursh))
# configuration files
env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour2_ui.rc'))
env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour.menus'))
@ -259,6 +266,7 @@ env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour
env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour2'), 'splash.ppm'))
env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour2/pixmaps'), pixmap_files))
#dist
env.Alias ('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript',

View file

@ -28,6 +28,7 @@
#include <pbd/xml++.h>
#include "prompter.h"
#include "selectable.h"
namespace ARDOUR {
class Session;
@ -37,7 +38,7 @@ namespace ARDOUR {
* AxisView defines the abstract base class for time-axis trackviews and routes.
*
*/
class AxisView : public virtual sigc::trackable
class AxisView : public virtual Selectable
{
public:
/**
@ -51,12 +52,6 @@ class AxisView : public virtual sigc::trackable
virtual string name() const = 0;
virtual void set_selected (bool yn) {
if (yn != _selected) {
_selected = yn;
}
}
virtual bool marked_for_display() const { return _marked_for_display; }
virtual void set_marked_for_display (bool yn) {
@ -65,7 +60,6 @@ class AxisView : public virtual sigc::trackable
}
}
virtual bool selected() const { return _selected; }
sigc::signal<void> Hiding;
sigc::signal<void> GoingAway;

View file

@ -389,7 +389,11 @@ gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview, gulong start_
/* but make sure it doesn't extend beyond the end of the source material */
rf3 = (gulong) (waveview->sourcefile_length_function (waveview->data_src, waveview->samples_per_unit)) + 1;
rf3 -= new_cache_start;
if (rf3 < new_cache_start) {
rf3 = 0;
} else {
rf3 -= new_cache_start;
}
#if DEBUG_CACHE
fprintf (stderr, "\n\nAVAILABLE FRAMES = %lu of %lu, start = %lu, sstart = %lu, cstart = %lu\n",
@ -405,8 +409,8 @@ gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview, gulong start_
#if DEBUG_CACHE
fprintf (stderr, "new cache = %lu - %lu\n", new_cache_start, new_cache_end);
fprintf(stderr,"required_cach_entries = %lu, samples_per_unit = %f\n",
required_cache_entries,waveview->samples_per_unit);
fprintf(stderr,"required_cach_entries = %lu, samples_per_unit = %f req frames = %lu\n",
required_cache_entries,waveview->samples_per_unit, required_frames);
#endif
if (required_cache_entries > cache->allocated) {
@ -514,8 +518,8 @@ gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview, gulong start_
// fprintf(stderr,"length == %lu\n",waveview->length_function (waveview->data_src));
// required_frames = MIN (waveview->length_function (waveview->data_src) - new_cache_start, required_frames);
npeaks = (gulong) floor (required_frames / waveview->samples_per_unit);
npeaks = MAX (1, npeaks);
required_frames = npeaks * waveview->samples_per_unit;
#if DEBUG_CACHE
@ -532,11 +536,15 @@ gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview, gulong start_
// start_sample, end_sample);
#endif
waveview->peak_function (waveview->data_src, npeaks, new_cache_start, required_frames, cache->data + offset, waveview->channel,waveview->samples_per_unit);
if (required_frames) {
waveview->peak_function (waveview->data_src, npeaks, new_cache_start, required_frames, cache->data + offset, waveview->channel,waveview->samples_per_unit);
/* take into account any copied peaks */
/* take into account any copied peaks */
npeaks += copied;
npeaks += copied;
} else {
npeaks = copied;
}
if (npeaks < cache->allocated) {
#if DEBUG_CACHE

View file

@ -50,7 +50,7 @@ CrossfadeView::CrossfadeView (ArdourCanvas::Group *parent,
AudioRegionView& rview)
: TimeAxisViewItem ("xf.name()", *parent, tv, spu, basic_color, xf.position(),
: TimeAxisViewItem ("xfade" /*xf.name()*/, *parent, tv, spu, basic_color, xf.position(),
xf.overlap_length(), TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowFrame)),
crossfade (xf),
left_view (lview),
@ -91,13 +91,6 @@ CrossfadeView::~CrossfadeView ()
GoingAway (this) ; /* EMIT_SIGNAL */
}
std::string
CrossfadeView::get_item_name ()
{
return "xfade";
// return crossfade.name();
}
void
CrossfadeView::reset_width_dependent_items (double pixel_width)
{

View file

@ -46,7 +46,6 @@ struct CrossfadeView : public TimeAxisViewItem
AudioRegionView& left_view; // and these too
AudioRegionView& right_view;
std::string get_item_name();
void set_height (double);
bool valid() const { return _valid; }

View file

@ -195,7 +195,7 @@ Editor::set_mouse_mode (MouseMode m, bool force)
*/
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
if ((*i)->selected()) {
if ((*i)->get_selected()) {
(*i)->show_selection (selection->time);
}
}

View file

@ -1091,7 +1091,7 @@ ImageFrameSocketHandler::handle_item_selected(const char* msg)
}
else
{
ifv->set_selected(true, this) ;
ifv->set_selected(true) ;
ifta->get_view()->set_selected_imageframe_view(iftag, ifv) ;
thePublicEditor.scroll_timeaxis_to_imageframe_item(ifv) ;

View file

@ -365,11 +365,11 @@ ImageFrameTimeAxisView::set_selected_imageframe_view(ImageFrameTimeAxisGroup* if
if(selected_imageframe_view)
{
selected_imageframe_view->set_selected(false, this) ;
selected_imageframe_view->set_selected(false) ;
}
selected_imageframe_view = ifv ;
selected_imageframe_view->set_selected(true, this) ;
selected_imageframe_view->set_selected(true) ;
}
/**
@ -386,7 +386,7 @@ ImageFrameTimeAxisView::clear_selected_imageframe_item(bool clear_group)
if(selected_imageframe_view)
{
selected_imageframe_view->set_selected(false, this) ;
selected_imageframe_view->set_selected(false) ;
}
selected_imageframe_view = 0 ;
}

View file

@ -172,16 +172,15 @@ delete imageframe;
* @return true if the position change was a success, false otherwise
*/
bool
ImageFrameView::set_position(jack_nframes_t pos, void* src)
ImageFrameView::set_position(jack_nframes_t pos, void* src, double* delta)
{
jack_nframes_t old_pos = frame_position ;
// do the standard stuff
bool ret = TimeAxisViewItem::set_position(pos, src) ;
bool ret = TimeAxisViewItem::set_position(pos, src, delta) ;
// everything went ok with the standard stuff?
if(ret)
{
if (ret) {
/* move each of our associated markers with this ImageFrameView */
for (MarkerViewList::iterator i = marker_view_list.begin(); i != marker_view_list.end(); ++i)
{

View file

@ -91,7 +91,7 @@ class ImageFrameView : public TimeAxisViewItem
* @param src the identity of the object that initiated the change
* @return true if the position change was a success, false otherwise
*/
virtual bool set_position(jack_nframes_t pos, void* src) ;
virtual bool set_position(jack_nframes_t pos, void* src, double* delta = 0) ;
/**
* Sets the duration of this item

View file

@ -361,6 +361,7 @@ To create it from the command line, start ardour as \"ardour --new %1"), path)
return true;
}
int
main (int argc, char *argv[])
{

View file

@ -125,7 +125,6 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
output_button.set_name ("MixerIOButton");
output_label.set_name ("MixerIOButtonLabel");
_route.meter_change.connect (mem_fun(*this, &MixerStrip::meter_changed));
meter_point_button.add (meter_point_label);
meter_point_button.set_name ("MixerStripMeterPreButton");

View file

@ -127,7 +127,7 @@ Panner2d::reset (uint32_t n_inputs)
}
void
Panner2d::on_size_allocate (Gtk::Allocation alloc)
Panner2d::on_size_allocate (Gtk::Allocation& alloc)
{
width = alloc.get_width();
height = alloc.get_height();

View file

@ -78,7 +78,7 @@ class Panner2d : public Gtk::DrawingArea
bool on_button_press_event (GdkEventButton *);
bool on_button_release_event (GdkEventButton *);
bool on_motion_notify_event (GdkEventMotion *);
void on_size_allocate (Gtk::Allocation alloc);
void on_size_allocate (Gtk::Allocation& alloc);
private:
struct Target {

View file

@ -53,8 +53,6 @@ class RedirectAutomationLine : public AutomationLine
void view_to_model_y (double&);
void model_to_view_y (double&);
void change_model (uint32_t, double x, double y);
void change_model_range (uint32_t, uint32_t, double delta);
};
#endif /* __ardour_gtk_region_gain_line_h__ */

View file

@ -1234,12 +1234,6 @@ AudioRegionView::set_waveform_shape (WaveformShape shape)
}
}
std::string
AudioRegionView::get_item_name ()
{
return region.name();
}
void
AudioRegionView::move (double x_delta, double y_delta)
{

View file

@ -63,7 +63,6 @@ class AudioRegionView : public TimeAxisViewItem
bool is_valid() const { return valid; }
void set_valid (bool yn) { valid = yn; }
std::string get_item_name();
void set_height (double);
void set_samples_per_unit (double);
bool set_duration (jack_nframes_t, void*);

View file

@ -21,7 +21,9 @@
#ifndef __ardour_gtk_selectable_h__
#define __ardour_gtk_selectable_h__
class Selectable
#include <sigc++/signal.h>
class Selectable : public virtual sigc::trackable
{
public:
Selectable() {
@ -30,10 +32,20 @@ class Selectable
virtual ~Selectable() {}
virtual void set_selected (bool) {
_selected = true;
virtual void set_selected (bool yn) {
if (yn != _selected) {
_selected = true;
Selected (_selected); /* EMIT_SIGNAL */
}
}
bool get_selected() const {
return _selected;
}
/** Emitted when the selected status of this Selectable changes */
sigc::signal<void, bool> Selected ;
protected:
bool _selected;
};

View file

@ -548,7 +548,7 @@ StreamView::set_selected_regionviews (AudioRegionSelection& regions)
}
// cerr << "\tregion " << (*i)->region.name() << " selected = " << selected << endl;
(*i)->set_selected (selected, this);
(*i)->set_selected (selected);
}
}

View file

@ -484,26 +484,14 @@ TimeAxisViewItem::get_item_name() const
* @param src the identity of the object that initiated the change
*/
void
TimeAxisViewItem::set_selected(bool yn, void* src)
TimeAxisViewItem::set_selected(bool yn)
{
if (_selected != yn) {
_selected = yn ;
Selectable::set_selected (yn);
set_frame_color ();
Selected (_selected) ; /* EMIT_SIGNAL */
}
}
/**
* Returns whether this item is currently selected.
*
* @return true if this item is currently selected, false otherwise
*/
bool
TimeAxisViewItem::get_selected() const
{
return (_selected) ;
}
void
TimeAxisViewItem::set_should_show_selection (bool yn)
{

View file

@ -21,8 +21,6 @@
#ifndef __gtk_ardour_time_axis_view_item_h__
#define __gtk_ardour_time_axis_view_item_h__
#include <sigc++/signal.h>
#include <jack/jack.h>
#include <string>
@ -38,7 +36,7 @@ class TimeAxisView;
* A base class for 'items' that may appear upon a TimeAxisView
*
*/
class TimeAxisViewItem : public sigc::trackable, public Selectable
class TimeAxisViewItem : public Selectable
{
public:
virtual ~TimeAxisViewItem() ;
@ -170,9 +168,8 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable
* Set to true to indicate that this item is currently selected
*
* @param yn true if this item is currently selected
* @param src the identity of the object that initiated the change
*/
virtual void set_selected(bool yn, void* src) ;
virtual void set_selected(bool yn) ;
/**
* Set to true to indicate that this item should show its selection status
@ -181,13 +178,6 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable
*/
virtual void set_should_show_selection (bool yn) ;
/**
* Returns whether this item is currently selected.
*
* @return true if this item is currently selected, false otherwise
*/
bool get_selected() const ;
//---------------------------------------------------------------------------------------//
// Parent Component Methods
@ -319,10 +309,6 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable
/** Emitted when the mionimum item duration is changed */
sigc::signal<void,jack_nframes_t,void*> MinDurationChanged ;
/** Emitted when the selected status of this item changes */
sigc::signal<void, bool> Selected ;
protected:
enum Visibility {

View file

@ -103,6 +103,7 @@ extra_sources = [ ]
if ardour['VST']:
extra_sources += vst_files
ardour.Append(CCFLAGS="-DVST_SUPPORT", CPPPATH="#libs/fst")
if ardour['LIBLO']:
extra_sources += osc_files

View file

@ -48,7 +48,7 @@ class DestructiveFileSource : public SndFileSource {
static void setup_standard_crossfades (jack_nframes_t sample_rate);
protected:
jack_nframes_t write_unlocked (Sample *src, jack_nframes_t start, jack_nframes_t cnt, char * workbuf);
jack_nframes_t write_unlocked (Sample *src, jack_nframes_t cnt, char * workbuf);
private:
static jack_nframes_t xfade_frames;

View file

@ -321,7 +321,6 @@ public:
Change restore_state (State&);
StateManager::State* state_factory (std::string why) const;
void send_state_changed();
bool get_midi_node_info (XMLNode * node, MIDI::eventType & ev, MIDI::channel_t & chan, MIDI::byte & additional);
bool set_midi_node_info (XMLNode * node, MIDI::eventType ev, MIDI::channel_t chan, MIDI::byte additional);

View file

@ -233,7 +233,6 @@ class Region : public Stateful, public StateManager
/* state management */
void send_change (Change);
void send_state_changed ();
/* derived classes need these during their own state management calls */

View file

@ -95,7 +95,7 @@ class Route : public IO
virtual bool can_record() const { return false; }
virtual void set_record_enable (bool yn, void *src) {}
virtual bool record_enabled() const { return false; }
virtual void transport_stopped (bool abort, bool did_locate, bool flush_redirects);
virtual void handle_transport_stopped (bool abort, bool did_locate, bool flush_redirects);
virtual void set_pending_declick (int);
/* end of vfunc-based API */

View file

@ -792,7 +792,9 @@ AudioSource::do_build_peak (jack_nframes_t first_frame, jack_nframes_t cnt)
frames_to_read = min (frames_per_peak, cnt);
if ((frames_read = read_unlocked (buf, current_frame, frames_to_read, workbuf)) != frames_to_read) {
/* lock for every read */
if ((frames_read = read (buf, current_frame, frames_to_read, workbuf)) != frames_to_read) {
error << string_compose(_("%1: could not write read raw data for peak computation (%2)"), _name, strerror (errno)) << endmsg;
goto out;
}

View file

@ -255,7 +255,7 @@ DestructiveFileSource::crossfade (Sample* data, jack_nframes_t cnt, int fade_in,
}
jack_nframes_t
DestructiveFileSource::write_unlocked (Sample* data, jack_nframes_t start, jack_nframes_t cnt, char * workbuf)
DestructiveFileSource::write_unlocked (Sample* data, jack_nframes_t cnt, char * workbuf)
{
jack_nframes_t old_file_pos;
@ -319,9 +319,7 @@ DestructiveFileSource::write_unlocked (Sample* data, jack_nframes_t start, jack_
}
old_file_pos = file_pos;
if (file_pos + cnt > _length) {
_length = file_pos + cnt;
}
update_length (file_pos, cnt);
file_pos += cnt;
if (_build_peakfiles) {

View file

@ -2443,12 +2443,6 @@ IO::state_factory (std::string why) const
return state;
}
void
IO::send_state_changed ()
{
return;
}
/**
Update the peak meters.

View file

@ -2002,7 +2002,7 @@ Route::set_active (bool yn)
}
void
Route::transport_stopped (bool abort_ignored, bool did_locate, bool can_flush_redirects)
Route::handle_transport_stopped (bool abort_ignored, bool did_locate, bool can_flush_redirects)
{
jack_nframes_t now = _session.transport_frame();

View file

@ -1198,8 +1198,8 @@ Session::update_latency_compensation (bool with_stop, bool abort)
for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
if (with_stop) {
(*i)->transport_stopped (abort, (post_transport_work & PostTransportLocate),
(!(post_transport_work & PostTransportLocate) || pending_locate_flush));
(*i)->handle_transport_stopped (abort, (post_transport_work & PostTransportLocate),
(!(post_transport_work & PostTransportLocate) || pending_locate_flush));
}
jack_nframes_t old_latency = (*i)->signal_latency ();

View file

@ -81,8 +81,6 @@ SndFileSource::SndFileSource (string idstr, SampleFormat sfmt, HeaderFormat hf,
init (idstr);
cerr << "creating " << idstr << " hf = " << hf << endl;
switch (hf) {
case CAF:
fmt = SF_FORMAT_CAF;
@ -174,7 +172,7 @@ SndFileSource::SndFileSource (string idstr, SampleFormat sfmt, HeaderFormat hf,
}
if (_build_peakfiles) {
if (initialize_peakfile (false, _path)) {
if (initialize_peakfile (true, _path)) {
sf_close (sf);
sf = 0;
throw failed_constructor ();
@ -187,14 +185,6 @@ SndFileSource::SndFileSource (string idstr, SampleFormat sfmt, HeaderFormat hf,
HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioFileSource::handle_header_position_change));
}
if (_build_peakfiles) {
if (initialize_peakfile (false, _path)) {
sf_close (sf);
sf = 0;
throw failed_constructor ();
}
}
AudioSourceCreated (this); /* EMIT SIGNAL */
}
@ -310,7 +300,7 @@ SndFileSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t
if (file_cnt) {
if (sf_seek (sf, (off_t) start, SEEK_SET) < 0) {
if (sf_seek (sf, (sf_count_t) start, SEEK_SET|SFM_READ) != (sf_count_t) start) {
char errbuf[256];
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
error << string_compose(_("SndFileSource: could not seek to frame %1 within %2 (%3)"), start, _name.substr (1), errbuf) << endmsg;
@ -505,7 +495,7 @@ SndFileSource::set_header_timeline_position ()
jack_nframes_t
SndFileSource::write_float (Sample* data, jack_nframes_t frame_pos, jack_nframes_t cnt)
{
if (sf_seek (sf, frame_pos, SEEK_SET) != frame_pos) {
if (sf_seek (sf, frame_pos, SEEK_SET|SFM_WRITE) != frame_pos) {
error << string_compose (_("%1: cannot seek to %2"), _path, frame_pos) << endmsg;
return 0;
}

View file

@ -1150,7 +1150,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
** it makes sense.
*/
if (((whence & SFM_MASK) == SFM_WRITE && psf->mode == SFM_READ) ||
((whence & SFM_MASK) == SFM_WRITE && psf->mode == SFM_WRITE))
((whence & SFM_MASK) == SFM_READ && psf->mode == SFM_WRITE))
{ psf->error = SFE_WRONG_SEEK ;
return PSF_SEEK_ERROR ;
} ;
@ -1210,10 +1210,25 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
if (psf->error)
return PSF_SEEK_ERROR ;
#ifdef ECDL_ORIGINAL#
if (seek_from_start < 0 || seek_from_start > psf->sf.frames)
{ psf->error = SFE_BAD_SEEK ;
return PSF_SEEK_ERROR ;
} ;
#else
if (((whence & SFM_MASK) == SFM_WRITE) || (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR))
{ if (seek_from_start < 0 /* || (seek_from_start > psf->sf.frames && post-audio chunks exist) */ )
{ psf->error = SFE_BAD_SEEK ;
return PSF_SEEK_ERROR ;
}
}
else /* seek for reading */
{ if (seek_from_start < 0 || seek_from_start > psf->sf.frames)
{ psf->error = SFE_BAD_SEEK ;
return PSF_SEEK_ERROR ;
}
}
#endif
if (psf->seek)
{ int new_mode = (whence & SFM_MASK) ? (whence & SFM_MASK) : psf->mode ;
@ -1234,6 +1249,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
break ;
} ;
psf->last_op = new_mode ;
return retval ;