Question

I'm using CocoaLibSpotify and the SPPlaybackManager to stream Spotify music to my app. It works very well overall, but I'm experiencing some issues with the playback during other network activity.

Procedure:

  1. (During audio playback) I'm firing a regular ASIHTTPRequest to a server.
  2. When the request has finished, I'm making a number of Spotify searches using SPSearch.
  3. On many devices (in particular iPhone 3GS), I'm getting massive "stuttering"/"skips"/"pauses" in the playback while the Searches are performed.

Earlier, I used regular ASIHTTPRequests instead of the SPSearch class, so I'm quite sure it's got to do with the overall network activity.

Also, the playback issues may appear while doing some other network activity on the device, i.e. loading a number of emails in the Mail app.

Threading?

I'm guessing this is some kind of threading issue (i.e. the audio is played back on the main thread or something), but I'm not sure exactly how to approach the issue... I've tried invoking SPPlaybackManager#playTrack:: on a background thread, but I guess the setup wasn't 100% correct (since the issues remained).

Does anyone have any pointers as to how I should move forward?

Was it helpful?

Solution

Both the audio delivery and audio playback in the classes supplied with CocoaLibSpotify are run on (different) background threads. However, SPPlaybackManager is only intended to be an easy-to-follow example of dealing with audio playback using Core Audio - it hasn't been tested for, nor is it intended for, use during high CPU load and/or in environments very tight on resources.

All I can do is point you towards the standard debugging tools such as Instruments to trace and profile what's going on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top