[xiph-commits] r12754 - in trunk/xiph-qt: CAFLAC/src CASpeex/src CAVorbis/src OggImport/src build-macosx/XiphQT.xcodeproj

arek at svn.xiph.org arek at svn.xiph.org
Tue Mar 13 20:51:41 PDT 2007


Author: arek
Date: 2007-03-13 20:51:23 -0700 (Tue, 13 Mar 2007)
New Revision: 12754

Added:
   trunk/xiph-qt/OggImport/src/samplerefs.c
   trunk/xiph-qt/OggImport/src/samplerefs.h
Modified:
   trunk/xiph-qt/CAFLAC/src/CAOggFLACDecoder.cpp
   trunk/xiph-qt/CAFLAC/src/flac_versions.h
   trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp
   trunk/xiph-qt/CASpeex/src/speex_versions.h
   trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp
   trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp
   trunk/xiph-qt/CAVorbis/src/vorbis_versions.h
   trunk/xiph-qt/OggImport/src/OggImport.c
   trunk/xiph-qt/OggImport/src/importer_types.h
   trunk/xiph-qt/OggImport/src/stream_flac.c
   trunk/xiph-qt/OggImport/src/stream_flac.h
   trunk/xiph-qt/OggImport/src/stream_speex.c
   trunk/xiph-qt/OggImport/src/stream_speex.h
   trunk/xiph-qt/OggImport/src/stream_theora.c
   trunk/xiph-qt/OggImport/src/stream_theora.h
   trunk/xiph-qt/OggImport/src/stream_types_flac.h
   trunk/xiph-qt/OggImport/src/stream_types_speex.h
   trunk/xiph-qt/OggImport/src/stream_types_theora.h
   trunk/xiph-qt/OggImport/src/stream_types_vorbis.h
   trunk/xiph-qt/OggImport/src/stream_vorbis.c
   trunk/xiph-qt/OggImport/src/stream_vorbis.h
   trunk/xiph-qt/OggImport/src/utils.c
   trunk/xiph-qt/OggImport/src/utils.h
   trunk/xiph-qt/OggImport/src/versions.h
   trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj
Log:
Changes:
 * updated OggImport to use newer, bulk-update API for adding sample references;
 * updated decoder components to work properly with bulk-imported data (esp. in QT 7.1.5);
 * much improved, and enabled, idle/progressive importing (file duration calculation/estimation, placeholder track creation, idling, scheduling, async reading).


Modified: trunk/xiph-qt/CAFLAC/src/CAOggFLACDecoder.cpp
===================================================================
--- trunk/xiph-qt/CAFLAC/src/CAOggFLACDecoder.cpp	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CAFLAC/src/CAOggFLACDecoder.cpp	2007-03-14 03:51:23 UTC (rev 12754)
@@ -244,7 +244,7 @@
 
     ogg_page op;
 
-    if (!WrapOggPage(&op, static_cast<const Byte*> (inInputData) + inPacketDescription->mStartOffset, inPacketDescription->mDataByteSize, 0))
+    if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize + inPacketDescription->mStartOffset, inPacketDescription->mStartOffset))
         CODEC_THROW(kAudioCodecUnspecifiedError);
 
     dbg_printf("[ oFD]   : [%08lx] InPacket() [%4.4s] %ld\n", (UInt32) this, (char *) (static_cast<const Byte*> (inInputData) + inPacketDescription->mStartOffset),

Modified: trunk/xiph-qt/CAFLAC/src/flac_versions.h
===================================================================
--- trunk/xiph-qt/CAFLAC/src/flac_versions.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CAFLAC/src/flac_versions.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -32,9 +32,9 @@
 #define __flac_versions_h__
 
 #ifdef DEBUG
-#define kCAFLAC_adec_Version		(0x00FF0103)
+#define kCAFLAC_adec_Version		(0x00FF0104)
 #else
-#define kCAFLAC_adec_Version		(0x00000103)
+#define kCAFLAC_adec_Version		(0x00000104)
 #endif /* DEBUG */
 
 #endif /* __flac_versions_h__ */

Modified: trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp
===================================================================
--- trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp	2007-03-14 03:51:23 UTC (rev 12754)
@@ -196,7 +196,7 @@
 
     ogg_page op;
 
-    if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize, inPacketDescription->mStartOffset))
+    if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize + inPacketDescription->mStartOffset, inPacketDescription->mStartOffset))
         CODEC_THROW(kAudioCodecUnspecifiedError);
 
     ogg_packet opk;

Modified: trunk/xiph-qt/CASpeex/src/speex_versions.h
===================================================================
--- trunk/xiph-qt/CASpeex/src/speex_versions.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CASpeex/src/speex_versions.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -33,9 +33,9 @@
 
 
 #ifdef DEBUG
-#define kCASpeex_adec_Version		(0x00FF0103)
+#define kCASpeex_adec_Version		(0x00FF0104)
 #else
-#define kCASpeex_adec_Version		(0x00000103)
+#define kCASpeex_adec_Version		(0x00000104)
 #endif /* DEBUG */
 
 

Modified: trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp	2007-03-14 03:51:23 UTC (rev 12754)
@@ -107,7 +107,7 @@
 UInt32 CAOggVorbisDecoder::ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
                                                 AudioStreamPacketDescription* outPacketDescription)
 {
-    dbg_printf(" >> [%08lx] CAOggVorbisDecoder :: ProduceOutputPackets(%ld [%ld]) (%ld, %ld, %ld; %ld[%ld])\n",
+    dbg_printf("[VDO ]  >> [%08lx] :: ProduceOutputPackets(%ld [%ld]) (%ld, %ld, %ld; %ld[%ld])\n",
                (UInt32) this, ioNumberPackets, ioOutputDataByteSize, mSOBufferSize, mSOBufferUsed, mSOReturned, mSOBufferPages, mSOBufferPackets);
     UInt32 ret = kAudioCodecProduceOutputPacketSuccess;
 
@@ -115,7 +115,7 @@
         ioOutputDataByteSize = 0;
         ioNumberPackets = 0;
         ret = kAudioCodecProduceOutputPacketNeedsMoreInputData;
-        dbg_printf("<!E [%08lx] CAOggVorbisDecoder :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n", (UInt32) this,
+        dbg_printf("[VDO ] <!E [%08lx] :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n", (UInt32) this,
                    ioNumberPackets, ioOutputDataByteSize, ret, FramesReady());
         return ret;
     }
@@ -127,7 +127,7 @@
     Byte *the_data = static_cast<Byte*> (outOutputData);
 
     if (mSOBuffer != NULL) {
-        dbg_printf("  + SOBuffering output\n");
+        dbg_printf("[VDO ]   + SOBuffering output\n");
         /* stream/sample offset buffer not empty - must be beginning of the stream */
         if (mSOBufferUsed == 0) {
             /* fill the buffer first */
@@ -256,7 +256,11 @@
         }
     }
 
-    dbg_printf("<.. [%08lx] CAOggVorbisDecoder :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n",
+    if (ret == kAudioCodecProduceOutputPacketSuccess || ret == kAudioCodecProduceOutputPacketSuccessHasMore) {
+        ioNumberPackets = ioOutputDataByteSize / mOutputFormat.mBytesPerFrame;
+    }
+
+    dbg_printf("[VDO ] <.. [%08lx] :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n",
                (UInt32) this, ioNumberPackets, ioOutputDataByteSize, ret, FramesReady());
     return ret;
 }
@@ -300,14 +304,18 @@
 
 void CAOggVorbisDecoder::InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription)
 {
-    dbg_printf(" >> [%08lx] CAOggVorbisDecoder :: InPacket({%ld, %ld})\n", (UInt32) this, inPacketDescription->mDataByteSize, inPacketDescription->mVariableFramesInPacket);
-    if (!mCompressionInitialized)
+    dbg_printf("[VDO ]  >> [%08lx] :: InPacket({%ld, %ld})\n", (UInt32) this, inPacketDescription->mDataByteSize, inPacketDescription->mVariableFramesInPacket);
+    if (!mCompressionInitialized) {
+        dbg_printf("[VDO ] <!I [%08lx] :: InPacket()\n", (UInt32) this);
         CODEC_THROW(kAudioCodecUnspecifiedError);
+    }
 
     ogg_page op;
 
-    if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize, inPacketDescription->mStartOffset))
+    if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize + inPacketDescription->mStartOffset, inPacketDescription->mStartOffset)) {
+        dbg_printf("[VDO ] <!O [%08lx] :: InPacket()\n", (UInt32) this);
         CODEC_THROW(kAudioCodecUnspecifiedError);
+    }
 
     ogg_packet opk;
     SInt32 packet_count = 0;
@@ -349,7 +357,7 @@
         mSOReturned = 0;
     }
 
-    dbg_printf("<.. [%08lx] CAOggVorbisDecoder :: InPacket(pn: %ld)\n", (UInt32) this, ogg_page_pageno (&op));
+    dbg_printf("[VDO ] <.. [%08lx] :: InPacket(pn: %ld)\n", (UInt32) this, ogg_page_pageno (&op));
 }
 
 
@@ -374,7 +382,7 @@
 
             if (EndianS32_BtoN(aheader->type) == kCookieTypeVorbisFirstPageNo && ptrheader <= cend) {
                 mFirstPageNo = EndianU32_BtoN((reinterpret_cast<OggSerialNoAtom*> (aheader))->serialno);
-                dbg_printf("  = [%08lx] CAOggVorbisDecoder :: InitializeCompressionSettings(fpn: %ld)\n", (UInt32) this, mFirstPageNo);
+                dbg_printf("[VDO ]   = [%08lx] :: InitializeCompressionSettings(fpn: %ld)\n", (UInt32) this, mFirstPageNo);
                 break;
             }
         }

