tumtumtum / StreamingKit

A fast and extensible gapless AudioPlayer/AudioStreamer for OSX and iOS (iPhone, iPad)
Other
2.42k stars 523 forks source link

Play different music in a short period of time,the player can not be stopped #25

Open a363211861 opened 11 years ago

a363211861 commented 11 years ago

In my viewController, call the playInfo: function many times in a short period of time,then pop the viewController(viewDidDisappear: is called),music is still playing。

-(void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated];

[_audioPlayer stop];
_audioPlayer.delegate = nil;
_audioPlayer = nil;

}

-(void)playInfo:(NSDictionary *)info { self.musicInfo = info;

if (_audioPlayer) {
    [_audioPlayer stop];
    _audioPlayer.delegate = nil;
}
_audioPlayer = [[AudioPlayer alloc] init];
_audioPlayer.delegate = self;

NSURL *url = [self getPlayURL:info]; [_audioPlayer setDataSource:[_audioPlayer dataSourceFromURL:url] withQueueItemId:url]; }

a363211861 commented 11 years ago

I found dealloc method of audioPlayer never been called,In my project.  I think the reason may be retain cycle on self with blocks。 such as the code: [fastApiQueue addOperationWithBlock:^ { pthread_mutex_lock(&playerMutex); { ....... [self clearQueue]; ....... } pthread_mutex_unlock(&playerMutex); }];