Re: question for sending multiple requests to iTunes
Re: question for sending multiple requests to iTunes
- Subject: Re: question for sending multiple requests to iTunes
- From: John Stiles <email@hidden>
- Date: Fri, 1 Sep 2006 15:41:21 -0700
No worries. I recently did battle with iTunes and AESendMessage; I
walked away victorious, but it was a bloody battle.
Some tips:
- Take a look at an open-source library called "eyeTunes." It has
some great code that you can use to learn from, or use outright if
you like (I believe it's BSD licensed)
- In my case, I used AESendMessage's asynchronous mode for "queueing"
the reply instead of blocking until the reply comes back, since we
work on games and a 1/4 second hiccup is noticeable. eyeTunes does
not do this so I had to write it myself; it's not that hard but there
are some fiddly bits.
On Sep 1, 2006, at 3:35 PM, Philip Lukidis wrote:
OUCH. It's quite clearly documented as well. Thanks, I do
appreciate your pointing it out.
Philip Lukidis
-----Original Message-----
From: John Stiles [mailto:email@hidden]
Sent: Fri 9/1/2006 5:53 PM
To: Philip Lukidis
Cc: email@hidden
Subject: Re: question for sending multiple requests to iTunes
You are only allowed to call NSAppleScript from the main thread.
AESendMessage is documented as thread-safe but it is a lot more
complicated to use than NSAppleScript :(
On Sep 1, 2006, at 2:40 PM, Philip Lukidis wrote:
> Hello. I'm not if the problem which I'm am experiencing is a cocoa
> issue or an Applescript issue. Briefly, my application accesses
> iTunes via AppleScript, specifically by using cocoa NSAppleScript
> objects. Each script file is associated with its own NSAppleScript
> object, and access to it is protected with a pthread_mutex, so it's
> quite impossible for 2 threads to call the same script
> simultaneously. However, I'm finding that unless I synchronize
> access to these script objects globally in my process (i.e. one
> mutex for all calls), parallel calls to different scripts produce a
> resounding crash.
>
> Now, I could understand why there would be a crash if two threads
> tried to access the same script object in parallel, but I cannot
> understand why there would be a problem with two threads accessing
> different scripts simultaneously.
>
> Can anyone explain why this would be a problem?
>
> thanks,
>
> Philip Lukidis
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40blizzard.com
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden