From 122ad60512559f1d9f763370e3a4ab878dff339c Mon Sep 17 00:00:00 2001 From: svpdev Date: Sat, 10 May 2014 14:12:07 +0400 Subject: [PATCH 1/4] Leaks corrections in EZMicrophone --- EZAudio/EZMicrophone.m | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/EZAudio/EZMicrophone.m b/EZAudio/EZMicrophone.m index eaaa2009..4dc2d973 100644 --- a/EZAudio/EZMicrophone.m +++ b/EZAudio/EZMicrophone.m @@ -603,4 +603,34 @@ -(void)_disableCallbackBufferAllocation { operation:"Could not disable audio unit allocating its own buffers"]; } +#pragma mark De-allocation + +-(void) dealloc{ + + if(_isConfigured){ + + //stops fetching if it it is ongoing + if(_isFetching) + [self stopFetchingAudio]; + + //inputCallback shall be unregistered before de-allocation. + // Otherwise BAD_ACCESS within inputCallback happens while attempting to access _microphone through (__bridge EZMicrophone*)inRefCon + [EZAudio checkResult: + AudioUnitRemoveRenderNotify (microphoneInput, inputCallback, (__bridge void *)self) + operation:"Couldn't unregister input callback"]; + + //free microphoneInputBuffer to avoid memory leaks + [EZAudio freeBufferList:microphoneInputBuffer]; + + //free float buffers allocated in _configureFloatConverterWithFrameSize + for ( int i=0; i Date: Sat, 10 May 2014 14:12:07 +0400 Subject: [PATCH 2/4] INFI-64 Added: - EZAudio - VSVoiceController - controllerMode switch - to be worked out further - Added EZAudioPlayer and corrected - working on EZRecorder's re-opening of the AudioFile --- EZAudio/EZAudioPlayer.m | 22 +++++++++++++++--- EZAudio/EZMicrophone.m | 30 ++++++++++++++++++++++++ EZAudio/EZRecorder.h | 7 ++++++ EZAudio/EZRecorder.m | 51 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 3 deletions(-) diff --git a/EZAudio/EZAudioPlayer.m b/EZAudio/EZAudioPlayer.m index 56347ed0..f539f709 100644 --- a/EZAudio/EZAudioPlayer.m +++ b/EZAudio/EZAudioPlayer.m @@ -245,6 +245,13 @@ -(void)stop { [_output stopPlayback]; [_audioFile seekToFrame:0]; _eof = NO; + + if( self.audioPlayerDelegate ){ + if( [self.audioPlayerDelegate respondsToSelector:@selector(audioPlayer:didPausePlaybackOnAudioFile:)] ){ + // Notify the delegate we're pausing playback + [self.audioPlayerDelegate audioPlayer:self didPausePlaybackOnAudioFile:_audioFile]; + } + } } } @@ -286,10 +293,19 @@ -(void) output:(EZOutput *)output audioBufferList:audioBufferList bufferSize:&bufferSize eof:&_eof]; - if( _eof && self.shouldLoop ) - { - [self seekToFrame:0]; + if(_eof ){ + + //Notifies delegate about _eof + if(self.audioPlayerDelegate) + if ([self.audioPlayerDelegate respondsToSelector:@selector(audioPlayer:reachedEndOfAudioFile:)]) + [self.audioPlayerDelegate audioPlayer:self reachedEndOfAudioFile:self.audioFile]; + + //loops the playback if needed + if(self.shouldLoop ) + [self seekToFrame:0]; } + + } } diff --git a/EZAudio/EZMicrophone.m b/EZAudio/EZMicrophone.m index eaaa2009..4dc2d973 100644 --- a/EZAudio/EZMicrophone.m +++ b/EZAudio/EZMicrophone.m @@ -603,4 +603,34 @@ -(void)_disableCallbackBufferAllocation { operation:"Could not disable audio unit allocating its own buffers"]; } +#pragma mark De-allocation + +-(void) dealloc{ + + if(_isConfigured){ + + //stops fetching if it it is ongoing + if(_isFetching) + [self stopFetchingAudio]; + + //inputCallback shall be unregistered before de-allocation. + // Otherwise BAD_ACCESS within inputCallback happens while attempting to access _microphone through (__bridge EZMicrophone*)inRefCon + [EZAudio checkResult: + AudioUnitRemoveRenderNotify (microphoneInput, inputCallback, (__bridge void *)self) + operation:"Couldn't unregister input callback"]; + + //free microphoneInputBuffer to avoid memory leaks + [EZAudio freeBufferList:microphoneInputBuffer]; + + //free float buffers allocated in _configureFloatConverterWithFrameSize + for ( int i=0; i Date: Tue, 13 May 2014 22:23:35 +0400 Subject: [PATCH 3/4] Restored EZRecorder to initial state --- EZAudio/EZRecorder.h | 7 ------ EZAudio/EZRecorder.m | 51 -------------------------------------------- 2 files changed, 58 deletions(-) diff --git a/EZAudio/EZRecorder.h b/EZAudio/EZRecorder.h index dd913728..31ca8d04 100644 --- a/EZAudio/EZRecorder.h +++ b/EZAudio/EZRecorder.h @@ -92,8 +92,6 @@ typedef NS_ENUM(NSInteger, EZRecorderFileType) ///----------------------------------------------------------- /// @name Getting The Recorder's Properties ///----------------------------------------------------------- - - /** Provides the file path that's currently being used by the recorder. @return The NSURL representing the file path of the audio file path being used for recording. @@ -122,9 +120,4 @@ typedef NS_ENUM(NSInteger, EZRecorderFileType) */ -(void)closeAudioFile; -/** - Re-opens the audio file for writing. - */ -- (void)openAudioFile; - @end \ No newline at end of file diff --git a/EZAudio/EZRecorder.m b/EZAudio/EZRecorder.m index 72bb9b53..e6c76263 100644 --- a/EZAudio/EZRecorder.m +++ b/EZAudio/EZRecorder.m @@ -26,7 +26,6 @@ #import "EZRecorder.h" #import "EZAudio.h" -#import "VSMacros.h" @interface EZRecorder (){ ExtAudioFileRef _destinationFile; @@ -178,56 +177,6 @@ -(void)closeAudioFile // Null out the file reference _destinationFile = NULL; } -} - --(void) openAudioFile{ - - - if(_destinationFile) return; - - AudioFileID audioFileID; - [EZAudio checkResult:AudioFileOpenURL(_destinationFileURL, kAudioFileReadWritePermission, 0, &audioFileID) - operation:"Could not open audio file"]; - - UInt64 totalPackets; - UInt32 size = sizeof(totalPackets); - [EZAudio checkResult:AudioFileGetProperty(audioFileID, kAudioFilePropertyAudioDataPacketCount,&size, &totalPackets) - operation:"Could not get totalPackets"]; - - //check if the file has been optimized for appending - UInt32 isOptimized=0; - size = sizeof(isOptimized); - [EZAudio checkResult:AudioFileGetProperty(audioFileID, kAudioFilePropertyIsOptimized, &size, &isOptimized) - operation:"Could not get info if the file is optimized"]; - - if (isOptimized != 1 ){ - [EZAudio checkResult:AudioFileOptimize(audioFileID) - operation:"Could not optimize the file"]; - VSLog(@"Optimized"); - } - - [EZAudio checkResult:ExtAudioFileWrapAudioFileID(audioFileID, true, &_destinationFile) - operation:"Could not wrap with ExtAudioFile"]; - - // Set the client format (which should be equal to the source format) - [EZAudio checkResult:ExtAudioFileSetProperty(_destinationFile, - kExtAudioFileProperty_ClientDataFormat, - sizeof(_sourceFormat), - &_sourceFormat) - operation:"Failed to set client format on recorded audio file"]; - - - - -// SInt64 totalFrames; -// size = sizeof(totalFrames); -// [EZAudio checkResult:ExtAudioFileGetProperty(_destinationFile,kExtAudioFileProperty_FileLengthFrames, &size, &totalFrames) -// operation:"Failed to get total frames of input file"]; -// -// [EZAudio checkResult:ExtAudioFileSeek(_destinationFile, MAX(1,totalFrames-2)) operation:"Can't seek to the last frame"]; - - - } -(NSURL *)url From 964a043956cbbe6f4cae626c2291a63a883b79ae Mon Sep 17 00:00:00 2001 From: svpdev Date: Wed, 21 May 2014 00:07:31 +0400 Subject: [PATCH 4/4] INFI-104 Rework NoteVC: dynamic tableview; Booking.com-like style - added reload data in NoteCell:didTransitionFromLayout:toLayout: - added SingleNoteVC, NoteCellBase - added menu to SingleNoteVC - renamed SingleNoteVC... to NoteVC; NoteVC renamed to NoteVCOld - added NoteCellText, NoteCellTags - added NoteCellImages; updated ItemsCVDataProvider and Item+Operations - added NoteCellAudio, AudioPlayerController; refactored AudioRecorderController. NoteCellAudio is visible in NoteVC. Finally :) - shows AudioPlayerController when audio cell is selected; EZPlot - changed backGround color and clipping --- EZAudio/EZAudioFile.m | 2 +- EZAudio/EZAudioPlot.m | 7 ++++--- EZAudio/EZAudioPlotGL.m | 6 ++++-- EZAudio/EZPlot.h | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/EZAudio/EZAudioFile.m b/EZAudio/EZAudioFile.m index d3a03fa4..692f2345 100644 --- a/EZAudio/EZAudioFile.m +++ b/EZAudio/EZAudioFile.m @@ -149,7 +149,7 @@ -(void)_configureAudioFile { _floatBuffers[i] = (float*)malloc(outputBufferSize); } - [EZAudio printASBD:_fileFormat]; +// [EZAudio printASBD:_fileFormat]; // There's no waveform data yet _waveformData = NULL; diff --git a/EZAudio/EZAudioPlot.m b/EZAudio/EZAudioPlot.m index 2f17363d..b9cf2697 100644 --- a/EZAudio/EZAudioPlot.m +++ b/EZAudio/EZAudioPlot.m @@ -41,7 +41,7 @@ @interface EZAudioPlot () { @end @implementation EZAudioPlot -@synthesize backgroundColor = _backgroundColor; +//@synthesize backgroundColor = _backgroundColor; @synthesize color = _color; @synthesize gain = _gain; @synthesize plotType = _plotType; @@ -96,8 +96,9 @@ -(void)initPlot { #pragma mark - Setters -(void)setBackgroundColor:(id)backgroundColor { - _backgroundColor = backgroundColor; - [self _refreshDisplay]; + + [super setBackgroundColor:backgroundColor]; + [self _refreshDisplay]; } -(void)setColor:(id)color { diff --git a/EZAudio/EZAudioPlotGL.m b/EZAudio/EZAudioPlotGL.m index 1a73390f..efe9b8a6 100644 --- a/EZAudio/EZAudioPlotGL.m +++ b/EZAudio/EZAudioPlotGL.m @@ -77,7 +77,7 @@ @implementation EZAudioPlotGL #elif TARGET_OS_MAC @synthesize baseEffect = _baseEffect; #endif -@synthesize backgroundColor = _backgroundColor; +//@synthesize backgroundColor = _backgroundColor; @synthesize color = _color; @synthesize gain = _gain; @synthesize plotType = _plotType; @@ -137,7 +137,9 @@ -(void)initializeView { #pragma mark - Setters -(void)setBackgroundColor:(id)backgroundColor { - _backgroundColor = backgroundColor; + + [super setBackgroundColor:backgroundColor]; + #if TARGET_OS_IPHONE self.glViewController.backgroundColor = backgroundColor; #elif TARGET_OS_MAC diff --git a/EZAudio/EZPlot.h b/EZAudio/EZPlot.h index 121b6eac..fa13fc12 100644 --- a/EZAudio/EZPlot.h +++ b/EZAudio/EZPlot.h @@ -64,7 +64,7 @@ typedef NS_ENUM(NSInteger,EZPlotType){ /** The default background color of the plot. For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is black. */ -@property (nonatomic,strong) id backgroundColor; +//@property (nonatomic,copy) id backgroundColor; /** The default color of the plot's data (i.e. waveform, y-axis values). For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is red.