Skip to content

Commit ad25d10

Browse files
authored
1 parent f0a0bb8 commit ad25d10

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/ios/CDVSound.m

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,13 +836,31 @@ -(void)itemStalledPlaying:(NSNotification *) notification {
836836

837837
- (void)onMemoryWarning
838838
{
839-
[[self soundCache] removeAllObjects];
840-
[self setSoundCache:nil];
839+
/* https://issues.apache.org/jira/browse/CB-11513 */
840+
NSMutableArray* keysToRemove = [[NSMutableArray alloc] init];
841+
842+
for(id key in [self soundCache]) {
843+
CDVAudioFile* audioFile = [[self soundCache] objectForKey:key];
844+
if (audioFile != nil) {
845+
if (audioFile.player != nil && ![audioFile.player isPlaying]) {
846+
[keysToRemove addObject:key];
847+
}
848+
if (audioFile.recorder != nil && ![audioFile.recorder isRecording]) {
849+
[keysToRemove addObject:key];
850+
}
851+
}
852+
}
853+
854+
[[self soundCache] removeObjectsForKeys:keysToRemove];
855+
856+
// [[self soundCache] removeAllObjects];
857+
// [self setSoundCache:nil];
841858
[self setAvSession:nil];
842859

843860
[super onMemoryWarning];
844861
}
845862

863+
846864
- (void)dealloc
847865
{
848866
[[self soundCache] removeAllObjects];

0 commit comments

Comments
 (0)