• 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
Re: set kAudioFilePropertyAlbumArtwork: fail
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set kAudioFilePropertyAlbumArtwork: fail


  • Subject: Re: set kAudioFilePropertyAlbumArtwork: fail
  • From: Bastian Schnuerle <email@hidden>
  • Date: Tue, 06 Aug 2013 00:12:06 +0200

yeah, thanks guys ... i am gettin' that @autoreleasepool { also, and very often .. ....

Am 05.08.2013 um 23:50 schrieb Alex _:

Thanks Kyle.
I've try to do as you suggested but unfortunately it didn't fix the problem.
This time I got:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010
0x00007fff904e2250 in objc_msgSend ()

This is the snippet that actually allows you to replicate the problem.
It doesn't do anything special, just create the M4A audio file and set the cover.

int main(int argc, const char * argv[])
{
    @autoreleasepool {

        AudioFileID audioID;
AudioStreamBasicDescription outFormat = (AudioStreamBasicDescription){0};
        outFormat.mFormatID = kAudioFormatMPEG4AAC;
        outFormat.mSampleRate = 44100;
        outFormat.mChannelsPerFrame = 2;

AudioStreamBasicDescription inFormat = (AudioStreamBasicDescription) {0};
        inFormat.mSampleRate = 44100;
        inFormat.mFormatID = kAudioFormatLinearPCM;
        inFormat.mChannelsPerFrame = 2;
        inFormat.mBytesPerPacket = 8;
        inFormat.mFramesPerPacket = 1;
        inFormat.mBytesPerFrame = 8;
        inFormat.mBitsPerChannel = 32;
        inFormat.mFormatFlags = 9;

        UInt32 dataSize = sizeof(outFormat);
        checkError("AudioFormatGetProperty",
AudioFormatGetProperty (kAudioFormatProperty_FormatInfo,
                                          0,
                                          NULL,
                                          &dataSize,
                                          &outFormat));

        AudioConverterRef audioConverter;
        AudioConverterNew(&inFormat, &outFormat, &audioConverter);

checkError("AudioConvertGetPropertyInfo", AudioConverterGetPropertyInfo(audioConverter, kAudioConverterCompressionMagicCookie, &dataSize, NULL));

        char *cookie = malloc(dataSize);
checkError("AudioConvertGetProperty", AudioConverterGetProperty(audioConverter, kAudioConverterCompressionMagicCookie, &dataSize, cookie));

        NSURL *url = [NSURL URLWithString:@"/tmp/test.m4p"];
        checkError("AudioFileOpenURL",
                   AudioFileCreateWithURL((CFURLRef)url,
                                          kAudioFileM4AType,
                                          &outFormat,
kAudioFileReadWritePermission,
                                          &audioID));


checkError("AudioFileSetProperty", AudioFileSetProperty (audioID, kAudioFilePropertyMagicCookieData, dataSize, cookie));

NSData *image = [NSData dataWithContentsOfFile:@"/tmp/ test.jpg"];
        if (image != NULL)
        {
            checkError("AudioFileSetProperty",
                       AudioFileSetProperty(audioID,
kAudioFilePropertyAlbumArtwork,
                                            (UInt32)[image length],
                                            [image bytes]));
        }

        checkError("AudioFileClose",
                   AudioFileClose(audioID));

        free(cookie);
        NSLog(@"File closed\n");

    }
    return 0;
}

Thanks a lot for your help

----------------------------------------
From: email@hidden
To: email@hidden; email@hidden
Subject: Re: set kAudioFilePropertyAlbumArtwork: fail
Date: Mon, 5 Aug 2013 10:30:56 -0700

On Mon, Aug 5, 2013, at 01:37 AM, Alex _ wrote:
Unfortunately, as soon as I try to set the artwork, the
AudioFileSetProperty doesn't fail, but AudioFileClose does.
Specifically I get:á+[NSConcreteData bytes]: unrecognized selector sent
to class

á á á á ...
á á á ááNSDataá*image = [NSDataádataWithContentsOfFile:@"/tmp/ test.jpg"];
á á á ááifá(image !=áNULL)
á á á á {
á á á á á áácheckError("AudioFileSetProperty",
áá á á á á á á á á á ááAudioFileSetProperty(audioID,
á á á á á á á á á á á á á á á á á á á á á áákAudioFilePropertyAlbumArtwork,
á á á á á á á á á á á á á á á á á á á á á á (UInt32)[imageálength],
á á á á á á á á á á á á á á á á á á á á á ááCFBridgingRetain (image)));

You're assigning a pointer to the NSData object as a property value, but telling AudioFileSetData that you're actually assigning a value of the size of the bytes held by that NSData. At some point this corrupts your
heap, and -data (an instance method) winds up getting sent to
NSConcreteData (the class).

You want to do:

AudioFileSetProperty(audioID, kAudioFilePropertyAlbumArtwork,
(UInt32)[image length], [image bytes]);

--Kyle Sluder
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden

This email sent to email@hidden


_______________________________________________
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


  • Follow-Ups:
    • RE: set kAudioFilePropertyAlbumArtwork: fail
      • From: Alex _ <email@hidden>
References: 
 >set kAudioFilePropertyAlbumArtwork: fail (From: Alex _ <email@hidden>)
 >Re: set kAudioFilePropertyAlbumArtwork: fail (From: Kyle Sluder <email@hidden>)
 >RE: set kAudioFilePropertyAlbumArtwork: fail (From: Alex _ <email@hidden>)

  • Prev by Date: RE: set kAudioFilePropertyAlbumArtwork: fail
  • Next by Date: Documentation for Core Audio SDK
  • Previous by thread: RE: set kAudioFilePropertyAlbumArtwork: fail
  • Next by thread: RE: set kAudioFilePropertyAlbumArtwork: fail
  • Index(es):
    • Date
    • Thread