I have upgraded my Xcode version from 5.0 to 5.1 & started occuring below error in GPUImage Library GPUImageVideoCamera.m:301:54: Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int32_t' (aka 'int')
In below function on this line "connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);" error is occuring.
- (void)setFrameRate:(NSInteger)frameRate;
{
_frameRate = frameRate;
if (_frameRate > 0)
{
for (AVCaptureConnection *connection in videoOutput.connections)
{
if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
connection.videoMinFrameDuration = CMTimeMake(1, _frameRate);
if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])
connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);
}
}
else
{
for (AVCaptureConnection *connection in videoOutput.connections)
{
if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
connection.videoMinFrameDuration = kCMTimeInvalid;
// This sets videoMinFrameDuration back to default
if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])
connection.videoMaxFrameDuration = kCMTimeInvalid;
// This sets videoMaxFrameDuration back to default
}
}
}
The problem is related with architecture
. If you open your existing project in Xcode 5.1, It's default arch setting is 64-bit architectures.
See this lines in Xcode 5.1 release nots
Note: Be aware of the following architectures issues when opening your existing projects in Xcode 5.1:
You can see this line in this apple's doc.
NSInteger changes size in 64-bit code. The NSInteger type is used throughout Cocoa Touch; it is a 32-bit integer in the 32-bit runtime and a 64-bit integer in the 64-bit runtime. So when receiving information from a framework method that takes an NSInteger type, use the NSInteger type to hold the result.
But int is a 32-bit integer
, so only this arise this error. You can solve this problem by setting architecture to standard architecture including 64-bit
or do simple type casting as below.
connection.videoMinFrameDuration = CMTimeMake((int64_t)1, (int32_t)_frameRate);
See CMTimeMake syntax.
CMTime CMTimeMake (
int64_t value,
int32_t timescale
);