我试图将 AMR-NB 解码支持添加到 iOS 应用程序中,这在之前已经成功完成。但是自从我升级了我使用的框架(PhoneGap,现在作为 Cordova),我开始了一个新项目并将所有代码迁移到新项目,AMR-NB 库在链接短语期间开始出错。
我一直在使用'file'和'lipo -info'命令检查.a lib文件,并确保fat lib包含i386的arch,并且它已经包含在构建短语的链接短语中。我一直在比较新旧项目的构建设置,但没有找到解决这个问题的运气。
有谁知道我可能在哪里弄错了?谢谢!
更新:添加了 amrFileCodec.h 和 CJ-Func.m 的代码片段
amrFileCodec.h
// amrFileCodec.h
// Created by Tang Xiaoping on 9/27/11.
// Copyright 2011 test. All rights reserved.
#ifndef amrFileCodec_h
#define amrFileCodec_h
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "interf_dec.h"
#include "interf_enc.h"
...
// 将AMR文件解码成WAVE文件
int DecodeAMRFileToWAVEFile(const char* pchAMRFileName, const char* pchWAVEFilename);
#endif
CJ-Func.m
// CJ-Func.m
// iBear
// Created by Chris Jiang on 11-4-22.
// Copyright 2011 Individual. All rights reserved.
#import "CJ-Func.h"
#import "interf_dec.h"
#import "interf_enc.h"
#import "amrFileCodec.h"
@implementation MyPGPlugFunc
...
- (void)decodeAMR:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
NSArray *currentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = [currentPaths objectAtIndex:0];
NSString *wavDir = [basePath stringByAppendingPathComponent:@"tmp/wav"];
NSString *wavPath = [basePath stringByAppendingPathComponent:[arguments objectAtIndex:1]];
NSLog(@"[CJ-FUNC] Decoding %@ to %@", [arguments objectAtIndex:0], wavPath);
BOOL isDir = YES;
NSFileManager *fileMgr = [NSFileManager defaultManager];
if ( ![fileMgr fileExistsAtPath:wavDir isDirectory:&isDir] ) {
if ( ![fileMgr createDirectoryAtPath:wavDir withIntermediateDirectories:YES attributes:nil error:nil] )
NSLog(@"[CJ-FUNC] ERROR: tmp/wav directory creation failed");
else
NSLog(@"[CJ-FUNC] tmp/wav directory created");
}
[fileMgr release];
int encRes = DecodeAMRFileToWAVEFile(
[[arguments objectAtIndex:0] cStringUsingEncoding:NSASCIIStringEncoding],
[wavPath cStringUsingEncoding:NSASCIIStringEncoding]
);
if ( encRes <= 0 )
[self writeJavascript:[NSString stringWithFormat:@"%@();", [arguments objectAtIndex:3]]];
else
[self writeJavascript:[NSString stringWithFormat:@"%@('%@');", [arguments objectAtIndex:2], wavPath]];
}
@end