Long time no posts

Some time ago I’ve said there would be updates during New Year holidays. Well, that didn’t come true.
I have been moving to the new apartment and had no time to do something, even reading the e-mails was a problem.

Also I have a request to those of you who has a MacBook and a not-Touch iPod (i.e. Classic, Nano, etc.). Please post in the comments how does the player appear in the Mac OS X. Is it mounted to some directory (which exactly?) as a removable drive just like in Windows?

New iTunes library is here

I’ve just got why you should use new iTunes (8.2) since beta 5. They have replaced old iTunesDB library with new one based on SQLite, so sync is a bit odd thing now.
Device itself doesn’t use iTunesDB at all, but iTunes still does – I think it’s for compatibility reasons. When syncing, iTunes writes both iTunesDB and new library files to device. If there’s no iTunesDB file on device, iTunes will also purge new library and all your music will appear as “other” data.

I wonder whether new library will completely supersede iTunesDB or will they continue coexisting for compatibility reasons. But anyway, linux guys would be happy since SQLite format is open and much more clear for understanding.

Sync: “Slide to cancel”

Slide to CancelYeah, I’ve just found out how to handle this and terminate sync when user slides cancel switch.

We need following functions (meta-language):

ERROR AMDObserveNotification(HANDLE proxy, CFSTR notification);
ERROR AMDListenForNotifications(HANDLE proxy, NOTIFY_CALLBACK cb, USERDATA data);

and callback delegate:

typedef void (*NOTIFY_CALLBACK)(CFSTR notification, USERDATA data);

First, we need AMDObserveNotification to subscribe notifications about “com.apple.itunes-client.syncCancelRequest”. Then we should start listening for notifications (second function) until we get “AMDNotificationFaceplant”.
That’s it. When notification got, you should unlock and close lock file handle (don’t sure if you need to post “syncDidFinish” to proxy, seems it doesn’t matter) and terminate sync gracefully.

P.S. The same notification is also got when you unplug your device, so you should always be ready for errors.

ArtDoctor for Mac OS X: possible!

Some time ago a Mac port of Mono was released, so it made completely possible to run .NET applications there. But ArtDoctor needs to operate directly with device and was strictly tied with iTunesMobileDevice.dll, which has no analog on a Mac.

And today I’ve managed to create a fully cross-platform .NET library to deal with Apple devices. It even works without re-compiling for target platform. The trick is to use MobileDevice (dll on Windows and framework on Mac OS X) instead and apply some dll redirections for Mono.

However, it’s not just to change referenced library name. Unlike iTunesMobileDevice, MobileDevice framework doesn’t use native threads on both platforms. Also it is more strict about strings, so hand-made CFStrings most likely won’t do.

P.S. I really have no idea why both of these libraries are included in Windows distribution of Apple Mobile Device Support, ’cause they don’t even reference each other.

ArtDoctor future

For some time I thought that current ArtDoctor version (1.0.2) can fix any artwork-related issues. Well, I was wrong: maybe in case of iTunes that’s true, but other managers could not be trusted a bit.

A few days ago I was trying to resolve a reported issue with “parameter is not valid” error.
At first I thought there were some changes in thumbnail formats (error was got on iTouch 2G, and I’ve never tested it on that device). Then I looked in ArtworkDB and noticed that it had invalid information inside, like overlapping offsets in cache files.
So I understood ArtDoctor must also be able to rewrite artwork database, not only cache. It still doesn’t affect main database and is safe for your player. Even if something goes wrong, you won’t lose your music.
Continue Reading »

ArtDoctor page added

No updates yet, it is still version 1.0.2.

Go to product page.

ArtDoctor

Artwork (album art) is a great feature of Apple devices. It not only helps to distinguish your albums, movies or podcasts visually, but also it is a real eye-candy. A lot of people enjoy it!

Loading pictures from tags and resizing them every time is really slow, so devices are using cache with images of several different sizes to speed-up loading. And sometimes this cache is getting corrupted. As a result you can see “black squares” or partially drawn images, or even images from other album/movie.

In such cases iTunes won’t help you a bit – it reads images directly from tags and doesn’t even know about cache corruption. Also for new devices there’s no “Show artwork on device” option anymore. And even if your device is either jailbroken or you have TouchCopy (or other file manager), deleting artwork cache won’t force it to get rebuilt.

As a workaround, you may automate iTunes via COM and rewrite artwork for each track, but it takes a lot of time and you’re not guaranteed it won’t get corruped on next sync.

ArtDoctor utility was written exactly for healing corrupted cache. It will scan all your albums, get uncorrupted artwork from tags and write it into cache. You may use existing cache (to keep images that can’t be extracted from tags, e.g. video thumbnails) or recreate it from scratch.

ArtDoctor deals directly with binary cache, without rewriting tags, modifying iTunes database and performing other stupid things. Thereby it is very fast (takes several minutes on average content) and doesn’t affect synchronization.

Download ArtDoctor 1.0.2.

It requires .NET Framework 3.0 (or newer), iTunes and Windows XP/Vista/7 to run.

Note: ArtDoctor 1.0.2 doesn’t support iPhone OS 3.0. Please refer to ArtDoctor 2.0 preview.

mp4patch

There are many ways to convert video for your iPod/iPhone. You may use user-friendly GUI programs or command-line utilities like ffmpeg or mencoder… But almost none of them could embed soft sublitles to resulting mp4 file. Hard-coded subtitles are the best what they can.

But there’s a cross-platform tool called MP4Box to deal with mp4 containers. It can add subtitle streams by typing smth like:

mp4box -add source.mp4 -add subtitle.srt:lang=en output.mp4

This allows you to add audio tracks as well.

The resulted file will play great on a PC, but your iPod would fail to recognize subtitles and alternative audio tracks.

Solution

mp4patch is a small cross-platform utility to solve this incompatibility issue. It takes an mp4 file and changes it to make acceptable by iPod Touch and iPhone devices (older iPods don’t support soft subtitles and track selection).

Usage is quite simple:

mp4patch input.mp4

If you’re running Windows, you may download mp4patch binary. If you’re running other OS (or you’re a geek) you can compile it from source.

How to compile

First of all, download source code: mp4patch.c.

If you are going to compile it under Windows and Visual C++, you also need stdint.h header. Put it near the source.

If you’re using gcc, use smth like

gcc -o mp4patch mp4patch.c

If you’re using VC++, use

cl /GF /O2 /TP /I . /MT mp4patch.c /link /manifest
mt -manifest mp4patch.exe.manifest -outputresource:mp4patch.exe
del mp4patch.obj mp4patch.exe.manifest

Notes:
1. All the mess with manifest file is to make UAC happy.
2. /MT switch makes static linking with C runtime. You may use /MD instead to link dynamically and to get smaller output size.

If you use some other compiler, please refer to its documentation.