Add a missing #define to our MSVC project (portaudio_backend)
[ardour.git] / libs / ardour / audiofilesource.cc
index bb3c18f810470ed3b33853da73b2dece1d0ba686..2edd06282b1129b80927b5e9129c88ade9ee0660 100644 (file)
@@ -61,7 +61,7 @@
 #include <AudioToolbox/AudioFormat.h>
 #endif // HAVE_COREAUDIO
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -131,7 +131,12 @@ AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag f
 }
 
 
-/** Constructor used for existing internal-to-session files via XML.  File must exist. */
+/** Constructor used for sources listed in session-files (XML)
+ * and missing sources (SilentFileSource).
+ *
+ * If _origin is an absolute path after ::set_state(), then the
+ * file is external to the session.
+ */
 AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
        : Source (s, node)
        , AudioSource (s, node)
@@ -141,6 +146,10 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi
                throw failed_constructor ();
        }
 
+       if (Glib::path_is_absolute (_origin)) {
+               _path = _origin;
+       }
+
        if (init (_path, must_exist)) {
                throw failed_constructor ();
        }
@@ -198,11 +207,14 @@ AudioFileSource::get_soundfile_info (const string& path, SoundFileInfo& _info, s
 XMLNode&
 AudioFileSource::get_state ()
 {
+       LocaleGuard lg;
        XMLNode& root (AudioSource::get_state());
        char buf[32];
        snprintf (buf, sizeof (buf), "%u", _channel);
        root.add_property (X_("channel"), buf);
-        root.add_property (X_("origin"), _origin);
+       root.add_property (X_("origin"), _origin);
+       snprintf (buf, sizeof (buf), "%f", _gain);
+       root.add_property (X_("gain"), buf);
        return root;
 }
 
@@ -274,6 +286,20 @@ AudioFileSource::setup_peakfile ()
        }
 }
 
+void
+AudioFileSource::set_gain (float g, bool temporarily)
+{
+       if (_gain == g) {
+               return;
+       }
+       _gain = g;
+       if (temporarily) {
+               return;
+       }
+       close_peakfile();
+       setup_peakfile ();
+}
+
 bool
 AudioFileSource::safe_audio_file_extension(const string& file)
 {