AudioFileOpenURL gives back kAudio_FilePermissionError but kAudioFilePermissionsError != kAudio_FilePermissionError

When I option click AudioFileOpenURL in Xcode documentation says the following error codes are:


kAudioFileUnspecifiedError

An unspecified error has occurred.


kAudioFileUnsupportedFileTypeError

The file type is not supported.


kAudioFileUnsupportedDataFormatError

The data format is not supported by this file type.


kAudioFileUnsupportedPropertyError

The property is not supported.


kAudioFileBadPropertySizeError

The size of the property data was not correct.


kAudioFilePermissionsError

The operation violated the file permissions. For example, an attempt was made to write to a file opened with the

kAudioFileReadPermission
constant.


kAudioFileNotOptimizedError

The chunks following the audio data chunk are preventing the extension of the audio data chunk. To write more data, you must optimize the file.


kAudioFileInvalidChunkError

Either the chunk does not exist in the file or it is not supported by the file.


kAudioFileDoesNotAllow64BitDataSizeError

The file offset was too large for the file type. The AIFF and WAVE file format types have 32-bit file size limits.


kAudioFileInvalidPacketOffsetError

A packet offset was past the end of the file, or not at the end of the file when a VBR format was written, or a corrupt packet size was read when the packet table was built.


kAudioFileInvalidFileError

The file is malformed, or otherwise not a valid instance of an audio file of its type.


kAudioFileOperationNotSupportedError

The operation cannot be performed. For example, setting the

kAudioFilePropertyAudioDataByteCount
constant to increase the size of the audio data in a file is not a supported operation. Write the data instead.


kAudioFileNotOpenError

The file is closed.


kAudioFileEndOfFileError

End of file.


kAudioFilePositionError

Invalid file position.


kAudioFileFileNotFoundError

File not found.



----

But when I get a permission error I get -54. After looking around I discovered it is: kAudio_FilePermissionError which is declared in CoreAudioTypes.h, which the documentation does not point you to. The duplicated error code wouldn't be a problem if they were set to the same value though

Replies

Me too.


I use AudioFileOpenURL, one user has -54 error.


This happens not always. It happens ocaasionally.


But this user has many audio files, so always has play problem.


My macOS app is sandboxed, so I made internal copied file into document folder, then try to play.


But if failed to copy.


How I handle this error?


------------------------------------------


I found it happened when sandbox rule went wrong.


NSURL startAccessingSecurityScopedResource


NSURL stopAccessingSecurityScopedResource


Two should be paired.

>My macOS app is sandboxed, so I made internal copied file into document folder, then try to play.

>But if failed to copy.

>How I handle this error??


It depends on the error. You'd have to provide more info on that (how are you doing the copy/what error do you get back). You should probably open a new thread for your question though.