Modified: trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp	2007-03-14 03:51:23 UTC (rev 12754)
@@ -159,7 +159,7 @@
     dbg_printf("[VD  ]  >> [%08lx] :: GetProperty('%4.4s', %ld)\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID), ioPropertyDataSize);
     switch(inPropertyID)
     {
-    case kAudioCodecPropertyRequiresPacketDescription:
+    case kAudioCodecPropertyRequiresPacketDescription: // 'pakd'
         if(ioPropertyDataSize == sizeof(UInt32)) {
             *reinterpret_cast<UInt32*>(outPropertyData) = 1;
         } else {
@@ -167,7 +167,7 @@
         }
         break;
 
-    case kAudioCodecPropertyHasVariablePacketByteSizes:
+    case kAudioCodecPropertyHasVariablePacketByteSizes: // 'vpk?'
         if(ioPropertyDataSize == sizeof(UInt32)) {
             *reinterpret_cast<UInt32*>(outPropertyData) = 1;
         } else {
@@ -175,7 +175,7 @@
         }
         break;
 
-    case kAudioCodecPropertyPacketFrameSize:
+    case kAudioCodecPropertyPacketFrameSize: // 'pakf'
         if(ioPropertyDataSize == sizeof(UInt32))
         {
             /* The following line has been changed according to Apple engineers' suggestion
@@ -193,7 +193,7 @@
         }
         break;
 
-    case kAudioCodecPropertyMaximumPacketByteSize:
+    case kAudioCodecPropertyMaximumPacketByteSize: // 'pakb'
         if(ioPropertyDataSize == sizeof(UInt32)) {
             *reinterpret_cast<UInt32*>(outPropertyData) = kVorbisFormatMaxBytesPerPacket;
         } else {
@@ -201,7 +201,7 @@
         }
         break;
 
-    case kAudioCodecPropertyCurrentInputSampleRate:
+    case kAudioCodecPropertyCurrentInputSampleRate: // 'cisr'
         if (ioPropertyDataSize == sizeof(Float64)) {
             *reinterpret_cast<Float64*>(outPropertyData) = mInputFormat.mSampleRate;
         } else if (ioPropertyDataSize == sizeof(UInt32)) {
@@ -211,7 +211,7 @@
         }
         break;
 
-    case kAudioCodecPropertyCurrentOutputSampleRate:
+    case kAudioCodecPropertyCurrentOutputSampleRate: // 'cosr'
         if (ioPropertyDataSize == sizeof(Float64)) {
             *reinterpret_cast<Float64*>(outPropertyData) = mOutputFormat.mSampleRate;
         } else if (ioPropertyDataSize == sizeof(UInt32)) {
@@ -223,7 +223,7 @@
 
         //case kAudioCodecPropertyQualitySetting: ???
 #if TARGET_OS_MAC
-    case kAudioCodecPropertyNameCFString:
+    case kAudioCodecPropertyNameCFString: // 'lnam'
         {
             if (ioPropertyDataSize != sizeof(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
 
@@ -246,28 +246,28 @@
     dbg_printf("[VD  ]  >> [%08lx] :: GetPropertyInfo('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
     switch(inPropertyID)
     {
-    case kAudioCodecPropertyRequiresPacketDescription:
+    case kAudioCodecPropertyRequiresPacketDescription: // 'pakd'
         outPropertyDataSize = sizeof(UInt32);
         outWritable = false;
         break;
 
-    case kAudioCodecPropertyHasVariablePacketByteSizes:
+    case kAudioCodecPropertyHasVariablePacketByteSizes: // 'vpk?'
         outPropertyDataSize = sizeof(UInt32);
         outWritable = false;
         break;
 
-    case kAudioCodecPropertyPacketFrameSize:
+    case kAudioCodecPropertyPacketFrameSize: // 'pakf'
         outPropertyDataSize = sizeof(UInt32);
         outWritable = false;
         break;
 
-    case kAudioCodecPropertyMaximumPacketByteSize:
+    case kAudioCodecPropertyMaximumPacketByteSize: // 'pakb'
         outPropertyDataSize = sizeof(UInt32);
         outWritable = false;
         break;
 
-    case kAudioCodecPropertyCurrentInputSampleRate:
-    case kAudioCodecPropertyCurrentOutputSampleRate:
+    case kAudioCodecPropertyCurrentInputSampleRate:  // 'cisr'
+    case kAudioCodecPropertyCurrentOutputSampleRate: // 'cosr'
         outPropertyDataSize = sizeof(Float64);
         outWritable = false;
         break;

Modified: trunk/xiph-qt/CAVorbis/src/vorbis_versions.h
===================================================================
--- trunk/xiph-qt/CAVorbis/src/vorbis_versions.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/CAVorbis/src/vorbis_versions.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -33,10 +33,10 @@
 
 
 #ifdef DEBUG
-#define kCAVorbis_adec_Version		(0x00FF0107)
+#define kCAVorbis_adec_Version		(0x00FF0108)
 #define kCAVorbis_aenc_Version		(0x00FF0101)
 #else
-#define kCAVorbis_adec_Version		(0x00000107)
+#define kCAVorbis_adec_Version		(0x00000108)
 #define kCAVorbis_aenc_Version		(0x00000101)
 #endif /* DEBUG */
 

Modified: trunk/xiph-qt/OggImport/src/OggImport.c
===================================================================
--- trunk/xiph-qt/OggImport/src/OggImport.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/OggImport.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -4,7 +4,7 @@
  *    The main part of the OggImport component.
  *
  *
- *  Copyright (c) 2005-2006  Arek Korbik
+ *  Copyright (c) 2005-2007  Arek Korbik
  *
  *  This file is part of XiphQT, the Xiph QuickTime Components.
  *
@@ -95,7 +95,11 @@
     kDataBufferSize = 64 * 1024,
     kDataAsyncBufferSize = 16 * 1024,
 
-    kDefaultChunkSize = 11000
+    kDefaultChunkSize = 11000,
+
+    kTempFileDuration = 3599,
+    kBitrateEstimateBytesNeeded = 1024 * 1024,
+    kNoIdlingFileSizeLimit = 7 * 1024 * 1024,
 };
 
 
@@ -188,7 +192,37 @@
 }
 #endif
 
+static void _debug_idles(OggImportGlobalsPtr globals) {
+#if !defined(NDEBUG)
+    Boolean needs = false;
+    TimeRecord ni;
 
+    if (globals->idleManager != NULL) {
+        QTIdleManagerNeedsAnIdle(globals->idleManager, &needs);
+        if (needs) {
+            QTIdleManagerGetNextIdleTime(globals->idleManager, &ni);
+            dbg_printf("[OI  ]   i [%08lx] idles: requested: base: %ld, scale: %ld, value: %ld %ld [%ld]\n",
+                       (UInt32) globals, (long) ni.base, ni.scale, ni.value.hi, ni.value.lo,
+                       GetTimeBaseTime(ni.base, 1000000, NULL));
+        } else {
+            dbg_printf("[OI  ]  !i [%08lx] idles: not needed\n", (UInt32) globals);
+        }
+    }
+
+    if (globals->dataIdleManager != NULL) {
+        QTIdleManagerNeedsAnIdle(globals->dataIdleManager, &needs);
+        if (needs) {
+            QTIdleManagerGetNextIdleTime(globals->dataIdleManager, &ni);
+            dbg_printf("[OI  ]   d [%08lx] idles: requested: base: %ld, scale: %ld, value: %ld %ld [%ld]\n",
+                       (UInt32) globals, (long) ni.base, ni.scale, ni.value.hi, ni.value.lo,
+                       GetTimeBaseTime(ni.base, 1000000, NULL));
+        } else {
+            dbg_printf("[OI  ]  !d [%08lx] idles: not needed\n", (UInt32) globals);
+        }
+    }
+#endif /* NDEBUG */
+}
+
 static ComponentResult DoRead(OggImportGlobalsPtr globals, Ptr buffer, SInt64 offset, long size)
 {
     ComponentResult err;
@@ -206,27 +240,39 @@
                globals->dataCanDoScheduleData, globals->dataCanDoGetFileSize64);
 
     if (globals->usingIdle && globals->dataCanDoAsyncRead) {
+        wide read_time = {0, 2};
+        if (globals->idleTimeBase == NULL) {
+            globals->idleTimeBase = NewTimeBase();
+            SetTimeBaseRate(globals->idleTimeBase, fixed1);
+        }
+
         globals->dataRequested = true;
         const_ref = (long) globals;
         compl_upp = globals->dataReadCompletion;
-        sched_rec.timeNeededBy.value.hi = 0; //S64Set(0);
-        sched_rec.timeNeededBy.value.lo = 0; //S64Set(0);
-        sched_rec.timeNeededBy.scale = 0;
-        sched_rec.timeNeededBy.base = GetMovieTimeBase(globals->theMovie);
-        sched_rec.extendedID = 0; // kDataHExtendedSchedule ?
+
+        GetTimeBaseTime(globals->idleTimeBase, 20, &sched_rec.timeNeededBy);
+        WideAdd(&sched_rec.timeNeededBy.value, &read_time);
+        sched_rec.extendedID = 0;
         sched_rec.extendedVers = 0;
         sched_rec.priority = 0x00640000; // (Fixed) 100.0
 
         sched_rec_ptr = &sched_rec;
 
+        _debug_idles(globals);
         err = QTIdleManagerSetNextIdleTimeNever(globals->idleManager);
         dbg_printf("----: Disabling Idles: %ld\n", err);
+        _debug_idles(globals);
+        err = QTIdleManagerSetNextIdleTimeNever(globals->dataIdleManager);
+        dbg_printf("----: Disabling (data) Idles: %ld\n", err);
+        _debug_idles(globals);
     }
 
     if (globals->dataCanDoScheduleData64) {
         err = DataHScheduleData64(globals->dataReader, buffer, &wideOffset, size, const_ref, sched_rec_ptr, compl_upp);
+        dbg_printf("[OI  ]  sR [%08lx] :: DoRead() = %ld\n", (UInt32) globals, err);
     } else if (globals->dataCanDoScheduleData) {
         err = DataHScheduleData(globals->dataReader, buffer, wideOffset.lo, size, const_ref, sched_rec_ptr, compl_upp);
+        dbg_printf("[OI  ]  sr [%08lx] :: DoRead() = %ld\n", (UInt32) globals, err);
     } else {
         err = badComponentSelector;
         //err = DataHGetData(globals->dataReader, buffer, 0, wideOffset.lo, size);
@@ -347,8 +393,8 @@
 {
     ogg_stream_clear(&si->os);
 
-    if (si->sfhf->finish != NULL)
-        /* ret = */ (*si->sfhf->finish)(globals, si);
+    if (si->sfhf->flush != NULL)
+        /* ret = */ (*si->sfhf->flush)(globals, si, true);
 
     if (si->sfhf->clear != NULL)
         (*si->sfhf->clear)(si);
@@ -747,10 +793,11 @@
 }
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-ComponentResult NotifyMovieChanged(OggImportGlobalsPtr globals)
+ComponentResult NotifyMovieChanged(OggImportGlobalsPtr globals, Boolean force)
 {
     //Notify the movie it's changed (from email from Chris Flick)
     QTAtomContainer container = NULL;
+    UInt32 tickNow = TickCount();
     OSErr err = noErr;
 
     if (!globals->usingIdle) {
@@ -758,6 +805,11 @@
         return err;
     }
 
+    if ((tickNow < globals->tickNotified + globals->notifyStep) && !force) {
+        dbg_printf("  --  NotifyMovieChanged() = too short period, skipping\n");
+        return err;
+    }
+
     err = QTNewAtomContainer (&container);
 
     if (err == noErr)
@@ -771,6 +823,9 @@
         if (err == noErr)
             err = MovieExecuteWiredActions (globals->theMovie, 0, container);
 
+        if (!err)
+            globals->tickNotified = tickNow;
+
         dbg_printf("  **  NotifyMovieChanged() = %ld\n", (long)err);
         err = QTDisposeAtomContainer (container);
     }
@@ -811,6 +866,198 @@
     return ff;
 }
 
+/* =============== idle importing support functions ============== */
+
+ComponentResult GetLastFileGP(OggImportGlobalsPtr globals)
+{
+    ComponentResult err = noErr;
+    wide wideOffset = SInt64ToWide(globals->dataEndOffset);
+    unsigned char *buffer = NULL, *p = NULL;
+    UInt32 size = 8192, i = 16;
+    UInt32 ssize = 0;
+    wide wideSize = SInt64ToWide(S64SetU(size));
+
+    dbg_printf("[OI  ]  >> [%08lx] :: GetLastFileGP(%lld)\n", (UInt32) globals, globals->dataEndOffset);
+
+    buffer = malloc(size * 16);
+    if (buffer == NULL)
+        err = MemError();
+
+    if (!err) {
+        memset(buffer, 0, size * 16);
+        p = buffer + size * 16;
+
+        while (i-- > 0) {
+            wideOffset = *WideSubtract(&wideOffset, &wideSize);
+            p -= size;
+            ssize += size;
+
+            if (globals->dataCanDoScheduleData64) {
+                err = DataHScheduleData64(globals->dataReader, (char *) p,
+                                          &wideOffset, size, 0, NULL, NULL);
+            } else if (globals->dataCanDoScheduleData) {
+                err = DataHScheduleData(globals->dataReader, (char *) p,
+                                        wideOffset.lo, size, 0, NULL, NULL);
+            }
+
+            if (err)
+                break;
+
+            find_last_page_GP(p, ssize, &globals->lp_GP, &globals->lp_serialno);
+            if (globals->lp_GP > 0)
+                break;
+        }
+    }
+
+    // some sources can only be read sequentially, it's OK
+    if (err == notEnoughDataErr)
+        err = noErr;
+
+    if (buffer != NULL)
+        free(buffer);
+
+    dbg_printf("[OI  ] <   [%08lx] :: GetLastFileGP() = %ld\n", (UInt32) globals, err);
+    return err;
+}
+
+ComponentResult GetFileDurationFromGP(OggImportGlobalsPtr globals)
+{
+    ComponentResult err = noErr;
+    TimeRecord tr;
+
+    if (globals->lp_GP > 0) {
+        StreamInfoPtr si = FindStream(globals, globals->lp_serialno);
+        if (si != NULL && si->sfhf->gp_to_time != NULL) {
+            err = (*si->sfhf->gp_to_time)(si, &globals->lp_GP, &tr);
+        } else if (si != NULL) {
+            //TimeRecord tr = {SInt64ToWide(globals->lp_GP),
+            //                 si->rate, NULL};
+            tr.value = SInt64ToWide(globals->lp_GP);
+            tr.scale = si->rate;
+            tr.base = NULL;
+        }
+
+        if (!err) {
+            ConvertTimeScale(&tr, GetMovieTimeScale(globals->theMovie));
+            err = GetMoviesError();
+        }
+
+        if (!err)
+            globals->totalTime = U32SetU(WideToSInt64(tr.value));
+    }
+
+    return err;
+}
+
+ComponentResult EstimateFileDuration(OggImportGlobalsPtr globals)
+{
+    ComponentResult err = noErr;
+
+    SInt64 d = S64Multiply(S64Set(globals->timeLoaded), S64Subtract(globals->dataEndOffset, globals->dataStartOffset));
+    SInt64 read_size = S64Subtract(globals->dataOffset, globals->dataStartOffset);
+
+    /* Assume a number of 'non-audio' bytes at the beginning of each stream.
+       4k at the moment, better to assume more as it will result in a longer
+       (idealy it should be slightly longer than the real duration)
+       placeholder track. */
+    read_size = S64Subtract(read_size, S64Set(globals->streamCount * 4096));
+
+    if (S64Compare(read_size, S64Set(1)) < 0 || S64Compare(d, S64Set(1)) < 0)
+        globals->totalTime = kTempFileDuration * GetMovieTimeScale(globals->theMovie);
+    else
+        globals->totalTime = S32Set(S64Div(d,  read_size));
+
+    dbg_printf("[OI  ]   = [%08lx] :: EstimateFileDuration() : %ld (%ld, %lld, %lld)\n",
+               (UInt32) globals, globals->totalTime, globals->timeLoaded,
+               S64Subtract(globals->dataEndOffset, globals->dataStartOffset), read_size);
+    return err;
+}
+
+ComponentResult CreatePlaceholderTrack(OggImportGlobalsPtr globals)
+{
+    ComponentResult err = noErr;
+    Track track = NULL;
+    Media media = NULL;
+    SampleDescriptionHandle sd =
+        (SampleDescriptionHandle) NewHandleClear(sizeof(SampleDescription));
+
+    if (sd == NULL)
+        err = MemError();
+
+    if (!err) {
+        (*sd)->descSize = sizeof(SampleDescriptionPtr);
+        (*sd)->dataFormat = BaseMediaType;
+
+        track = NewMovieTrack(globals->theMovie, 0, 0, 0);
+        if (track != NULL) {
+            media = NewTrackMedia(track, BaseMediaType,
+                                  GetMovieTimeScale(globals->theMovie),
+                                  NewHandle(0), NullDataHandlerSubType);
+
+            if (media != NULL) {
+                err = AddMediaSampleReference(media, 0, 1, globals->totalTime,
+                                              sd, 1, 0, NULL);
+
+                if (!err)
+                    err = InsertMediaIntoTrack(track, 0, 0, globals->totalTime,
+                                               fixed1);
+                if (!err) {
+                    if (globals->phTrack != NULL)
+                        DisposeMovieTrack(globals->phTrack);
+                    globals->phTrack = track;
+                } else {
+                    DisposeMovieTrack(track);
+                }
+            } else {
+                err = GetMoviesError();
+                DisposeMovieTrack(track);
+            }
+        } else {
+            err = GetMoviesError();
+        }
+
+        DisposeHandle((Handle) sd);
+    }
+
+    return err;
+}
+
+ComponentResult RemovePlaceholderTrack(OggImportGlobalsPtr globals)
+{
+    ComponentResult err = noErr;
+
+    if (globals->phTrack) {
+        DisposeMovieTrack(globals->phTrack);
+        globals->phTrack = NULL;
+    }
+
+    return err;
+}
+
+ComponentResult FlushAllStreams(OggImportGlobalsPtr globals, Boolean notify)
+{
+    ComponentResult err = noErr;
+    int i;
+
+    for (i = 0; i < globals->streamCount; i++)
+    {
+        StreamInfoPtr si = &(*globals->streamInfoHandle)[i];
+        if (si->sfhf->flush != NULL)
+            err = (*si->sfhf->flush)(globals, si, false);
+        if (err)
+            break;
+    }
+
+    if (!err) {
+        globals->tickFlushed = TickCount();
+        NotifyMovieChanged(globals, notify);
+    }
+
+    return err;
+}
+
+/* =============================================================== */
+
 static ComponentResult ProcessPage(OggImportGlobalsPtr globals, ogg_page *op) {
     ComponentResult ret = noErr;
     long serialno;
@@ -903,6 +1150,8 @@
             globals->numTracksSeen = 0;
             globals->timeLoaded = 0;
             globals->timeLoadedSubSecond = 0.0;
+            globals->tickFlushed = 0;
+            globals->tickNotified = 0;
             globals->dataRequested = false;
             globals->startTickCount = TickCount();
 
@@ -912,24 +1161,45 @@
 
             if (!globals->sizeInitialised) {
                 result = XQTGetFileSize(globals);
-                if (result != noErr)
-                    process = false;
             }
 
+            if (result == noErr && globals->calcTotalTime && globals->lp_GP < 0) {
+                result = GetLastFileGP(globals);
+            }
+
+            if (result != noErr)
+                process = false;
+
             globals->state = kStateReadingPages;
             break;
 
         case kStateReadingPages:
             dbg_printf("   - (:kStateReadingPages:)\n");
             if (globals->dataRequested) {
-                DataHTask(globals->dataReader);
-                process = false;
-                break;
+                
+                _debug_idles(globals);
+                result = DataHTask(globals->dataReader);
+                {
+                    Boolean needs = false;
+                    QTIdleManagerNeedsAnIdle(globals->dataIdleManager, &needs);
+                    if (needs) {
+                        QTIdleManagerSetNextIdleTimeDelta(globals->idleManager, 1, 4); // delay 1/4s
+                        QTIdleManagerSetNextIdleTimeDelta(globals->dataIdleManager, 1, 4); // delay 1/4s
+                    }
+                }
+                _debug_idles(globals);
+                
+                dbg_printf("[OI  ]  dT [%08lx] :: StateProcess() = %ld\n", (UInt32) globals, result);
+                if (result != noErr || globals->dataRequested || true) {
+                    process = false;
+                    break;
+                }
             }
             globals->currentData = rb_data(&globals->dataRB);
             globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
 
             while (result == noErr && FindPage(&globals->currentData, globals->validDataEnd, &og)) {
+            //while (result == noErr && FindPageNoCRC(&globals->currentData, globals->validDataEnd, &og)) {
                 result = ProcessPage(globals, &og);
                 dbg_printf("   - << (:kStateReadingPages:) :: ProcessPage() = %ld\n", (long) result);
             }
@@ -937,6 +1207,48 @@
             if (result != noErr) {
                 process = false;
                 break;
+            } else {
+                if (globals->calcTotalTime && globals->groupStreamsFound) {
+                    if (globals->lp_GP > 0 && globals->totalTime == 0)
+                        result = GetFileDurationFromGP(globals);
+
+                    if (result != noErr) {
+                        process = false;
+                        break;
+                    }
+
+                    if (globals->phTrack == NULL && globals->totalTime > 0) {
+                        // duration: from GP
+                        /* result = */ CreatePlaceholderTrack(globals);
+                        globals->calcTotalTime = false;
+                        process = false;
+                        break;
+                    } else {
+                        if (S64Compare(globals->dataOffset, S64Set(kBitrateEstimateBytesNeeded)) > 0) {
+                            // duration: from bitrate
+                            // TODO: do 'from GP' calculations here (again) taking into account possible stream start offsets
+                            FlushAllStreams(globals, false);
+                            result = EstimateFileDuration(globals);
+                            /* result = */ CreatePlaceholderTrack(globals);
+                            globals->calcTotalTime = false;
+                            process = false;
+                            break;
+                        } else if (globals->phTrack == NULL) {
+                            // temporary placeholder
+                            globals->totalTime = kTempFileDuration * GetMovieTimeScale(globals->theMovie);
+                            /* result = */ CreatePlaceholderTrack(globals);
+                            if (globals->dataIsStream) {
+                                process = false;
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                if (globals->usingIdle) {
+                    if (TickCount() > globals->tickFlushed + globals->flushStep)
+                        FlushAllStreams(globals, false);
+                }
             }
 
             result = FillBuffer(globals);
@@ -963,6 +1275,8 @@
                 break;
             }
 
+            RemovePlaceholderTrack(globals);
+            NotifyMovieChanged(globals, true);
             globals->state = kStateImportComplete;
             break;
 
@@ -993,7 +1307,13 @@
 
         if (globals->idleManager != NULL) {
             dbg_printf("--2- ReadCompletion() :: requesting Idle\n");
+            _debug_idles(globals);
             QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
+            {
+                Boolean needs = false;
+                QTIdleManagerNeedsAnIdle(globals->idleManager, &needs);
+                dbg_printf("--2= ReadCompletion() :: requesting Idle = %d\n", needs);
+            }
         }
     }
 
@@ -1061,9 +1381,47 @@
     return err;
 }
 
+static ComponentResult JustStartImport(OggImportGlobalsPtr globals, Handle dataRef, OSType dataRefType) {
+    ComponentResult ret = noErr;
+    Boolean do_idles = globals->usingIdle;
+
+    globals->state = kStateInitial;
+    globals->usingIdle = false;
+    globals->calcTotalTime = true;
+
+    /* if limits have not been set, then try to get the size of the file. */
+    if (S64Compare(globals->dataEndOffset, S64Set(-1)) == 0) {
+        ret = XQTGetFileSize(globals);
+    }
+
+    if (ret != noErr) {
+        return ret;
+    } else if (S64Compare(globals->dataEndOffset, S64Set(0)) > 0) {
+        /* ret = */ GetLastFileGP(globals);
+    }
+
+    while (true) {
+        ret = StateProcess(globals);
+        if ((ret != noErr && ret != eofErr) || globals->dataIsStream || globals->state == kStateImportComplete || !globals->calcTotalTime) {
+            break;
+        }
+    }
+
+    if (ret == eofErr)
+        ret = noErr;
+
+    globals->usingIdle = do_idles;
+
+    if (ret == noErr) {
+        FlushAllStreams(globals, true);
+    }
+
+    dbg_printf("-<<- JustStartImport(): %ld\n", (long) ret);
+    return ret;
+}
+
 static ComponentResult JustImport(OggImportGlobalsPtr globals, Handle dataRef, OSType dataRefType) {
     ComponentResult ret = noErr;
-    Boolean do_read = true;
 
     globals->state = kStateInitial;
 
@@ -1075,10 +1433,10 @@
     if (ret != noErr)
         return ret;
 
-    while (do_read) {
+    while (true) {
         ret = StateProcess(globals);
         if ((ret != noErr && ret != eofErr) || globals->state == kStateImportComplete)
-            do_read = false;
+            break;
     }
 
     if (ret == eofErr)
@@ -1110,7 +1468,8 @@
             if (err == noErr)
                 err = DataHOpenForRead(globals->dataReader);
 
-            DataHPlaybackHints(globals->dataReader, 0, 0, -1, 49152);  // Don't care if it fails
+            //DataHPlaybackHints(globals->dataReader, 0, 0, -1, 49152);  // Don't care if it fails
+            DataHPlaybackHints(globals->dataReader, 0, 0, -1, 256 * 1024);  // Don't care if it fails
 
             if (err == noErr)
             {
@@ -1206,7 +1565,15 @@
         globals->sizeInitialised = false;
         globals->idleManager = NULL;
         globals->dataIdleManager = NULL;
+        globals->idleTimeBase = NULL;
 
+        globals->totalTime = 0;
+        globals->lp_serialno = 0;
+        globals->lp_GP = S64Set(-1);
+        globals->calcTotalTime = false;
+
+        globals->phTrack = NULL;
+
         result = noErr;
     }
     else
@@ -1224,12 +1591,8 @@
     dbg_printf("-- Close() called\n");
     if (globals != nil) // we have some globals
     {
-        if (globals->streamInfoHandle)
-        {
-            if (globals->streamCount > 0)
-                CloseAllStreams(globals);
-            DisposeHandle((Handle)globals->streamInfoHandle);
-        }
+        if (globals->dataReadCompletion)
+            DisposeDataHCompletionUPP(globals->dataReadCompletion);
 
         if (globals->dataReader)
         {
@@ -1238,6 +1601,13 @@
             globals->dataReader = NULL;
         }
 
+        if (globals->streamInfoHandle)
+        {
+            if (globals->streamCount > 0)
+                CloseAllStreams(globals);
+            DisposeHandle((Handle)globals->streamInfoHandle);
+        }
+
         if (globals->dataBuffer)
         {
             DisposePtr(globals->dataBuffer);
@@ -1248,15 +1618,15 @@
             rb_free(&globals->dataRB);
         }
 
-        if (globals->dataReadCompletion)
-            DisposeDataHCompletionUPP(globals->dataReadCompletion);
-
         if (globals->aliasHandle)
             DisposeHandle((Handle)globals->aliasHandle);
 
         if (globals->dataIdleManager != NULL)
             QTIdleManagerClose(globals->dataIdleManager);
 
+        if (globals->idleTimeBase != NULL)
+            DisposeTimeBase(globals->idleTimeBase);
+
         DisposePtr((Ptr)globals);
     }
 
@@ -1430,7 +1800,7 @@
                             long *outFlags)
 {
     ComponentResult err = noErr;
-    dbg_printf("-> Idle() called    [%08lx]\n", (long)globals);
+    dbg_printf("[OI  ]  >> [%08lx] :: Idle()  at: %ld\n", (UInt32) globals, TickCount());
 
     if (globals->state == kStateImportComplete) {
         *outFlags |= movieImportResultComplete;
@@ -1438,36 +1808,11 @@
         err = StateProcess(globals);
     }
 
-#if 0
-    if (true) {
-        Boolean needs = false;
-        TimeRecord ni;
-
-        if (globals->idleManager != NULL) {
-            QTIdleManagerNeedsAnIdle(globals->idleManager, &needs);
-            if (needs) {
-                QTIdleManagerGetNextIdleTime(globals->idleManager, &ni);
-                dbg_printf("-- -- IdleManager :: requested: base: %ld, scale: %ld, value: %ld %ld\n", (long)ni.base, ni.scale,
-                           ni.value.hi, ni.value.lo);
-            } else {
-                dbg_printf("-- -- IdleManager :: not needed\n");
-            }
-        }
-
-        if (globals->dataIdleManager != NULL) {
-            QTIdleManagerNeedsAnIdle(globals->dataIdleManager, &needs);
-            if (needs) {
-                QTIdleManagerGetNextIdleTime(globals->dataIdleManager, &ni);
-                dbg_printf("-- -- DataIdleManager :: requested: base: %ld, scale: %ld, value: %ld %ld\n", (long)ni.base, ni.scale,
-                           ni.value.hi, ni.value.lo);
-            } else {
-                dbg_printf("-- -- DataIdleManager :: not needed\n");
-            }
-        }
-    }
+#if 1
+    _debug_idles(globals);
 #endif
 
-    dbg_printf("-< Idle: %ld        [%08lx]\n", (long)err, (long)globals);
+    dbg_printf("[OI  ] <   [%08lx] :: Idle()  at: %ld\n", (UInt32) globals, TickCount());
     return err;
 }
 
@@ -1507,7 +1852,7 @@
     if (err == noErr)
         dbg_printf("    SetupDataHandler() succeeded\n");
 
-#if 1
+#if 0
     globals->usingIdle = (globals->dataIsStream
                           && (inFlags & movieImportWithIdle) != 0);
 
@@ -1520,7 +1865,13 @@
     dbg_printf("--> 2: globals->usingIdle: %d\n", globals->usingIdle);
 
     if (globals->usingIdle) {
+        globals->notifyStep = 420; // ~60 ticks per second
+        globals->flushStep = 60;
+#if 1
+        err = JustStartImport(globals, dataRef, dataRefType);
+#else
         err = StartImport(globals, dataRef, dataRefType);
+#endif /* 1 */
         *outFlags |= movieImportResultNeedIdles;
         *durationAdded = 0;
     } else {
@@ -1597,7 +1948,7 @@
     dbg_printf("-- EstimateCompletionTime() called: ratio = %lld\n", ratio);
 
     time->value = SInt64ToWide(ratio);
-    time->scale = 60;
+    time->scale = 60; // roughly TickCount()'s resolution
     time->base  = NULL;   // this time record is a duration
 
     return noErr;
@@ -1634,7 +1985,8 @@
         {
             globals->dataIdleManager = QTIdleManagerOpen();
             if (globals->dataIdleManager != NULL) {
-                err = DataHSetIdleManager(globals->dataReader, im);
+                //err = DataHSetIdleManager(globals->dataReader, im);
+                err = DataHSetIdleManager(globals->dataReader, globals->dataIdleManager);
                 dbg_printf("--  -- SetIdleManager(dataReader) = %ld\n", (long)err);
                 if (err != noErr) {
                     QTIdleManagerClose(globals->dataIdleManager);

Modified: trunk/xiph-qt/OggImport/src/importer_types.h
===================================================================
--- trunk/xiph-qt/OggImport/src/importer_types.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/importer_types.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -4,7 +4,7 @@
  *    Definitions of OggImporter data structures.
  *
  *
- *  Copyright (c) 2005-2006  Arek Korbik
+ *  Copyright (c) 2005-2007  Arek Korbik
  *
  *  This file is part of XiphQT, the Xiph QuickTime Components.
  *
@@ -108,6 +108,13 @@
     TimeValue           mediaLength;
     TimeValue           insertTime;
 
+    //SampleReference array
+    SampleReference64Record *sample_refs;
+    UInt32              sample_refs_size;
+    UInt32              sample_refs_count;
+    TimeValue           sample_refs_duration;
+    UInt32              sample_refs_increment;
+
     TimeValue           streamOffset;
     SInt32              streamOffsetSamples;
 
@@ -196,9 +203,14 @@
     TimeValue               timeLoaded;
     Float64                 timeLoadedSubSecond;        // last second fraction remainder
 
+    UInt32                  tickFlushed;
+    UInt32                  flushStep;
+    UInt32                  tickNotified;
+    UInt32                  notifyStep;
+
     unsigned long           startTickCount;
 
-    //    Track                   ghostTrack;
+    Track                   phTrack; /**< placeholder track for async importing */
 
     int                     streamCount;
     StreamInfo              **streamInfoHandle;
@@ -206,6 +218,12 @@
     Boolean					dataRequested;
     Boolean					sizeInitialised;
 
+    long                lp_serialno;
+    ogg_int64_t         lp_GP;
+    TimeValue           totalTime;
+    Boolean             calcTotalTime;
+
+    TimeBase            idleTimeBase;
 } OggImportGlobals, *OggImportGlobalsPtr;
 
 
@@ -220,9 +238,11 @@
 
 typedef int (*process_first_packet) (StreamInfo *si, ogg_page *op, ogg_packet *opckt);
 typedef ComponentResult (*process_stream_page) (OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
-typedef ComponentResult (*finish_stream) (OggImportGlobals *globals, StreamInfo *si);
+typedef ComponentResult (*flush_stream) (OggImportGlobals *globals, StreamInfo *si, Boolean notify);
 
+typedef ComponentResult (*granulepos_to_time) (StreamInfo *si, ogg_int64_t *gp, TimeRecord *time);
 
+
 typedef struct stream_format_handle_funcs {
     process_stream_page                 process_page;
 
@@ -235,10 +255,12 @@
     create_track_media                  track_media;
 
     initialize_stream                   initialize;
-    finish_stream                       finish;
+    flush_stream                        flush;
     clear_stream                        clear;
+
+    granulepos_to_time                  gp_to_time;
 } stream_format_handle_funcs;
 
-#define HANDLE_FUNCTIONS__NULL { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
+#define HANDLE_FUNCTIONS__NULL { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
 
 #endif /* __importer_types_h__ */

Added: trunk/xiph-qt/OggImport/src/samplerefs.c
===================================================================
--- trunk/xiph-qt/OggImport/src/samplerefs.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/samplerefs.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -0,0 +1,126 @@
+/*
+ *  samplerefs.c
+ *
+ *    SampleReference arrays handling utilities.
+ *
+ *
+ *  Copyright (c) 2007  Arek Korbik
+ *
+ *  This file is part of XiphQT, the Xiph QuickTime Components.
+ *
+ *  XiphQT is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  XiphQT is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with XiphQT; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ *  Last modified: $Id$
+ *
+ */
+
+
+#include "samplerefs.h"
+#include "debug.h"
+
+ComponentResult _store_sample_reference(StreamInfo *si, SInt64 *dataOffset, int size, TimeValue duration, short smp_flags)
+{
+    ComponentResult err = noErr;
+    SampleReference64Record *srptr = NULL;
+
+    if (si->sample_refs_count >= si->sample_refs_size) {
+        //resize the sample_refs array
+        si->sample_refs_size += si->sample_refs_increment;
+        srptr = realloc(si->sample_refs, si->sample_refs_size * sizeof(SampleReference64Record));
+        if (srptr == NULL)
+            err = MemError();
+        else
+            si->sample_refs = srptr;
+    }
+
+    if (!err) {
+        srptr = &si->sample_refs[si->sample_refs_count];
+        memset(srptr, 0, sizeof(SampleReference64Record));
+        srptr->dataOffset = SInt64ToWide(*dataOffset);
+        srptr->dataSize = size;
+        srptr->durationPerSample = duration;
+        srptr->numberOfSamples = 1;
+        srptr->sampleFlags = smp_flags;
+
+        dbg_printf("[OIsr]  ++ _store_sample_reference() sampleRef: %lld, len: %d, dur: %d [%08lx, %08lx]\n", *dataOffset, size, duration,
+                   (UInt32) si->sample_refs, (UInt32) srptr);
+
+        si->sample_refs_count += 1;
+        si->sample_refs_duration += duration;
+    }
+
+    return err;
+}
+
+ComponentResult _commit_srefs(OggImportGlobals *globals, StreamInfo *si, Boolean *movie_changed)
+{
+    ComponentResult err = noErr;
+    TimeValue inserted  = 0;
+
+    TimeValue movieTS = GetMovieTimeScale(globals->theMovie);
+    TimeValue mediaTS = 0;
+    Float64 mediaTS_fl = 0.0;
+
+    if (si->sample_refs_count < 1) {
+        *movie_changed = false;
+        return err;
+    }
+
+    dbg_printf("[OIsr]  +> _commit_srefs() sampleRefs: %lld, count: %ld, dur: %ld\n", globals->dataOffset, si->sample_refs_count,
+               si->sample_refs_duration);
+    err = AddMediaSampleReferences64(si->theMedia, si->sampleDesc, si->sample_refs_count, si->sample_refs, &inserted);
+
+
+    if (!err) {
+        TimeValue timeLoaded;
+        Float64 timeLoadedSubSecond;
+
+        si->mediaLength += si->sample_refs_duration;
+
+        err = InsertMediaIntoTrack(si->theTrack, si->insertTime, inserted,
+                                   si->sample_refs_duration, fixed1);
+        if (si->insertTime == 0) {
+            if (si->streamOffset != 0) {
+                SetTrackOffset(si->theTrack, si->streamOffset);
+                dbg_printf("   # -- SetTrackOffset(%ld) = %ld --> %ld\n",
+                           si->streamOffset, GetMoviesError(),
+                           GetTrackOffset(si->theTrack));
+                if (globals->dataIsStream) {
+                    SetTrackEnabled(si->theTrack, false);
+                    SetTrackEnabled(si->theTrack, true);
+                }
+            }
+        }
+        si->insertTime = -1;
+
+        mediaTS = GetMediaTimeScale(si->theMedia);
+        mediaTS_fl = (Float64) mediaTS;
+        timeLoaded = si->streamOffset + si->mediaLength / mediaTS * movieTS + (si->mediaLength % mediaTS) * movieTS / mediaTS;
+        timeLoadedSubSecond = (Float64) ((si->streamOffset % movieTS * mediaTS / movieTS + si->mediaLength) % mediaTS) / mediaTS_fl;
+
+        if (globals->timeLoaded < timeLoaded || (globals->timeLoaded == timeLoaded && globals->timeLoadedSubSecond < timeLoadedSubSecond)) {
+            globals->timeLoaded = timeLoaded;
+            globals->timeLoadedSubSecond = timeLoadedSubSecond;
+        }
+
+        *movie_changed = true;
+
+        si->sample_refs_duration = 0;
+        si->sample_refs_count = 0;
+    }
+
+    return err;
+}


Property changes on: trunk/xiph-qt/OggImport/src/samplerefs.c
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/xiph-qt/OggImport/src/samplerefs.h
===================================================================
--- trunk/xiph-qt/OggImport/src/samplerefs.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/samplerefs.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -0,0 +1,41 @@
+/*
+ *  samplerefs.h
+ *
+ *    SampleReference arrays handling utilities header file.
+ *
+ *
+ *  Copyright (c) 2007  Arek Korbik
+ *
+ *  This file is part of XiphQT, the Xiph QuickTime Components.
+ *
+ *  XiphQT is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  XiphQT is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with XiphQT; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ *  Last modified: $Id$
+ *
+ */
+
+
+#if !defined(__samplerefs_h__)
+#define __samplerefs_h__
+
+#include "importer_types.h"
+
+
+extern ComponentResult _store_sample_reference(StreamInfo *si, SInt64 *dataOffset, int size, TimeValue duration, short smp_flags);
+extern ComponentResult _commit_srefs(OggImportGlobals *globals, StreamInfo *si, Boolean *movie_changed);
+
+
+#endif /* __samplerefs_h__ */


Property changes on: trunk/xiph-qt/OggImport/src/samplerefs.h
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/xiph-qt/OggImport/src/stream_flac.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_flac.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_flac.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -41,64 +41,9 @@
 #include "data_types.h"
 #include "utils.h"
 
-static ComponentResult _commit_srefs(OggImportGlobals *globals, StreamInfo *si, Boolean *movie_changed)
-{
-    ComponentResult ret = noErr;
-    TimeValue inserted  = 0;
+#include "samplerefs.h"
 
-    TimeValue movieTS = GetMovieTimeScale(globals->theMovie);
-    TimeValue mediaTS = 0;
-    TimeValue mediaTS_fl = 0.0;
 
-    if (si->si_flac.sample_refs_count < 1)
-        return ret;
-
-    dbg_printf("   -   :++: adding sampleRefs: %lld, count: %ld, dur: %ld\n", globals->dataOffset, si->si_flac.sample_refs_count,
-               si->si_flac.sample_refs_duration);
-    ret = AddMediaSampleReferences64(si->theMedia, si->sampleDesc, si->si_flac.sample_refs_count, si->si_flac.sample_refs, &inserted);
-
-    if (ret == noErr) {
-        TimeValue timeLoaded;
-        Float64 timeLoadedSubSecond;
-
-        si->mediaLength += si->si_flac.sample_refs_duration;
-
-        ret = InsertMediaIntoTrack(si->theTrack, si->insertTime, inserted,
-                                   si->si_flac.sample_refs_duration, fixed1);
-        if (si->insertTime == 0) {
-            if (si->streamOffset != 0) {
-                SetTrackOffset(si->theTrack, si->streamOffset);
-                dbg_printf("   # -- SetTrackOffset(%ld) = %ld --> %ld\n",
-                           si->streamOffset, GetMoviesError(),
-                           GetTrackOffset(si->theTrack));
-                if (globals->dataIsStream) {
-                    SetTrackEnabled(si->theTrack, false);
-                    SetTrackEnabled(si->theTrack, true);
-                }
-            }
-        }
-        si->insertTime = -1;
-
-        mediaTS = GetMediaTimeScale(si->theMedia);
-        mediaTS_fl = (Float64) mediaTS;
-        timeLoaded = si->streamOffset + si->mediaLength / mediaTS * movieTS + (si->mediaLength % mediaTS) * movieTS / mediaTS;
-        timeLoadedSubSecond = (Float64) ((si->streamOffset % movieTS * mediaTS / movieTS + si->mediaLength) % mediaTS) / mediaTS_fl;
-
-        if (globals->timeLoaded < timeLoaded || (globals->timeLoaded == timeLoaded && globals->timeLoadedSubSecond < timeLoadedSubSecond)) {
-            globals->timeLoaded = timeLoaded;
-            globals->timeLoadedSubSecond = timeLoadedSubSecond;
-        }
-
-        *movie_changed = true;
-
-        si->si_flac.sample_refs_duration = 0;
-        si->si_flac.sample_refs_count = 0;
-    }
-
-    return ret;
-};
-
-
 int recognize_header__flac(ogg_page *op)
 {
     char fh[] = {0x7f, 'F', 'L', 'A', 'C', '\0'};
@@ -124,27 +69,28 @@
 
 int initialize_stream__flac(StreamInfo *si)
 {
+    si->sample_refs_count = 0;
+    si->sample_refs_duration = 0;
+    si->sample_refs_size = kFSRefsInitial;
+    si->sample_refs_increment = kFSRefsIncrement;
+    si->sample_refs = calloc(si->sample_refs_size, sizeof(SampleReference64Record));
+
+    if (si->sample_refs == NULL)
+        return -1;
+
     vorbis_comment_init(&si->si_flac.vc);
 
     si->si_flac.metablocks = 0;
     si->si_flac.skipped = 0;
     si->si_flac.state = kFStateInitial;
 
-    si->si_flac.sample_refs_count = 0;
-    si->si_flac.sample_refs_duration = 0;
-    si->si_flac.sample_refs_size = kSRefsInitial;
-    si->si_flac.sample_refs = calloc(si->si_flac.sample_refs_size, sizeof(SampleReference64Record));
-
-    if (si->si_flac.sample_refs == NULL)
-        return -1;
-
     return 0;
 };
 
 void clear_stream__flac(StreamInfo *si)
 {
-    if (si->si_flac.sample_refs != NULL)
-        free(si->si_flac.sample_refs);
+    if (si->sample_refs != NULL)
+        free(si->sample_refs);
 
     vorbis_comment_clear(&si->si_flac.vc);
 };
@@ -402,38 +348,20 @@
                     duration += si->streamOffsetSamples;
                 }
 
-                
-                if (si->si_flac.sample_refs_count >= si->si_flac.sample_refs_size) {
-                    //resize the sample_refs array
-                    SampleReference64Record *srptr = NULL;
-                    si->si_flac.sample_refs_size += kSRefsIncrement;
-                    srptr = realloc(si->si_flac.sample_refs, si->si_flac.sample_refs_size * sizeof(SampleReference64Record));
-                    //if (srptr == NULL)
-                    //    ; // signal error here
-                    si->si_flac.sample_refs = srptr;
+                ret = _store_sample_reference(si, &globals->dataOffset, len, duration, smp_flags);
+                if (ret != noErr) {
+                    loop = false;
+                    break;
                 }
 
-                {
-                    SampleReference64Record *srptr = &si->si_flac.sample_refs[si->si_flac.sample_refs_count];
-                    memset(srptr, 0, sizeof(SampleReference64Record));
-                    srptr->dataOffset = SInt64ToWide(globals->dataOffset);
-                    srptr->dataSize = len;
-                    srptr->durationPerSample = duration;
-                    srptr->numberOfSamples = 1;
-                    srptr->sampleFlags = smp_flags;
-
-                    dbg_printf("   -   :++: storing sampleRef: %lld, len: %d, dur: %d [%08lx, %08lx]\n", globals->dataOffset, len, duration,
-                               (UInt32) si->si_flac.sample_refs, (UInt32) srptr);
-                    si->si_flac.sample_refs_count += 1;
-                    si->si_flac.sample_refs_duration += duration;
-                }
-
-                // change the condition...?
+                if (!globals->usingIdle) {
 #if !defined(XIPHQT_FORCE_SINGLE_SAMPLE_REF)
-                if (si->si_flac.sample_refs_count >= si->si_flac.sample_refs_size)
+                    if (si->sample_refs_count >= si->sample_refs_size)
+                    //if (si->sample_refs_count >= kFSRefsInitial)
 #endif
-                {
-                    ret = _commit_srefs(globals, si, &movie_changed);
+                    {
+                        ret = _commit_srefs(globals, si, &movie_changed);
+                    }
                 }
 
                 if (pos != -1)
@@ -448,20 +376,20 @@
     } while(loop);
 
     if (movie_changed)
-        NotifyMovieChanged(globals);
+        NotifyMovieChanged(globals, false);
 
     return ret;
 };
 
-ComponentResult finish_stream__flac(OggImportGlobals *globals, StreamInfo *si)
+ComponentResult flush_stream__flac(OggImportGlobals *globals, StreamInfo *si, Boolean notify)
 {
     ComponentResult ret = noErr;
     Boolean movie_changed = false;
 
     ret = _commit_srefs(globals, si, &movie_changed);
 
-    if (movie_changed)
-        NotifyMovieChanged(globals);
+    if (movie_changed && notify)
+        NotifyMovieChanged(globals, true);
 
     return ret;
 };

Modified: trunk/xiph-qt/OggImport/src/stream_flac.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_flac.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_flac.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -47,11 +47,11 @@
 
 extern int process_first_packet__flac(StreamInfo *si, ogg_page *op, ogg_packet *opckt);
 extern ComponentResult process_stream_page__flac(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
-extern ComponentResult finish_stream__flac(OggImportGlobals *globals, StreamInfo *si);
+extern ComponentResult flush_stream__flac(OggImportGlobals *globals, StreamInfo *si, Boolean notify);
 
 #define HANDLE_FUNCTIONS__FLAC { &process_stream_page__flac, &recognize_header__flac, \
             &verify_header__flac, &process_first_packet__flac, &create_sample_description__flac, \
-            NULL, NULL, &initialize_stream__flac, &finish_stream__flac, &clear_stream__flac }
+            NULL, NULL, &initialize_stream__flac, &flush_stream__flac, &clear_stream__flac, NULL }
 
 
 #endif /* __stream_flac_h__ */

Modified: trunk/xiph-qt/OggImport/src/stream_speex.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_speex.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_speex.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -41,6 +41,9 @@
 #include "data_types.h"
 #include "utils.h"
 
+#include "samplerefs.h"
+
+
 int recognize_header__speex(ogg_page *op)
 {
     if (!strncmp("Speex   ", (char *)op->body, 8))
@@ -56,6 +59,15 @@
 
 int initialize_stream__speex(StreamInfo *si)
 {
+    si->sample_refs_count = 0;
+    si->sample_refs_duration = 0;
+    si->sample_refs_size = kSSRefsInitial;
+    si->sample_refs_increment = kSSRefsIncrement;
+    si->sample_refs = calloc(si->sample_refs_size, sizeof(SampleReference64Record));
+
+    if (si->sample_refs == NULL)
+        return -1;
+
     memset(&si->si_speex.header, 0, sizeof(SpeexHeader));
     vorbis_comment_init(&si->si_speex.vc);
 
@@ -67,6 +79,9 @@
 
 void clear_stream__speex(StreamInfo *si)
 {
+    if (si->sample_refs != NULL)
+        free(si->sample_refs);
+
     vorbis_comment_clear(&si->si_speex.vc);
 };
 
@@ -260,7 +275,6 @@
                 ogg_int64_t pos       = ogg_page_granulepos(opg);
                 int         len       = opg->header_len + opg->body_len;
                 TimeValue   duration  = pos - si->lastGranulePos;
-                TimeValue   inserted  = 0;
                 short       smp_flags = 0;
 
                 if (ogg_page_continued(opg) || si->incompleteCompensation != 0)
@@ -284,51 +298,15 @@
                     duration += si->streamOffsetSamples;
                 }
 
-                dbg_printf("   -   :++: adding sampleRef: %lld, len: %d, dur: %d\n", globals->dataOffset, len, duration);
-                ret = AddMediaSampleReference(si->theMedia, S32Set(globals->dataOffset),
-                                              len, duration, si->sampleDesc, 1, smp_flags, &inserted); //@@@@ 64-bit enable
-                if (ret == noErr) {
-                    TimeValue timeLoaded;
-                    Float64 timeLoadedSubSecond;
+                ret = _store_sample_reference(si, &globals->dataOffset, len, duration, smp_flags);
+                if (ret != noErr) {
+                    loop = false;
+                    break;
+                }
 
-                    si->mediaLength += duration;
-
-                    dbg_printf("   -   :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
-                               ogg_page_pageno(opg), inserted,
-                               opg->header_len + opg->body_len, len, !logg_page_last_packet_incomplete(opg));
-                    dbg_printf("   -   :/>: inserting media: %ld, mt: %lld, dur: %d\n", si->insertTime, si->lastGranulePos, duration);
-                    ret = InsertMediaIntoTrack(si->theTrack, si->insertTime /*inserted*/, /* si->lastGranulePos */ inserted,
-                                               duration, fixed1);
-                    if (si->insertTime == 0) {
-                        if (si->streamOffset != 0) {
-                            SetTrackOffset(si->theTrack, si->streamOffset);
-                            dbg_printf("   # -- SetTrackOffset(%ld) = %ld --> %ld\n",
-                                       si->streamOffset, GetMoviesError(),
-                                       GetTrackOffset(si->theTrack));
-                            if (globals->dataIsStream) {
-                                SetTrackEnabled(si->theTrack, false);
-                                SetTrackEnabled(si->theTrack, true);
-                            }
-                        }
-                    }
-                    si->insertTime = -1;
-
-                    mediaTS = GetMediaTimeScale(si->theMedia);
-                    mediaTS_fl = (Float64) mediaTS;
-                    timeLoaded = si->streamOffset + si->mediaLength / mediaTS * movieTS + (si->mediaLength % mediaTS) * movieTS / mediaTS;
-                    timeLoadedSubSecond = (Float64) ((si->streamOffset % movieTS * mediaTS / movieTS + si->mediaLength) % mediaTS) / mediaTS_fl;
-
-                    dbg_printf("   -   :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld(%lg); %ld; ml: %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
-                               ogg_page_pageno(opg), inserted,
-                               GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), timeLoaded, timeLoadedSubSecond,
-                               (duration * movieTS) / mediaTS, si->mediaLength,
-                               mediaTS, movieTS, ret);
-                    if (globals->timeLoaded < timeLoaded || (globals->timeLoaded == timeLoaded && globals->timeLoadedSubSecond < timeLoadedSubSecond)) {
-                        globals->timeLoaded = timeLoaded;
-                        globals->timeLoadedSubSecond = timeLoadedSubSecond;
-                    }
-
-                    movie_changed = true;
+                if (!globals->usingIdle) {
+                    if (si->sample_refs_count >= kSSRefsInitial)
+                        ret = _commit_srefs(globals, si, &movie_changed);
                 }
 
                 if (pos != -1)
@@ -343,7 +321,21 @@
     } while(loop);
 
     if (movie_changed)
-        NotifyMovieChanged(globals);
+        NotifyMovieChanged(globals, false);
 
     return ret;
 };
+
+
+ComponentResult flush_stream__speex(OggImportGlobals *globals, StreamInfo *si, Boolean notify)
+{
+    ComponentResult ret = noErr;
+    Boolean movie_changed = false;
+
+    ret = _commit_srefs(globals, si, &movie_changed);
+
+    if (movie_changed && notify)
+        NotifyMovieChanged(globals, true);
+
+    return ret;
+};

Modified: trunk/xiph-qt/OggImport/src/stream_speex.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_speex.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_speex.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -45,10 +45,11 @@
 
 extern int process_first_packet__speex(StreamInfo *si, ogg_page *op, ogg_packet *opckt);
 extern ComponentResult process_stream_page__speex(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
+extern ComponentResult flush_stream__speex(OggImportGlobals *globals, StreamInfo *si, Boolean notify);
 
 #define HANDLE_FUNCTIONS__SPEEX { &process_stream_page__speex, &recognize_header__speex, \
             &verify_header__speex, &process_first_packet__speex, &create_sample_description__speex, \
-            NULL, NULL, &initialize_stream__speex, NULL, &clear_stream__speex }
+            NULL, NULL, &initialize_stream__speex, &flush_stream__speex, &clear_stream__speex, NULL }
 
 
 #endif /* __stream_vorbis_h__ */

Modified: trunk/xiph-qt/OggImport/src/stream_theora.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_theora.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_theora.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -43,7 +43,9 @@
 #include "fccs.h"
 #include "data_types.h"
 
+#include "samplerefs.h"
 
+
 #define MAX_FPS_DENOMINATOR 198
 #define DESIRED_MULTIPLIER 197
 #define SEGMENT_RATIO_DENOM 3
@@ -81,7 +83,6 @@
     return a;
 }
 
-
 int recognize_header__theora(ogg_page *op)
 {
     dbg_printf("! -- - theora_recognise_header: '%4.4s'\n", ((char *)op->body) + 1);
@@ -128,6 +129,15 @@
 
 int initialize_stream__theora(StreamInfo *si)
 {
+    si->sample_refs_count = 0;
+    si->sample_refs_duration = 0;
+    si->sample_refs_size = kTSRefsInitial;
+    si->sample_refs_increment = kTSRefsIncrement;
+    si->sample_refs = calloc(si->sample_refs_size, sizeof(SampleReference64Record));
+
+    if (si->sample_refs == NULL)
+        return -1;
+
     th_info_init(&si->si_theora.ti);
     th_comment_init(&si->si_theora.tc);
     si->si_theora.ts = NULL;
@@ -140,6 +150,7 @@
     si->si_theora.lpkt_flags = 0;
 
     si->si_theora.psegment_ratio = SEGMENT_RATIO_DENOM;
+
     return 0;
 };
 
@@ -149,6 +160,9 @@
         th_setup_free(si->si_theora.ts);
     th_info_clear(&si->si_theora.ti);
     th_comment_clear(&si->si_theora.tc);
+
+    if (si->sample_refs != NULL)
+        free(si->sample_refs);
 };
 
 ComponentResult create_sample_description__theora(StreamInfo *si)
@@ -356,37 +370,20 @@
         case kTStateReadingPackets:
             {
                 ogg_int64_t pos       = ogg_page_granulepos(opg);
-                int         len       = opg->header_len + opg->body_len;
-                TimeValue   duration  = 0;
-                TimeValue   inserted  = -1;
                 short       smp_flags = 0;
 
-                int packet_count = 0;
                 long psize = 0, poffset = 0;
                 int i, segments;
                 Boolean continued = ogg_page_continued(opg);
-                SampleReference64Record sampleRec;
-                SInt64 tmp = 0;
+                TimeValue durationPerSample = 0;
                 ogg_int64_t last_packet_pos = si->lastGranulePos >> si->si_theora.granulepos_shift;
                 last_packet_pos += si->lastGranulePos - (last_packet_pos << si->si_theora.granulepos_shift);
 
-#if 0
-                if (ogg_page_continued(opg) || si->incompleteCompensation != 0)
-                    smp_flags |= mediaSampleNotSync;
-
-                if (duration <= 0) {
-                    duration = INCOMPLETE_PAGE_DURATION;
-                    si->incompleteCompensation -= INCOMPLETE_PAGE_DURATION;
-                } else if (si->incompleteCompensation != 0) {
-                    duration += si->incompleteCompensation;
-                    si->incompleteCompensation = 0;
-                    if (duration <= 0) {
-                        ret = badFileFormat;
-                        loop = false;
-                        break;
-                    }
+                loop = false;
+                if (ovret < 0) {
+                    ret = invalidMedia;
+                    break;
                 }
-#endif /* 0 */
 
                 if (continued)
                     smp_flags |= mediaSampleNotSync;
@@ -407,39 +404,31 @@
 
                         if (si->si_theora.lpkt_data_size != 0) {
                             /* add last packet to media */
-                            memset(&sampleRec, 0, sizeof(sampleRec));
-                            sampleRec.dataOffset = SInt64ToWide(si->si_theora.lpkt_data_offset);
-                            sampleRec.dataSize = si->si_theora.lpkt_data_size;
-                            sampleRec.sampleFlags = si->si_theora.lpkt_flags;
-                            sampleRec.numberOfSamples = 1;
+                            durationPerSample = 0;
                             if (!incomplete) {
                                 /* packet finishes here */
                                 if (si->si_theora.lpkt_duration > 0) {
-                                    sampleRec.durationPerSample = si->si_theora.lpkt_duration;
+                                    durationPerSample = si->si_theora.lpkt_duration;
                                 } else {
-                                    sampleRec.durationPerSample = 1;
+                                    durationPerSample = 1;
                                     pduration += si->si_theora.lpkt_duration - 1;
                                 }
                             } else {
                                 /* segmented packet */
                                 if (si->si_theora.lpkt_duration > 0) {
-                                    sampleRec.durationPerSample = si->si_theora.lpkt_duration / si->si_theora.psegment_ratio;
-                                    if (sampleRec.durationPerSample == 0)
-                                        sampleRec.durationPerSample = 1;
-                                    pduration = si->si_theora.lpkt_duration - sampleRec.durationPerSample;
+                                    durationPerSample = si->si_theora.lpkt_duration / si->si_theora.psegment_ratio;
+                                    if (durationPerSample == 0)
+                                        durationPerSample = 1;
+                                    pduration = si->si_theora.lpkt_duration - durationPerSample;
                                 } else {
-                                    sampleRec.durationPerSample = 1;
-                                    pduration = si->si_theora.lpkt_duration - 1 /* sampleRec.durationPerSample */;
+                                    durationPerSample = 1;
+                                    pduration = si->si_theora.lpkt_duration - 1 /* durationPerSample */;
                                 }
                             }
-                            dbg_printf("   T   :++: adding sampleRef: %8lld, len: %8d, dur: %8d, fl: %08x\n",
-                                       sampleRec.dataOffset, sampleRec.dataSize, sampleRec.durationPerSample, sampleRec.sampleFlags);
-                            ret = AddMediaSampleReferences64(si->theMedia, si->sampleDesc, 1, &sampleRec, inserted == -1 ? &inserted : NULL);
+                            ret = _store_sample_reference(si, &si->si_theora.lpkt_data_offset, si->si_theora.lpkt_data_size,
+                                                          durationPerSample, si->si_theora.lpkt_flags);
                             if (ret != noErr)
                                 break;
-
-                            duration += sampleRec.durationPerSample;
-                            packet_count += 1;
                         } else if (si->streamOffsetSamples > 0) {
                             /* first packet (and stream has a sample offset) */
                             dbg_printf("   -   :++: increasing duration (%ld) by sampleOffset: %ld\n", pduration, si->streamOffsetSamples);
@@ -459,82 +448,28 @@
                     }
                 }
 
-                loop = false;
-                if (ovret < 0) {
-                    ret = invalidMedia;
-                    break;
-                }
-
                 if (ret == noErr && si->si_theora.lpkt_data_size != 0 && ogg_page_eos(opg)) {
                     /* it's EOS here, flush */
-                    memset(&sampleRec, 0, sizeof(sampleRec));
-                    sampleRec.dataOffset = SInt64ToWide(si->si_theora.lpkt_data_offset);
-                    sampleRec.dataSize = si->si_theora.lpkt_data_size;
-                    sampleRec.sampleFlags = si->si_theora.lpkt_flags;
-                    sampleRec.numberOfSamples = 1;
+                    durationPerSample = 0;
 
                     /* this the last page of the stream, packet SHOULD finish here */
                     if (si->si_theora.lpkt_duration > 0) {
-                        sampleRec.durationPerSample = si->si_theora.lpkt_duration;
+                        durationPerSample = si->si_theora.lpkt_duration;
                     } else {
-                        sampleRec.durationPerSample = 1;
+                        durationPerSample = 1;
                     }
 
-                    dbg_printf("   T   :++: adding sampleRef! %8lld, len: %8d, dur: %8d, fl: %08x\n",
-                               sampleRec.dataOffset, sampleRec.dataSize, sampleRec.durationPerSample, sampleRec.sampleFlags);
-                    ret = AddMediaSampleReferences64(si->theMedia, si->sampleDesc, 1, &sampleRec, inserted == -1 ? &inserted : NULL);
+                    ret = _store_sample_reference(si, &si->si_theora.lpkt_data_offset, si->si_theora.lpkt_data_size,
+                                                  durationPerSample, si->si_theora.lpkt_flags);
                     if (ret != noErr)
                         break;
-
-                    duration += sampleRec.durationPerSample;
-                    packet_count += 1;
                 }
 
-                
-                if (ret == noErr && packet_count > 0) {
-                    TimeValue timeLoaded;
-                    Float64 timeLoadedSubSecond;
-
-                    si->mediaLength += duration;
-
-                    dbg_printf("   -   :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
-                               ogg_page_pageno(opg), inserted,
-                               opg->body_len, len, !logg_page_last_packet_incomplete(opg));
-                    dbg_printf("   -   :/>: inserting media: %ld, mt: %ld, dur: %ld\n", si->insertTime, inserted, duration);
-                    ret = InsertMediaIntoTrack(si->theTrack, si->insertTime /*inserted*/, /* si->lastGranulePos */ inserted,
-                                               duration, fixed1);
-                    if (si->insertTime == 0) {
-                        if (si->streamOffset != 0) {
-                            SetTrackOffset(si->theTrack, si->streamOffset);
-                            dbg_printf("   # -- SetTrackOffset(%ld) = %ld --> %ld\n",
-                                       si->streamOffset, GetMoviesError(),
-                                       GetTrackOffset(si->theTrack));
-                            if (globals->dataIsStream) {
-                                SetTrackEnabled(si->theTrack, false);
-                                SetTrackEnabled(si->theTrack, true);
-                            }
-                        }
-                    }
-                    si->insertTime = -1;
-
-                    mediaTS = GetMediaTimeScale(si->theMedia);
-                    mediaTS_fl = (Float64) mediaTS;
-                    timeLoaded = si->streamOffset + si->mediaLength / mediaTS * movieTS + (si->mediaLength % mediaTS) * movieTS / mediaTS;
-                    timeLoadedSubSecond = (Float64) ((si->streamOffset % movieTS * mediaTS / movieTS + si->mediaLength) % mediaTS) / mediaTS_fl;
-
-                    dbg_printf("   -   :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld(%lg); %ld; ml: %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
-                               ogg_page_pageno(opg), inserted,
-                               GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), timeLoaded, timeLoadedSubSecond,
-                               (duration * movieTS) / mediaTS, si->mediaLength,
-                               mediaTS, movieTS, ret);
-                    if (globals->timeLoaded < timeLoaded || (globals->timeLoaded == timeLoaded && globals->timeLoadedSubSecond < timeLoadedSubSecond)) {
-                        globals->timeLoaded = timeLoaded;
-                        globals->timeLoadedSubSecond = timeLoadedSubSecond;
-                    }
-
-                    movie_changed = true;
+                if (!globals->usingIdle) {
+                    if (si->sample_refs_count >= kTSRefsInitial)
+                        ret = _commit_srefs(globals, si, &movie_changed);
                 }
-                
+
                 if (pos != -1)
                     si->lastGranulePos = pos;
             }
@@ -547,7 +482,34 @@
     } while(loop);
 
     if (movie_changed)
-        NotifyMovieChanged(globals);
+        NotifyMovieChanged(globals, false);
 
     return ret;
 };
+
+ComponentResult flush_stream__theora(OggImportGlobals *globals, StreamInfo *si, Boolean notify)
+{
+    ComponentResult err = noErr;
+    Boolean movie_changed = false;
+
+    err = _commit_srefs(globals, si, &movie_changed);
+
+    if (movie_changed && notify)
+        NotifyMovieChanged(globals, true);
+
+    return err;
+};
+
+ComponentResult granulepos_to_time__theora(StreamInfo *si, ogg_int64_t *gp, TimeRecord *time)
+{
+    ComponentResult err = noErr;
+
+    ogg_int64_t frames = *gp >> si->si_theora.granulepos_shift;
+    frames += *gp - (frames << si->si_theora.granulepos_shift);
+
+    time->value = SInt64ToWide(frames);
+    time->scale = si->rate;
+    time->base = NULL;
+
+    return err;
+};

Modified: trunk/xiph-qt/OggImport/src/stream_theora.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_theora.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_theora.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -48,10 +48,14 @@
 
 extern int process_first_packet__theora(StreamInfo *si, ogg_page *op, ogg_packet *opckt);
 extern ComponentResult process_stream_page__theora(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
+extern ComponentResult flush_stream__theora(OggImportGlobals *globals, StreamInfo *si, Boolean notify);
 
+extern ComponentResult granulepos_to_time__theora(StreamInfo *si, ogg_int64_t *gp, TimeRecord *time);
+
 #define HANDLE_FUNCTIONS__THEORA { &process_stream_page__theora, &recognize_header__theora, \
             &verify_header__theora, &process_first_packet__theora, &create_sample_description__theora, \
-            &create_track__theora, &create_track_media__theora, &initialize_stream__theora, NULL, &clear_stream__theora }
+            &create_track__theora, &create_track_media__theora, &initialize_stream__theora, flush_stream__theora, \
+            &clear_stream__theora, &granulepos_to_time__theora }
 
 
 #endif /* __stream_theora_h__ */

Modified: trunk/xiph-qt/OggImport/src/stream_types_flac.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_types_flac.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_types_flac.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -44,8 +44,8 @@
 } FLACImportStates;
 
 enum {
-    kSRefsInitial = 4096,
-    kSRefsIncrement = 4096
+    kFSRefsInitial = 4096,
+    kFSRefsIncrement = 4096
 };
 
 typedef struct {
@@ -56,12 +56,6 @@
     SInt32 metablocks;
     SInt32 skipped;
     UInt32 bps;
-
-    //SampleReference array
-    SampleReference64Record *sample_refs;
-    UInt32 sample_refs_size;
-    UInt32 sample_refs_count;
-    TimeValue sample_refs_duration;
 } StreamInfo__flac;
 
 

Modified: trunk/xiph-qt/OggImport/src/stream_types_speex.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_types_speex.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_types_speex.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -45,6 +45,11 @@
     kSStateReadingPackets
 } SpeexImportStates;
 
+enum {
+    kSSRefsInitial = 2048,
+    kSSRefsIncrement = 2048
+};
+
 typedef struct {
     SpeexImportStates state;
 

Modified: trunk/xiph-qt/OggImport/src/stream_types_theora.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_types_theora.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_types_theora.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -48,6 +48,11 @@
     kTStateReadingPackets
 } TheoraImportStates;
 
+enum {
+    kTSRefsInitial = 8192,
+    kTSRefsIncrement = 4096
+};
+
 typedef struct {
     TheoraImportStates state;
 

Modified: trunk/xiph-qt/OggImport/src/stream_types_vorbis.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_types_vorbis.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_types_vorbis.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -44,6 +44,11 @@
     kVStateReadingPackets
 } VorbisImportStates;
 
+enum {
+    kVSRefsInitial = 2048,
+    kVSRefsIncrement = 2048
+};
+
 typedef struct {
     VorbisImportStates state;
 

Modified: trunk/xiph-qt/OggImport/src/stream_vorbis.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_vorbis.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_vorbis.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -38,7 +38,9 @@
 #include "fccs.h"
 #include "data_types.h"
 
+#include "samplerefs.h"
 
+
 int recognize_header__vorbis(ogg_page *op)
 {
     if (!strncmp("\1vorbis", (char *)op->body, 7))
@@ -79,6 +81,15 @@
 
 int initialize_stream__vorbis(StreamInfo *si)
 {
+    si->sample_refs_count = 0;
+    si->sample_refs_duration = 0;
+    si->sample_refs_size = kFSRefsInitial;
+    si->sample_refs_increment = kFSRefsIncrement;
+    si->sample_refs = calloc(si->sample_refs_size, sizeof(SampleReference64Record));
+
+    if (si->sample_refs == NULL)
+        return -1;
+
     vorbis_info_init(&si->si_vorbis.vi);
     vorbis_comment_init(&si->si_vorbis.vc);
 
@@ -89,6 +100,9 @@
 
 void clear_stream__vorbis(StreamInfo *si)
 {
+    if (si->sample_refs != NULL)
+        free(si->sample_refs);
+
     vorbis_info_clear(&si->si_vorbis.vi);
     vorbis_comment_clear(&si->si_vorbis.vc);
 };
@@ -282,7 +296,6 @@
                 ogg_int64_t pos       = ogg_page_granulepos(opg);
                 int         len       = opg->header_len + opg->body_len;
                 TimeValue   duration  = pos - si->lastGranulePos;
-                TimeValue   inserted  = 0;
                 short       smp_flags = 0;
 
                 if (ogg_page_continued(opg) || si->incompleteCompensation != 0)
@@ -306,51 +319,16 @@
                     duration += si->streamOffsetSamples;
                 }
 
-                dbg_printf("   -   :++: adding sampleRef: %lld, len: %d, dur: %d\n", globals->dataOffset, len, duration);
-                ret = AddMediaSampleReference(si->theMedia, S32Set(globals->dataOffset),
-                                              len, duration, si->sampleDesc, 1, smp_flags, &inserted); //@@@@ 64-bit enable
-                if (ret == noErr) {
-                    TimeValue timeLoaded;
-                    Float64 timeLoadedSubSecond;
+                ret = _store_sample_reference(si, &globals->dataOffset, len, duration, smp_flags);
+                if (ret != noErr) {
+                    loop = false;
+                    break;
+                }
 
-                    si->mediaLength += duration;
-
-                    dbg_printf("   -   :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
-                               ogg_page_pageno(opg), inserted,
-                               opg->header_len + opg->body_len, len, !logg_page_last_packet_incomplete(opg));
-                    dbg_printf("   -   :/>: inserting media: %ld, mt: %lld, dur: %d\n", si->insertTime, si->lastGranulePos, duration);
-                    ret = InsertMediaIntoTrack(si->theTrack, si->insertTime /*inserted*/, /* si->lastGranulePos */ inserted,
-                                               duration, fixed1);
-                    if (si->insertTime == 0) {
-                        if (si->streamOffset != 0) {
-                            SetTrackOffset(si->theTrack, si->streamOffset);
-                            dbg_printf("   # -- SetTrackOffset(%ld) = %ld --> %ld\n",
-                                       si->streamOffset, GetMoviesError(),
-                                       GetTrackOffset(si->theTrack));
-                            if (globals->dataIsStream) {
-                                SetTrackEnabled(si->theTrack, false);
-                                SetTrackEnabled(si->theTrack, true);
-                            }
-                        }
-                    }
-                    si->insertTime = -1;
-
-                    mediaTS = GetMediaTimeScale(si->theMedia);
-                    mediaTS_fl = (Float64) mediaTS;
-                    timeLoaded = si->streamOffset + si->mediaLength / mediaTS * movieTS + (si->mediaLength % mediaTS) * movieTS / mediaTS;
-                    timeLoadedSubSecond = (Float64) ((si->streamOffset % movieTS * mediaTS / movieTS + si->mediaLength) % mediaTS) / mediaTS_fl;
-
-                    dbg_printf("   -   :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld(%lg); %ld; ml: %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
-                               ogg_page_pageno(opg), inserted,
-                               GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), timeLoaded, timeLoadedSubSecond,
-                               (duration * movieTS) / mediaTS, si->mediaLength,
-                               mediaTS, movieTS, ret);
-                    if (globals->timeLoaded < timeLoaded || (globals->timeLoaded == timeLoaded && globals->timeLoadedSubSecond < timeLoadedSubSecond)) {
-                        globals->timeLoaded = timeLoaded;
-                        globals->timeLoadedSubSecond = timeLoadedSubSecond;
-                    }
-
-                    movie_changed = true;
+                if (!globals->usingIdle) {
+                    //if (si->sample_refs_count >= si->sample_refs_size)
+                    if (si->sample_refs_count >= kVSRefsInitial)
+                        ret = _commit_srefs(globals, si, &movie_changed);
                 }
 
                 if (pos != -1)
@@ -365,7 +343,20 @@
     } while(loop);
 
     if (movie_changed)
-        NotifyMovieChanged(globals);
+        NotifyMovieChanged(globals, false);
 
     return ret;
 };
+
+ComponentResult flush_stream__vorbis(OggImportGlobals *globals, StreamInfo *si, Boolean notify)
+{
+    ComponentResult ret = noErr;
+    Boolean movie_changed = false;
+
+    ret = _commit_srefs(globals, si, &movie_changed);
+
+    if (movie_changed && notify)
+        NotifyMovieChanged(globals, true);
+
+    return ret;
+};

Modified: trunk/xiph-qt/OggImport/src/stream_vorbis.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_vorbis.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/stream_vorbis.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -45,10 +45,11 @@
 
 extern int process_first_packet__vorbis(StreamInfo *si, ogg_page *op, ogg_packet *opckt);
 extern ComponentResult process_stream_page__vorbis(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
+extern ComponentResult flush_stream__vorbis(OggImportGlobals *globals, StreamInfo *si, Boolean notify);
 
 #define HANDLE_FUNCTIONS__VORBIS { &process_stream_page__vorbis, &recognize_header__vorbis, \
             &verify_header__vorbis, &process_first_packet__vorbis, &create_sample_description__vorbis, \
-            NULL, NULL, &initialize_stream__vorbis, NULL, &clear_stream__vorbis }
+            NULL, NULL, &initialize_stream__vorbis, &flush_stream__vorbis, &clear_stream__vorbis, NULL }
 
 
 #endif /* __stream_vorbis_h__ */

Modified: trunk/xiph-qt/OggImport/src/utils.c
===================================================================
--- trunk/xiph-qt/OggImport/src/utils.c	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/utils.c	2007-03-14 03:51:23 UTC (rev 12754)
@@ -4,7 +4,7 @@
  *    Small support functions for ogg processing.
  *
  *
- *  Copyright (c) 2006  Arek Korbik
+ *  Copyright (c) 2006,2007  Arek Korbik
  *
  *  This file is part of XiphQT, the Xiph QuickTime Components.
  *
@@ -31,6 +31,9 @@
 #include "debug.h"
 #include "utils.h"
 
+extern Boolean FindPage(unsigned char **data, const unsigned char *end,
+                        ogg_page *og);
+
 int unpack_vorbis_comments(vorbis_comment *vc, const void *data, UInt32 data_size)
 {
     int i;
@@ -63,3 +66,21 @@
 
     return 0;
 }
+
+void find_last_page_GP(const unsigned char *data, UInt32 data_size,
+                       ogg_int64_t *gp, long *serialno)
+{
+    unsigned char *ptr = (unsigned char *) data;
+    const unsigned char *end = data + data_size;
+    ogg_page op;
+
+    *gp = -1;
+    *serialno = 0;
+
+    while (FindPage(&ptr, end, &op)) {
+        if (ogg_page_granulepos(&op) > 0) {
+            *gp = ogg_page_granulepos(&op);
+            *serialno = ogg_page_serialno(&op);
+        }
+    }
+}

Modified: trunk/xiph-qt/OggImport/src/utils.h
===================================================================
--- trunk/xiph-qt/OggImport/src/utils.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/utils.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -4,7 +4,7 @@
  *    Support functions header file.
  *
  *
- *  Copyright (c) 2006  Arek Korbik
+ *  Copyright (c) 2006,2007  Arek Korbik
  *
  *  This file is part of XiphQT, the Xiph QuickTime Components.
  *
@@ -32,9 +32,12 @@
 #define __ogg_utils_h__
 
 #include "config.h"
+#include <ogg/ogg.h>
 #include <Vorbis/codec.h>
 
 extern int unpack_vorbis_comments(vorbis_comment *vc, const void *data, UInt32 data_size);
+extern void find_last_page_GP(const unsigned char *data, UInt32 data_size,
+                              ogg_int64_t *gp, long *serialno);
 
 
 #endif /* __ogg_utils_h__ */

Modified: trunk/xiph-qt/OggImport/src/versions.h
===================================================================
--- trunk/xiph-qt/OggImport/src/versions.h	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/OggImport/src/versions.h	2007-03-14 03:51:23 UTC (rev 12754)
@@ -32,9 +32,9 @@
 #define __versions_h__
 
 #ifdef DEBUG
-#define kOgg_eat__Version		(0x00FF0108)
+#define kOgg_eat__Version		(0x00FF0109)
 #else
-#define kOgg_eat__Version		(0x00000108)
+#define kOgg_eat__Version		(0x00000109)
 #endif /* DEBUG */
 
 #endif /* __versions_h__ */

Modified: trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj
===================================================================
--- trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj	2007-03-14 02:13:57 UTC (rev 12753)
+++ trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj	2007-03-14 03:51:23 UTC (rev 12754)
@@ -55,6 +55,9 @@
 		7326B54D0B5AC44B004CE9D3 /* MetaDataConfig.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 737449730B19F922002B059E /* MetaDataConfig.plist */; };
 		73271C840B610B2400175874 /* RingBufferTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73271C830B610B2400175874 /* RingBufferTests.cpp */; };
 		734716840B77F72E001F439D /* XCACodecTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 734716820B77F72E001F439D /* XCACodecTests.cpp */; };
+		7373EDD00B7BDCAA00591836 /* samplerefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 7373EDCE0B7BDCAA00591836 /* samplerefs.c */; };
+		7373EDD20B7BDCAA00591836 /* samplerefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 7373EDCE0B7BDCAA00591836 /* samplerefs.c */; };
+		7373EDD30B7BDCAA00591836 /* samplerefs.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7373EDCF0B7BDCAA00591836 /* samplerefs.h */; };
 		737448B60B19EC05002B059E /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 7374489F0B19EC05002B059E /* common.c */; };
 		737448B70B19EC05002B059E /* OggImport.c in Sources */ = {isa = PBXBuildFile; fileRef = 737448A20B19EC05002B059E /* OggImport.c */; };
 		737448B80B19EC05002B059E /* rb.c in Sources */ = {isa = PBXBuildFile; fileRef = 737448A50B19EC05002B059E /* rb.c */; };
