mirror of
https://github.com/zakk4223/CocoaSplit.git
synced 2026-05-15 14:15:50 -06:00
Added a callback for CAMultiAudio node inputs when they are removed from an engine. This allows the PCM player to clean up the pending deallocation queue.
Chased down some more minor memory leaks in the ffmpeg movie player
This commit is contained in:
parent
d4238c2224
commit
a7c744bf40
6 changed files with 55 additions and 31 deletions
|
|
@ -483,7 +483,6 @@
|
|||
{
|
||||
self.player.asbd = &_asbd;
|
||||
self.player.pcmPlayer = self.pcmPlayer;
|
||||
|
||||
if (self.player.currentlyPlaying)
|
||||
{
|
||||
self.pcmPlayer.name = self.player.currentlyPlaying.shortName;
|
||||
|
|
|
|||
|
|
@ -729,13 +729,18 @@
|
|||
|
||||
if (_video_codec_ctx)
|
||||
{
|
||||
|
||||
avcodec_close(_video_codec_ctx);
|
||||
avcodec_free_context(&_video_codec_ctx);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (_audio_codec_ctx)
|
||||
{
|
||||
avcodec_close(_audio_codec_ctx);
|
||||
avcodec_free_context(&_audio_codec_ctx);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@
|
|||
@autoreleasepool {
|
||||
if (self.paused)
|
||||
{
|
||||
[self.pcmPlayer pause];
|
||||
//[self.pcmPlayer pause];
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -740,7 +740,6 @@
|
|||
-(void)dealloc
|
||||
{
|
||||
|
||||
NSLog(@"DEALLOC PLAYER %@", self.currentlyPlaying);
|
||||
|
||||
if (self.currentlyPlaying)
|
||||
{
|
||||
|
|
@ -749,7 +748,6 @@
|
|||
|
||||
for (CSFFMpegInput *item in self.inputQueue)
|
||||
{
|
||||
NSLog(@"ITEM %@", item);
|
||||
[item closeMedia];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -918,6 +918,9 @@ OSStatus encoderRenderCallback( void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
[self removeObjectFromAudioInputsAtIndex:index];
|
||||
|
||||
});
|
||||
|
||||
[toRemove didRemoveInput];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
// CocoaSplit
|
||||
//
|
||||
// Created by Zakk on 7/30/17.
|
||||
// Copyright © 2017 Zakk. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CAMultiAudioNode.h"
|
||||
|
|
@ -24,6 +23,7 @@
|
|||
|
||||
-(void)openMixerWindow:(id)sender;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -39,5 +39,6 @@
|
|||
@property (assign) bool noSettings;
|
||||
@property (assign) bool systemDevice;
|
||||
|
||||
-(void)didRemoveInput;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -78,42 +78,56 @@ void BufferCompletedPlaying(void *userData, ScheduledAudioSlice *bufferList);
|
|||
{
|
||||
|
||||
@autoreleasepool {
|
||||
int32_t availBytes;
|
||||
void *pcmPtr = NULL;
|
||||
while ((pcmPtr = TPCircularBufferTail(&(self->_completedBuffer), &availBytes)))
|
||||
{
|
||||
struct cspcm_buffer_msg *cMsg = pcmPtr;
|
||||
|
||||
CAMultiAudioPCM *pcmObj = (__bridge CAMultiAudioPCM *)(cMsg->pcmObj);
|
||||
if (cMsg->msgPtr)
|
||||
int32_t availBytes;
|
||||
void *pcmPtr = NULL;
|
||||
while ((pcmPtr = TPCircularBufferTail(&(self->_completedBuffer), &availBytes)))
|
||||
{
|
||||
free(cMsg->msgPtr);
|
||||
struct cspcm_buffer_msg *cMsg = pcmPtr;
|
||||
|
||||
CAMultiAudioPCM *pcmObj = (__bridge CAMultiAudioPCM *)(cMsg->pcmObj);
|
||||
if (cMsg->msgPtr)
|
||||
{
|
||||
free(cMsg->msgPtr);
|
||||
}
|
||||
|
||||
if (self.completedBlock)
|
||||
{
|
||||
self.completedBlock(pcmObj);
|
||||
}
|
||||
|
||||
if (self.save_buffer)
|
||||
{
|
||||
[self.pauseBuffer addObject:pcmObj];
|
||||
} else {
|
||||
[self releasePCM:pcmObj];
|
||||
}
|
||||
TPCircularBufferConsume(&(self->_completedBuffer), sizeof(struct cspcm_buffer_msg));
|
||||
|
||||
}
|
||||
|
||||
if (self.completedBlock)
|
||||
{
|
||||
self.completedBlock(pcmObj);
|
||||
}
|
||||
|
||||
if (self.save_buffer)
|
||||
{
|
||||
[self.pauseBuffer addObject:pcmObj];
|
||||
} else {
|
||||
[self releasePCM:pcmObj];
|
||||
}
|
||||
TPCircularBufferConsume(&(self->_completedBuffer), sizeof(struct cspcm_buffer_msg));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (self->_exitPending)
|
||||
@synchronized(self)
|
||||
{
|
||||
return;
|
||||
if (self->_exitPending)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
usleep(20);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
-(void)didRemoveInput
|
||||
{
|
||||
@synchronized(self)
|
||||
{
|
||||
_exitPending = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(bool)playPcmBuffer:(CAMultiAudioPCM *)pcmBuffer
|
||||
{
|
||||
|
||||
|
|
@ -367,12 +381,16 @@ void BufferCompletedPlaying(void *userData, ScheduledAudioSlice *bufferList);
|
|||
|
||||
-(void)dealloc
|
||||
{
|
||||
|
||||
NSLog(@"DEALLOC PCM PLAYER");
|
||||
[self flush];
|
||||
_pendingBuffers = nil;
|
||||
if (_inputFormat)
|
||||
{
|
||||
free(_inputFormat);
|
||||
}
|
||||
|
||||
TPCircularBufferCleanup(&_completedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue