Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple runs of file write example gives error -48 duplicate filename on second execution and all following #30

Closed
ghost opened this issue Aug 21, 2012 · 6 comments

Comments

@ghost
Copy link

ghost commented Aug 21, 2012

Hi

When I uncomment the filewrite example code in the demo view controller, on the first run everything is fine, but on the second run,

CheckError(ExtAudioFileCreateWithURL(audioFileRef, kAudioFileM4AType, &outputFileDesc, NULL, 0, &_outputFile), "Creating file");

exits the app with error code -48, which is declared in MacErrors.h as duplicate filename.

I will try to find a work around this and post it here.

best

@ghost
Copy link
Author

ghost commented Aug 21, 2012

My quick workaround for this is:

in AudioFileWriter.m

  • (id)initWithAudioFileURL:(NSURL *)urlToAudioFile samplingRate:(float)thisSamplingRate numChannels:(UInt32)thisNumChannels

just above the line with CheckEroor(ExtAudioFileCreateWithURL... i added the following code which removes the file if it already exists:

if ([[NSFileManager defaultManager] fileExistsAtPath:[urlToAudioFile path]]) {
[[NSFileManager defaultManager] removeItemAtURL:urlToAudioFile error:nil] ;
}

@ghost
Copy link
Author

ghost commented Aug 21, 2012

but here is a much better solution, this should go into the rep

CheckError(ExtAudioFileCreateWithURL(audioFileRef, kAudioFileM4AType, &outputFileDesc, NULL, kAudioFileFlags_EraseFile, &_outputFile), "Creating file");

kAudioFileFlags_EraseFile does the trick, currently 0 is passed for flags.

@ghost ghost closed this as completed Aug 21, 2012
@alexbw
Copy link
Owner

alexbw commented Aug 21, 2012

This is a great addition. Make a pull request, I'll roll it in.

On Tuesday, August 21, 2012 at 7:23 AM, sn-e5 wrote:

My quick workaround for this is:
in
(id)initWithAudioFileURL:(NSURL *)urlToAudioFile samplingRate:(float)thisSamplingRate numChannels:(UInt32)thisNumChannels

just above the line with CheckEroor(ExtAudioFileCreateWithURL... i added the following code which removes the file if it already exists:
if ([[NSFileManager defaultManager] fileExistsAtPath:[urlToAudioFile path]]) {
[[NSFileManager defaultManager] removeItemAtURL:urlToAudioFile error:nil] ;
}


Reply to this email directly or view it on GitHub (#30 (comment)).

@ghost
Copy link
Author

ghost commented Aug 21, 2012

hi alex, did the pull request, my first ever ;). btw, thank you for your awesome work, it is extremely useful to me.

@alexbw
Copy link
Owner

alexbw commented Aug 21, 2012

Roger that, I'll test the commit and merge it in. Glad you dig the project!

On Tuesday, August 21, 2012 at 7:57 AM, sn-e5 wrote:

hi alex, did the pull request, my first ever ;). btw, thank you for your awesome work, it is extremely useful to me.


Reply to this email directly or view it on GitHub (#30 (comment)).

@alexissmirnov
Copy link

Sent from a phone.

On 2012-08-21, at 7:12 AM, sn-e5 notifications@github.com wrote:

Hi

When I uncomment the filewrite example code in the demo view controller, on the first run everything is fine, but on the second run,

CheckError(ExtAudioFileCreateWithURL(audioFileRef, kAudioFileM4AType, &outputFileDesc, NULL, 0, &_outputFile), "Creating file");

exits the app with error code -48, which is declared in MacErrors.h as duplicate filename.

I will try to find a work around this and post it here.

best


Reply to this email directly or view it on GitHub.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants