• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Unexpected values returned when requesting fileplayer current time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unexpected values returned when requesting fileplayer current time


  • Subject: Unexpected values returned when requesting fileplayer current time
  • From: Barry Duggan <email@hidden>
  • Date: Tue, 24 Sep 2013 18:43:58 +0100

 Im running a simple little core audio audio using ios 6.0. 

The problem I have is when requesting the kAudioUnitProperty_CurrentPlayTime of the file player unit. When I run my code on the simulator everything runs fine. If I constantly poll the property I can see it rise from -1, 0 , 2048 etc .

When I run the application on a device though I get very puzzling results. Instead of seeing a steady increase in the current play time I see output similar to -1,0,2144484098.

So, on a device the current play time leaps ahead to what seems like an arbitrary huge number.

Can anybody explain this simulator vs device behavior or explain how the file players timeline could jump ahead like this?



        Float64 getTrackPosition() {
            AudioTimeStamp ts; 
            UInt32 size = sizeof(ts); 
            AudioUnitGetProperty(fileAU, kAudioUnitProperty_CurrentPlayTime, kAudioUnitScope_Global, 0, &ts, &size); 
            Float64 sampleFrame = ts.mSampleTime;
            
            return sampleFrame ;
        }
    
    
    double PrepareFileAU (AudioUnit &au, CAStreamBasicDescription &fileFormat, AudioFileID audioFile)
            {
                // 
                // calculate the duration
             UInt64 nPackets;
             UInt32 propsize = sizeof(nPackets);
             XThrowIfError (AudioFileGetProperty(audioFile, kAudioFilePropertyAudioDataPacketCount, &propsize, &nPackets), "kAudioFilePropertyAudioDataPacketCount");
                
             Float64 fileDuration = (nPackets * fileFormat.mFramesPerPacket) / fileFormat.mSampleRate;
                
             ScheduledAudioFileRegion rgn;
             memset (&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));
             rgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
             rgn.mTimeStamp.mSampleTime = 0;
             rgn.mCompletionProc = NULL;
             rgn.mCompletionProcUserData = NULL;
             rgn.mAudioFile = audioFile;
             rgn.mLoopCount = 0;
             rgn.mStartFrame = 0;
             rgn.mFramesToPlay = UInt32(nPackets * fileFormat.mFramesPerPacket);
                
                
                XThrowIfError (AudioUnitSetProperty(au, kAudioUnitProperty_ScheduledFileIDs, kAudioUnitScope_Global, 0, &audioFile, sizeof(AudioFileID)), "Schedule file Id's");
                
                XThrowIfError (AudioUnitSetProperty(au, kAudioUnitProperty_ScheduledFileRegion, kAudioUnitScope_Global, 0, &rgn, sizeof(rgn)), "kAudioUnitProperty_ScheduledFileRegion");
                
                
            
                // prime the fp AU with default values
             UInt32 defaultVal = 0;
                XThrowIfError (AudioUnitSetProperty(au, kAudioUnitProperty_ScheduledFilePrime, kAudioUnitScope_Global, 0, &defaultVal, sizeof(defaultVal)), "kAudioUnitProperty_ScheduledFilePrime");
                
            
             AudioTimeStamp startTime;
             memset (&startTime, 0, sizeof(startTime));
             startTime.mFlags = kAudioTimeStampSampleTimeValid;
             startTime.mSampleTime = -1;
                
                XThrowIfError (AudioUnitSetProperty(au, kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global, 0, &startTime, sizeof(startTime)), "kAudioUnitProperty_ScheduleStartTimeStamp");
                
               
                
             return fileDuration;
            }
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Audio Units and Infinite Tails
  • Next by Date: recording and playback independently with RemoteIO
  • Previous by thread: Audio Units and Infinite Tails
  • Next by thread: recording and playback independently with RemoteIO
  • Index(es):
    • Date
    • Thread