Moved Monkeys Audio plugin to new source system.
parent
ce08d6d4da
commit
505b525d42
|
@ -15,6 +15,8 @@
|
|||
17ADB1E80B9793E300257CA2 /* MonkeysAudioPlugin.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17ADB1E60B9793E300257CA2 /* MonkeysAudioPlugin.h */; };
|
||||
17ADB1E90B9793E300257CA2 /* MonkeysAudioPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 17ADB1E70B9793E300257CA2 /* MonkeysAudioPlugin.mm */; };
|
||||
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
||||
8EB1E6F90B9B39AA008F9F45 /* SourceIO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8EB1E6F80B9B39AA008F9F45 /* SourceIO.h */; };
|
||||
8EB1E6FD0B9B39D4008F9F45 /* SourceIO.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8EB1E6FC0B9B39D4008F9F45 /* SourceIO.mm */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
|
@ -27,6 +29,7 @@
|
|||
179CFD7A0B90C70E00C8C4DB /* MAC.framework in CopyFiles */,
|
||||
177FCFB50B90C97E0011C3B5 /* Plugin.h in CopyFiles */,
|
||||
17ADB1E80B9793E300257CA2 /* MonkeysAudioPlugin.h in CopyFiles */,
|
||||
8EB1E6F90B9B39AA008F9F45 /* SourceIO.h in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -47,6 +50,8 @@
|
|||
32DBCF630370AF2F00C91783 /* MonkeysAudio_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MonkeysAudio_Prefix.pch; sourceTree = "<group>"; };
|
||||
8D5B49B6048680CD000E48DA /* MonkeysAudio.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MonkeysAudio.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8EB1E6F80B9B39AA008F9F45 /* SourceIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceIO.h; sourceTree = "<group>"; };
|
||||
8EB1E6FC0B9B39D4008F9F45 /* SourceIO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SourceIO.mm; sourceTree = "<group>"; };
|
||||
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
|
@ -95,13 +100,15 @@
|
|||
08FB77AFFE84173DC02AAC07 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
177FCFB40B90C97E0011C3B5 /* Plugin.h */,
|
||||
17ADB1E60B9793E300257CA2 /* MonkeysAudioPlugin.h */,
|
||||
17ADB1E70B9793E300257CA2 /* MonkeysAudioPlugin.mm */,
|
||||
177FCFB40B90C97E0011C3B5 /* Plugin.h */,
|
||||
1745C2E70B90BDD100A6768C /* MonkeysAudioDecoder.h */,
|
||||
1745C2E80B90BDD100A6768C /* MonkeysAudioDecoder.mm */,
|
||||
1745C2E90B90BDD100A6768C /* MonkeysAudioPropertiesReader.h */,
|
||||
1745C2EA0B90BDD100A6768C /* MonkeysAudioPropertiesReader.mm */,
|
||||
8EB1E6F80B9B39AA008F9F45 /* SourceIO.h */,
|
||||
8EB1E6FC0B9B39D4008F9F45 /* SourceIO.mm */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
|
@ -196,6 +203,7 @@
|
|||
1745C2ED0B90BDD100A6768C /* MonkeysAudioDecoder.mm in Sources */,
|
||||
1745C2EE0B90BDD100A6768C /* MonkeysAudioPropertiesReader.mm in Sources */,
|
||||
17ADB1E90B9793E300257CA2 /* MonkeysAudioPlugin.mm in Sources */,
|
||||
8EB1E6FD0B9B39D4008F9F45 /* SourceIO.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -12,9 +12,14 @@
|
|||
|
||||
#import "Plugin.h"
|
||||
|
||||
#import "SourceIO.h"
|
||||
|
||||
@interface MonkeysAudioDecoder : NSObject <CogDecoder>
|
||||
{
|
||||
IAPEDecompress * decompress;
|
||||
IAPEDecompress *decompress;
|
||||
|
||||
id<CogSource> source;
|
||||
SourceIO *sourceIO;
|
||||
|
||||
int channels;
|
||||
int bitsPerSample;
|
||||
|
|
|
@ -12,17 +12,12 @@
|
|||
|
||||
@implementation MonkeysAudioDecoder
|
||||
|
||||
- (BOOL)open:(NSURL *)url
|
||||
- (BOOL)open:(id<CogSource>)s
|
||||
{
|
||||
int n;
|
||||
str_utf16 *chars = NULL;
|
||||
|
||||
chars = GetUTF16FromUTF8((const unsigned char *)[[url path] UTF8String]);
|
||||
if(chars == NULL)
|
||||
return NO;
|
||||
sourceIO = new SourceIO(s);
|
||||
|
||||
decompress = CreateIAPEDecompress(chars, &n);
|
||||
free(chars);
|
||||
decompress = CreateIAPEDecompressEx(sourceIO, &n);
|
||||
|
||||
if (decompress == NULL)
|
||||
{
|
||||
|
@ -36,6 +31,9 @@
|
|||
|
||||
length = ((double)decompress->GetInfo(APE_INFO_TOTAL_BLOCKS)*1000.0)/frequency;
|
||||
|
||||
[self willChangeValueForKey:@"properties"];
|
||||
[self didChangeValueForKey:@"properties"];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -60,8 +58,13 @@
|
|||
// DBLog(@"CLOSE");
|
||||
if (decompress)
|
||||
delete decompress;
|
||||
if (sourceIO)
|
||||
delete sourceIO;
|
||||
|
||||
[source release];
|
||||
|
||||
decompress = NULL;
|
||||
sourceIO = NULL;
|
||||
}
|
||||
|
||||
- (double)seekToTime:(double)milliseconds
|
||||
|
@ -89,5 +92,10 @@
|
|||
return [NSArray arrayWithObject:@"ape"];
|
||||
}
|
||||
|
||||
- (BOOL)seekable
|
||||
{
|
||||
return [source seekable];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
@implementation MonkeysAudioPropertiesReader
|
||||
|
||||
- (NSDictionary *)propertiesForURL:(NSURL *)url
|
||||
+ (NSDictionary *)propertiesForSource:(id<CogSource>)source
|
||||
{
|
||||
NSDictionary *properties;
|
||||
MonkeysAudioDecoder *decoder;
|
||||
|
||||
decoder = [[MonkeysAudioDecoder alloc] init];
|
||||
if (![decoder open:url])
|
||||
if (![decoder open:source])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* SourceCIO.h
|
||||
* MonkeysAudio
|
||||
*
|
||||
* Created by Zaphod Beeblebrox on 3/4/07.
|
||||
* Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <MAC/IO.h>
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
class SourceIO : public CIO
|
||||
{
|
||||
public:
|
||||
//construction / destruction
|
||||
SourceIO(id<CogSource> s);
|
||||
~SourceIO();
|
||||
|
||||
// open / close
|
||||
int Open(const wchar_t * pName);
|
||||
int Close();
|
||||
|
||||
// read / write
|
||||
int Read(void * pBuffer, unsigned int nBytesToRead, unsigned int * pBytesRead);
|
||||
int Write(const void * pBuffer, unsigned int nBytesToWrite, unsigned int * pBytesWritten);
|
||||
|
||||
// seek
|
||||
int Seek(int nDistance, unsigned int nMoveMode);
|
||||
|
||||
// creation / destruction
|
||||
int Create(const wchar_t * pName);
|
||||
int Delete();
|
||||
|
||||
// other functions
|
||||
int SetEOF();
|
||||
|
||||
// attributes
|
||||
int GetPosition();
|
||||
int GetSize();
|
||||
int GetName(wchar_t * pBuffer);
|
||||
protected:
|
||||
id<CogSource> source;
|
||||
};
|
|
@ -0,0 +1,110 @@
|
|||
//
|
||||
// SourceCIO.m
|
||||
// MonkeysAudio
|
||||
//
|
||||
// Created by Zaphod Beeblebrox on 3/4/07.
|
||||
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SourceIO.h"
|
||||
|
||||
#import <wchar.h>
|
||||
#include <MAC/NoWindows.h>
|
||||
|
||||
SourceIO::SourceIO(id<CogSource> s)
|
||||
{
|
||||
source = [s retain];
|
||||
}
|
||||
|
||||
SourceIO::~SourceIO()
|
||||
{
|
||||
[source release];
|
||||
}
|
||||
|
||||
int SourceIO::Open(const wchar_t * pName)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SourceIO::Close()
|
||||
{
|
||||
[source close];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read / write
|
||||
int SourceIO::Read(void * pBuffer, unsigned int nBytesToRead, unsigned int * pBytesRead)
|
||||
{
|
||||
int l = [source read:pBuffer amount:nBytesToRead];
|
||||
|
||||
if (l < 0) {
|
||||
*pBytesRead = 0;
|
||||
NSLog(@"Error!");
|
||||
return -1;
|
||||
}
|
||||
*pBytesRead = l;
|
||||
|
||||
return 0;
|
||||
}
|
||||
int SourceIO::Write(const void * pBuffer, unsigned int nBytesToWrite, unsigned int * pBytesWritten)
|
||||
{
|
||||
*pBytesWritten = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// seek
|
||||
int SourceIO::Seek(int nDistance, unsigned int nMoveMode)
|
||||
{
|
||||
return ([source seekable] && [source seek:nDistance whence:nMoveMode] ? 0 : -1);
|
||||
}
|
||||
|
||||
// creation / destruction
|
||||
int SourceIO::Create(const wchar_t * pName)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SourceIO::Delete()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// other functions
|
||||
int SourceIO::SetEOF()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// attributes
|
||||
int SourceIO::GetPosition()
|
||||
{
|
||||
return [source tell];
|
||||
}
|
||||
|
||||
int SourceIO::GetSize()
|
||||
{
|
||||
if ([source seekable]) {
|
||||
long currentPos = [source tell];
|
||||
|
||||
[source seek:0 whence:SEEK_END];
|
||||
long size = [source tell];
|
||||
|
||||
[source seek:currentPos whence:SEEK_SET];
|
||||
|
||||
return size;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int SourceIO::GetName(wchar_t * pBuffer)
|
||||
{
|
||||
wcscpy(pBuffer,(const wchar_t*)[[[[source url] path] substringWithRange:NSMakeRange(0, MAX_PATH)] UTF8String]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue