A few taglib fixes. Reads id3v2 before ape for mp3 files. Added AutoReleasePool to backgrounded method.
This commit is contained in:
parent
cf46d16a56
commit
9af41d7542
4 changed files with 44 additions and 28 deletions
|
@ -22,7 +22,7 @@
|
||||||
#ifndef TAGLIB_FILEREF_H
|
#ifndef TAGLIB_FILEREF_H
|
||||||
#define TAGLIB_FILEREF_H
|
#define TAGLIB_FILEREF_H
|
||||||
|
|
||||||
#include <tstringlist.h>
|
#include "tstringlist.h"
|
||||||
|
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
|
@ -44,12 +44,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual String title() const
|
virtual String title() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->title().isEmpty())
|
|
||||||
return file->APETag()->title();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->title().isEmpty())
|
if(file->ID3v2Tag() && !file->ID3v2Tag()->title().isEmpty())
|
||||||
return file->ID3v2Tag()->title();
|
return file->ID3v2Tag()->title();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->title().isEmpty())
|
||||||
|
return file->APETag()->title();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->title();
|
return file->ID3v1Tag()->title();
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual String artist() const
|
virtual String artist() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->artist().isEmpty())
|
|
||||||
return file->APETag()->artist();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->artist().isEmpty())
|
if(file->ID3v2Tag() && !file->ID3v2Tag()->artist().isEmpty())
|
||||||
return file->ID3v2Tag()->artist();
|
return file->ID3v2Tag()->artist();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->artist().isEmpty())
|
||||||
|
return file->APETag()->artist();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->artist();
|
return file->ID3v1Tag()->artist();
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual String album() const
|
virtual String album() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->album().isEmpty())
|
|
||||||
return file->APETag()->album();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->album().isEmpty())
|
if(file->ID3v2Tag() && !file->ID3v2Tag()->album().isEmpty())
|
||||||
return file->ID3v2Tag()->album();
|
return file->ID3v2Tag()->album();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->album().isEmpty())
|
||||||
|
return file->APETag()->album();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->album();
|
return file->ID3v1Tag()->album();
|
||||||
|
|
||||||
|
@ -86,12 +86,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual String comment() const
|
virtual String comment() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->comment().isEmpty())
|
|
||||||
return file->APETag()->comment();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->comment().isEmpty())
|
if(file->ID3v2Tag() && !file->ID3v2Tag()->comment().isEmpty())
|
||||||
return file->ID3v2Tag()->comment();
|
return file->ID3v2Tag()->comment();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->comment().isEmpty())
|
||||||
|
return file->APETag()->comment();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->comment();
|
return file->ID3v1Tag()->comment();
|
||||||
|
|
||||||
|
@ -100,12 +100,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual String genre() const
|
virtual String genre() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->genre().isEmpty())
|
|
||||||
return file->APETag()->genre();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->genre().isEmpty())
|
if(file->ID3v2Tag() && !file->ID3v2Tag()->genre().isEmpty())
|
||||||
return file->ID3v2Tag()->genre();
|
return file->ID3v2Tag()->genre();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->genre().isEmpty())
|
||||||
|
return file->APETag()->genre();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->genre();
|
return file->ID3v1Tag()->genre();
|
||||||
|
|
||||||
|
@ -114,12 +114,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual uint year() const
|
virtual uint year() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->year() > 0)
|
|
||||||
return file->APETag()->year();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && file->ID3v2Tag()->year() > 0)
|
if(file->ID3v2Tag() && file->ID3v2Tag()->year() > 0)
|
||||||
return file->ID3v2Tag()->year();
|
return file->ID3v2Tag()->year();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->year() > 0)
|
||||||
|
return file->APETag()->year();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->year();
|
return file->ID3v1Tag()->year();
|
||||||
|
|
||||||
|
@ -128,12 +128,12 @@ namespace TagLib {
|
||||||
|
|
||||||
virtual uint track() const
|
virtual uint track() const
|
||||||
{
|
{
|
||||||
if (file->APETag() && !file->APETag()->track() > 0)
|
|
||||||
return file->APETag()->track();
|
|
||||||
|
|
||||||
if(file->ID3v2Tag() && file->ID3v2Tag()->track() > 0)
|
if(file->ID3v2Tag() && file->ID3v2Tag()->track() > 0)
|
||||||
return file->ID3v2Tag()->track();
|
return file->ID3v2Tag()->track();
|
||||||
|
|
||||||
|
if (file->APETag() && !file->APETag()->track() > 0)
|
||||||
|
return file->APETag()->track();
|
||||||
|
|
||||||
if(file->ID3v1Tag())
|
if(file->ID3v1Tag())
|
||||||
return file->ID3v1Tag()->track();
|
return file->ID3v1Tag()->track();
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,8 @@
|
||||||
|
|
||||||
- (void)loadInfoForEntries:(NSArray *)entries
|
- (void)loadInfoForEntries:(NSArray *)entries
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
NSOperationQueue *queue;
|
NSOperationQueue *queue;
|
||||||
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
||||||
|
|
||||||
|
@ -279,10 +281,10 @@
|
||||||
for (PlaylistEntry *pe in entries)
|
for (PlaylistEntry *pe in entries)
|
||||||
{
|
{
|
||||||
NSInvocationOperation *readEntryInfoOperation;
|
NSInvocationOperation *readEntryInfoOperation;
|
||||||
readEntryInfoOperation = [[[NSInvocationOperation alloc]
|
readEntryInfoOperation = [[NSInvocationOperation alloc]
|
||||||
initWithTarget:self
|
initWithTarget:self
|
||||||
selector:@selector(readEntryInfo:)
|
selector:@selector(readEntryInfo:)
|
||||||
object:pe]autorelease];
|
object:pe];
|
||||||
if (oldReadEntryInfoOperation)
|
if (oldReadEntryInfoOperation)
|
||||||
{
|
{
|
||||||
[readEntryInfoOperation addDependency:oldReadEntryInfoOperation];
|
[readEntryInfoOperation addDependency:oldReadEntryInfoOperation];
|
||||||
|
@ -294,12 +296,14 @@
|
||||||
context:NULL];
|
context:NULL];
|
||||||
[queue addOperation:readEntryInfoOperation];
|
[queue addOperation:readEntryInfoOperation];
|
||||||
oldReadEntryInfoOperation = [readEntryInfoOperation retain];
|
oldReadEntryInfoOperation = [readEntryInfoOperation retain];
|
||||||
|
[readEntryInfoOperation release];
|
||||||
}
|
}
|
||||||
[oldReadEntryInfoOperation release];
|
[oldReadEntryInfoOperation release];
|
||||||
|
|
||||||
[queue waitUntilAllOperationsAreFinished];
|
[queue waitUntilAllOperationsAreFinished];
|
||||||
|
|
||||||
[playlistController performSelectorOnMainThread:@selector(updateTotalTime) withObject:nil waitUntilDone:NO];
|
[playlistController performSelectorOnMainThread:@selector(updateTotalTime) withObject:nil waitUntilDone:NO];
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)readEntryInfo:(PlaylistEntry *)pe
|
- (NSDictionary *)readEntryInfo:(PlaylistEntry *)pe
|
||||||
|
|
|
@ -35,13 +35,25 @@
|
||||||
lYear = tag->year();
|
lYear = tag->year();
|
||||||
lTrack = tag->track();
|
lTrack = tag->track();
|
||||||
|
|
||||||
lArtist = [NSString stringWithUTF8String:pArtist.toCString(true)];
|
if (!pArtist.isNull())
|
||||||
|
lArtist = [NSString stringWithUTF8String:pArtist.toCString(true)];
|
||||||
|
else
|
||||||
|
lArtist = @"";
|
||||||
|
|
||||||
lAlbum = [NSString stringWithUTF8String:pAlbum.toCString(true)];
|
if (!pAlbum.isNull())
|
||||||
|
lAlbum = [NSString stringWithUTF8String:pAlbum.toCString(true)];
|
||||||
|
else
|
||||||
|
lAlbum = @"";
|
||||||
|
|
||||||
lTitle = [NSString stringWithUTF8String:pTitle.toCString(true)];
|
if (!pTitle.isNull())
|
||||||
|
lTitle = [NSString stringWithUTF8String:pTitle.toCString(true)];
|
||||||
|
else
|
||||||
|
lTitle = @"";
|
||||||
|
|
||||||
lGenre = [NSString stringWithUTF8String:pGenre.toCString(true)];
|
if (!pGenre.isNull())
|
||||||
|
lGenre = [NSString stringWithUTF8String:pGenre.toCString(true)];
|
||||||
|
else
|
||||||
|
lGenre = @"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue