Use PLATFORM_WINDOWS (in preference to WIN32) for consistency with the other libraries
[ardour.git] / libs / ardour / coreaudiosource.cc
index 09e06a49bcd96a40d2b2eaa6c7db3826f633c019..010905d120cc371beaa8437b0e6613a8674bed8c 100644 (file)
@@ -28,6 +28,8 @@
 #include <appleutility/CAAudioFile.h>
 #include <appleutility/CAStreamBasicDescription.h>
 
+#include <glibmm/fileutils.h>
+
 #include "i18n.h"
 
 #include <AudioToolbox/AudioFormat.h>
@@ -36,21 +38,32 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
+/** Create a new CoreAudioSource using session state, which implies that the
+ *  file must already exist.
+ */
 CoreAudioSource::CoreAudioSource (Session& s, const XMLNode& node)
        : Source (s, node)
        , AudioFileSource (s, node)
 {
        init_cafile ();
+
+        assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS));
+       existence_check ();
 }
 
+/** Create a new CoreAudioSource from an existing file. Sources created with this
+ *  method are never writable or removable.
+ */
 CoreAudioSource::CoreAudioSource (Session& s, const string& path, int chn, Flag flags)
-       /* files created this way are never writable or removable */
        : Source (s, DataType::AUDIO, path, Source::Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy))),
                AudioFileSource (s, path,
                        Source::Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
 {
        _channel = chn;
        init_cafile ();
+
+        assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS));
+       existence_check ();
 }
 
 void
@@ -174,7 +187,6 @@ CoreAudioSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) c
 
                if (n_channels == 1) {
                        if (safe_read (dst, start, file_cnt, abl) == 0) {
-                               _read_data_count = cnt * sizeof (Sample);
                                return cnt;
                        }
                        return 0;
@@ -187,8 +199,6 @@ CoreAudioSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) c
                return 0;
        }
 
-       _read_data_count = cnt * sizeof(float);
-
        Sample *ptr = interleave_buf + _channel;
 
        /* stride through the interleaved data */
@@ -227,7 +237,7 @@ CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&)
 {
        FSRef ref;
        ExtAudioFileRef af = 0;
-       size_t size;
+       UInt32 size;
        CFStringRef name;
        int ret = -1;