ios - cocoalibspotify: Crash during playback callback under music_delivery -


we have crashes when playing using cocoalibspotify: problem looks in callback function music_delivery() under spsession.m, instance initiated callback not spsessionaudiodeliverydelegate compatible instance. however, playback related instance used spplaybackmanager. , function used play song using spotify is:

#pragma mark - domain function - (void)searchforkeywords:(nsstring *)keywords{     //construct search string     spsearch *search = [[spsearch alloc] initwithsearchquery:keywords insession:[spsession sharedsession]];      //search track     [spasyncloading waituntilloaded:search timeout:kspasyncloadingdefaulttimeout then:^(nsarray *results, nsarray *notloadedresults) {     if ([results count]>0) {         //search returns results.         spsearch *thissearch = [results objectatindex:0];         if ([[thissearch tracks] count]>0) {              // add loading flag album art             [[imagemanager sharedinstance] setloadingflagforsong:self.namedsong];              sptrack *track = [[thissearch tracks]objectatindex:0];              [spasyncloading waituntilloaded:track timeout:kspasyncloadingdefaulttimeout then:^(nsarray *tracks, nsarray *notloadedtracks) {                  self.currenttrack = track;             }];         }else{         }      }else{         //search didn't return results.     }     }]; }  - (void)play { [spsession dispatchtolibspotifythread:^{     [[spsession sharedsession]setplaybackdelegate:self];      // change current track of session     if (currenttrack) {          self.playbackmanager = [[spplaybackmanager alloc] initwithplaybacksession:[spsession sharedsession]];         [[spsession sharedsession]setplaybackdelegate:self];          [self.playbackmanager playtrack:currenttrack callback:^(nserror *error) {              // failure playing             if (error) {             }             // success         }];     }      // play     else {     } }]; }  - (void)pause { [spsession dispatchtolibspotifythread:^{     [spotifyhelper sharedinstance].playbackmanager.isplaying = no; } waituntildone:yes]; }   - (void)stop { [spsession dispatchtolibspotifythread:^{     [spotifyhelper sharedinstance].playbackmanager.isplaying = no;     [[spotifyhelper sharedinstance].playbackmanager sessiondidendplayback:[spsession sharedsession]]; } waituntildone:yes]; }  -(void)seektolocation:(float)location { [spsession dispatchtolibspotifythread:^{     [[spotifyhelper sharedinstance].playbackmanager seektotrackposition:location * self.currenttrack.duration]; } waituntildone:yes]; } 

the error message: -[__nscftype session:shoulddeliveraudioframes:ofcount:streamdescription:]: unrecognized selector sent instance 0x21328a90

stack: 0    libsystem_kernel.dylib  __pthread_kill + 8 1    libsystem_c.dylib   pthread_kill + 58 2    libsystem_c.dylib   abort + 94 3    libc++abi.dylib     abort_message + 74 4    libc++abi.dylib     default_terminate() + 24 5    libobjc.a.dylib     _objc_terminate() + 146 6    libc++abi.dylib     safe_handler_caller(void (*)()) + 78 7    libc++abi.dylib     std::terminate() + 19 8    libc++abi.dylib     __cxa_throw + 122 9    libobjc.a.dylib     objc_exception_throw + 94 10   corefoundation  __methoddescriptionforselector 11   corefoundation  ___forwarding___ + 392 12   corefoundation  _cf_forwarding_prep_0 + 24 crash->13    ourapp      music_delivery 14   ourapp  sp_playlist_get_offline_download_completed 15   ourapp  sp_error_message 16   ourapp  sp_error_message 

two things:

1) don't dispatch cocoalibspotify thread when calling cocoalibspotify methods — that's done internally. remove dispatchtolibspotifythread line.

2) remove [[spsession sharedsession]setplaybackdelegate:self]; line. that's what's causing crash.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -