Skip to content

Commit

Permalink
Merge pull request #20 from mike-es/master
Browse files Browse the repository at this point in the history
Improved memory usage
  • Loading branch information
alexbw committed Jul 7, 2012
2 parents 86a85aa + d8290e5 commit b056c50
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
22 changes: 11 additions & 11 deletions Novocaine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@
FA552628152A63A4003D9601 = {
isa = PBXGroup;
children = (
FA5526EB152A6466003D9601 /* Accelerate.framework */,
FA5526EC152A6466003D9601 /* AudioToolbox.framework */,
FA5526ED152A6466003D9601 /* AudioUnit.framework */,
FA5526EE152A6466003D9601 /* CoreAudio.framework */,
FA55269D152A6405003D9601 /* Accelerate.framework */,
FA55269E152A6405003D9601 /* AudioToolbox.framework */,
FA55269F152A6405003D9601 /* AudioUnit.framework */,
FA5526A0152A6405003D9601 /* CoreAudio.framework */,
FA552694152A63F6003D9601 /* Novocaine */,
FA55267F152A63B6003D9601 /* Novocaine Mac Example */,
FA5526D3152A6452003D9601 /* Novocaine iOS Example */,
Expand All @@ -148,9 +140,17 @@
FA552636152A63A4003D9601 /* Frameworks */ = {
isa = PBXGroup;
children = (
FA552637152A63A4003D9601 /* UIKit.framework */,
FA552639152A63A4003D9601 /* Foundation.framework */,
FA5526EB152A6466003D9601 /* Accelerate.framework */,
FA55269D152A6405003D9601 /* Accelerate.framework */,
FA5526EC152A6466003D9601 /* AudioToolbox.framework */,
FA55269E152A6405003D9601 /* AudioToolbox.framework */,
FA5526ED152A6466003D9601 /* AudioUnit.framework */,
FA55269F152A6405003D9601 /* AudioUnit.framework */,
FA5526EE152A6466003D9601 /* CoreAudio.framework */,
FA5526A0152A6405003D9601 /* CoreAudio.framework */,
FA55263B152A63A4003D9601 /* CoreGraphics.framework */,
FA552639152A63A4003D9601 /* Foundation.framework */,
FA552637152A63A4003D9601 /* UIKit.framework */,
FA55265D152A63AE003D9601 /* Cocoa.framework */,
FA55265F152A63AE003D9601 /* Other Frameworks */,
);
Expand Down Expand Up @@ -193,8 +193,8 @@
FA552694152A63F6003D9601 /* Novocaine */ = {
isa = PBXGroup;
children = (
FA2015EC154B0DA700F8D3AC /* AudioFileWriter.m */,
FA2015EB154B0D9B00F8D3AC /* AudioFileWriter.h */,
FA2015EC154B0DA700F8D3AC /* AudioFileWriter.m */,
FA552695152A63F6003D9601 /* Novocaine.h */,
FA552696152A63F6003D9601 /* Novocaine.m */,
FA552697152A63F6003D9601 /* RingBuffer.h */,
Expand Down
1 change: 1 addition & 0 deletions Novocaine/AudioFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
//- (float)getCurrentTime;
- (void)play;
- (void)pause;
- (void)stop;


@end
11 changes: 9 additions & 2 deletions Novocaine/AudioFileReader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ @interface AudioFileReader ()
RingBuffer *ringBuffer;
}

@property RingBuffer *ringBuffer;
@property AudioStreamBasicDescription outputFormat;
@property ExtAudioFileRef inputFile;
@property UInt32 outputBufferSize;
Expand All @@ -52,7 +51,6 @@ - (void)bufferNewAudio;

@implementation AudioFileReader

@synthesize ringBuffer = _ringBuffer;
@synthesize outputFormat = _outputFormat;
@synthesize inputFile = _inputFile;
@synthesize outputBuffer = _outputBuffer;
Expand Down Expand Up @@ -279,5 +277,14 @@ - (void)pause
}
}

- (void)stop
{
// Release the dispatch timer because it holds a reference to this class instance
if (self.callbackTimer) {
dispatch_release(self.callbackTimer);
self.playing = FALSE;
}
}


@end
5 changes: 5 additions & 0 deletions Novocaine/Novocaine.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,16 @@ - (id)init
#pragma mark - Block Handling
- (void)setInputBlock:(InputBlock)newInputBlock
{
InputBlock tmpBlock = inputBlock;
inputBlock = Block_copy(newInputBlock);
Block_release(tmpBlock);
}

- (void)setOutputBlock:(OutputBlock)newOutputBlock
{
OutputBlock tmpBlock = outputBlock;
outputBlock = Block_copy(newOutputBlock);
Block_release(tmpBlock);
}


Expand Down Expand Up @@ -786,6 +790,7 @@ - (void)checkAudioSource {
CFStringRef route;
CheckError( AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &route), "Couldn't check the audio route");
self.inputRoute = (NSString *)route;
CFRelease(route);
NSLog(@"AudioRoute: %@", self.inputRoute);


Expand Down
2 changes: 1 addition & 1 deletion Novocaine/RingBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RingBuffer {
public:
RingBuffer() {};
RingBuffer(SInt64 bufferLength, SInt64 numChannels);
~RingBuffer() {};
~RingBuffer();

void AddNewSInt16AudioBuffer(const AudioBuffer aBuffer);
void AddNewSInt16Data(const SInt16 *newData, const SInt64 numFrames, const SInt64 whichChannel);
Expand Down
9 changes: 7 additions & 2 deletions Novocaine/RingBuffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "RingBuffer.h"


// TODO: teardown function to release mData

RingBuffer::RingBuffer(SInt64 bufferLength, SInt64 numChannels) :
mSizeOfBuffer(bufferLength)
{
Expand All @@ -48,6 +46,13 @@

}

RingBuffer::~RingBuffer()
{
for (int i=0; i<mNumChannels; i++) {
free(mData[i]);
}
}

void RingBuffer::AddNewSInt16AudioBuffer(const AudioBuffer aBuffer)
{

Expand Down

0 comments on commit b056c50

Please sign in to comment.