• 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
ExtAudioFileSeek returning -66568 (kExtAudioFileError_InvalidSeek)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ExtAudioFileSeek returning -66568 (kExtAudioFileError_InvalidSeek)


  • Subject: ExtAudioFileSeek returning -66568 (kExtAudioFileError_InvalidSeek)
  • From: "Stephen F. Booth" <email@hidden>
  • Date: Sun, 16 Dec 2007 11:11:26 -0800

Hello all,

I've been staring at this code for three days now trying to figure out what I'm doing wrong.  I am attempting to open a WAVE file (2-channel, 44.1 KHz 16-bit signed integer), seek to a point in it, and extract some of the audio to a separate file after some processing.  I have done this numerous times in the past without problems, but for some reason my new code isn't working properly.  Here is what I have (I'm using 10.5 with gc enabled, although compiling with gc off has no effect on this particular issue):

// Open the file for reading
ExtAudioFileRef file = NULL;
OSStatus status = ExtAudioFileOpenURL((CFURLRef)[NSURL fileURLWithPath:path], &file);
if(noErr != status)
goto cleanup;
// Determine the total number of audio frames in the file (for debugging output)
SInt64 totalFrames = -1;
dataSize = sizeof(totalFrames);
status = ExtAudioFileGetProperty(file, kExtAudioFileProperty_FileLengthFrames, &dataSize, &totalFrames);
if(noErr != status)
goto cleanup;
NSLog(@"Total frames in file = %qi", totalFrames);
// Seek to the desired starting sector
SInt64 frame = AUDIO_FRAMES_PER_CDDA_SECTOR * firstSector;
NSLog(@"Seeking to frame %qi", frame);
status = ExtAudioFileSeek(file, frame);
NSLog(@"ExtAudioFileSeek = %i", status);
if(noErr != status)
goto cleanup;

Here is the output I'm seeing:

Total frames in file = 20599404
Seeking to frame 10783332
ExtAudioFileSeek = -66568

I've also tried using the FSRef version of ExtAudioFileOpen, but that didn't make a difference.

I know the file is valid and can be opened by Core Audio, because afinfo and afplay work correctly:

Macintosh:Release-Tiger+ me$ ./afinfo /tmp/Disc\ Image.wav 
File:           /tmp/Disc Image.wav
File type ID:   WAVE
Data format:     2 ch,  44100 Hz, 'lpcm' (0x0000000C) 16-bit little-endian signed integer
                no channel layout.
estimated duration: 467.107 sec
audio bytes: 82397616
audio packets: 20599404
bit rate: 1411200 bits per second
maximum packet size: 4
packet size upper bound: 4
audio data file offset: 4096
optimized
Source Has Channel Layout: FALSE
Source Has Region List: FALSE
Source Has Marker List: FALSE
----

and the kicker is that 

Macintosh:Release-Tiger+ me$ ./afplay -f 10783332 /tmp/Disc\ Image.wav 

works perfectly as well!  So surely there is a mistake in my code somewhere, but I can' see it.

Stephen
 _______________________________________________
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: Re: Is MusicSequenceSaveSMFData() totally broken or am I missing something?
  • Next by Date: How to uniquely identify audio device
  • Previous by thread: Re: Is MusicSequenceSaveSMFData() totally broken or am I missing something?
  • Next by thread: How to uniquely identify audio device
  • Index(es):
    • Date
    • Thread