fix DSP load bounds 0..1 and add unbound API
[ardour.git] / libs / ardour / sndfilesource.cc
index 7dc2803a65a311157d71e72c21dd42859af93cf3..54854b61ff7968bbe6d6f247e94249f22cde8a80 100644 (file)
@@ -152,6 +152,23 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig
                _flags = Flag (_flags & ~Broadcast);
                break;
 
+       case RF64_WAV:
+               fmt = SF_FORMAT_RF64;
+               _flags = Flag (_flags & ~Broadcast);
+               _flags = Flag (_flags | RF64_RIFF);
+               break;
+
+       case MBWF:
+               fmt = SF_FORMAT_RF64;
+               _flags = Flag (_flags | Broadcast);
+               _flags = Flag (_flags | RF64_RIFF);
+               break;
+
+       case RF64:
+               fmt = SF_FORMAT_RF64;
+               _flags = Flag (_flags & ~Broadcast);
+               break;
+                              
        default:
                fatal << string_compose (_("programming error: %1"), X_("unsupported audio header format requested")) << endmsg;
                abort(); /*NOTREACHED*/
@@ -296,6 +313,19 @@ SndFileSource::open ()
 
        _length = _info.frames;
 
+#ifdef HAVE_RF64_RIFF
+       if (_file_is_new && _length == 0 && writable()) {
+               if (_flags & RF64_RIFF) {
+                       if (sf_command (_sndfile, SFC_AUTO_DOWNGRADE_RF64, 0, 0) != SF_TRUE) {
+                               char errbuf[256];
+                               sf_error_str (_sndfile, errbuf, sizeof (errbuf) - 1);
+                               error << string_compose (_("Cannot mark RF64 audio file for automatic downgrade to WAV: %1"), errbuf)
+                                     << endmsg;
+                       }
+               }
+       }
+#endif
+       
        if (!_broadcast_info) {
                _broadcast_info = new BroadcastInfo;
        }
@@ -937,6 +967,10 @@ SndFileSource::get_soundfile_info (const string& path, SoundFileInfo& info, stri
 
        sf_info.format = 0; // libsndfile says to clear this before sf_open().
 
+       if (path.empty() || Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
+               return false;
+       }
+
 #ifdef PLATFORM_WINDOWS
        int fd = g_open (path.c_str(), O_RDONLY, 0444);
 #else