Add a missing #define to our MSVC project (portaudio_backend)
[ardour.git] / libs / ardour / audiofilesource.cc
index 8e1f50a55dea2ccd3aff80898a9a0d57a98a361b..2edd06282b1129b80927b5e9129c88ade9ee0660 100644 (file)
@@ -131,11 +131,13 @@ AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag f
 }
 
 
-/** Constructor used for existing files via XML.  File must exist. If _origin
- * is an absolute path after ::set_state(), then the file is external to the
- * session.
+/** 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, bool optional_origin)
+AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
        : Source (s, node)
        , AudioSource (s, node)
        , FileSource (s, node, must_exist)
@@ -146,7 +148,6 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi
 
        if (Glib::path_is_absolute (_origin)) {
                _path = _origin;
-               must_exist = !optional_origin;
        }
 
        if (init (_path, must_exist)) {
@@ -206,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;
 }
 
@@ -282,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)
 {