@@ -347,6 +350,7 @@
 			dstSubfolderSpec = 7;
 			files = (
 				7326B54D0B5AC44B004CE9D3 /* MetaDataConfig.plist in CopyFiles */,
+				7373EDD30B7BDCAA00591836 /* samplerefs.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -372,6 +376,8 @@
 		73271C830B610B2400175874 /* RingBufferTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RingBufferTests.cpp; path = ../tests/common/RingBufferTests.cpp; sourceTree = SOURCE_ROOT; };
 		734716820B77F72E001F439D /* XCACodecTests.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = XCACodecTests.cpp; path = ../tests/common/XCACodecTests.cpp; sourceTree = SOURCE_ROOT; };
 		734716830B77F72E001F439D /* XCACodecTests.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = XCACodecTests.h; path = ../tests/common/XCACodecTests.h; sourceTree = SOURCE_ROOT; };
+		7373EDCE0B7BDCAA00591836 /* samplerefs.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = samplerefs.c; path = ../OggImport/src/samplerefs.c; sourceTree = SOURCE_ROOT; };
+		7373EDCF0B7BDCAA00591836 /* samplerefs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = samplerefs.h; path = ../OggImport/src/samplerefs.h; sourceTree = SOURCE_ROOT; };
 		7374489F0B19EC05002B059E /* common.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../OggImport/src/common.c; sourceTree = SOURCE_ROOT; };
 		737448A00B19EC05002B059E /* common.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = common.h; path = ../OggImport/src/common.h; sourceTree = SOURCE_ROOT; };
 		737448A10B19EC05002B059E /* importer_types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = importer_types.h; path = ../OggImport/src/importer_types.h; sourceTree = SOURCE_ROOT; };
@@ -668,6 +674,8 @@
 		737448880B19EAE7002B059E /* OggImport */ = {
 			isa = PBXGroup;
 			children = (
+				7373EDCE0B7BDCAA00591836 /* samplerefs.c */,
+				7373EDCF0B7BDCAA00591836 /* samplerefs.h */,
 				737448C10B19EC3E002B059E /* vorbis */,
 				737448C00B19EC37002B059E /* speex */,
 				737448BF0B19EC2C002B059E /* flac */,
@@ -1325,6 +1333,7 @@
 				7326B5310B5AC44B004CE9D3 /* CAFLACDecoder.cpp in Sources */,
 				7326B5320B5AC44B004CE9D3 /* CAOggFLACDecoder.cpp in Sources */,
 				7326B5330B5AC44B004CE9D3 /* flac_entrypoints.cpp in Sources */,
+				7373EDD20B7BDCAA00591836 /* samplerefs.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1385,6 +1394,7 @@
 				73744CAB0B1A3D07002B059E /* OggExport.c in Sources */,
 				73744CAE0B1A3D07002B059E /* stream_audio.c in Sources */,
 				73744CB20B1A3D07002B059E /* stream_video.c in Sources */,
+				7373EDD00B7BDCAA00591836 /* samplerefs.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};



More information about the commits mailing list