sp_session_callbacks Struct Reference
[Session handling]

#include <api.h>


Data Fields

void(* logged_in )(sp_session *session, sp_error error)
void(* logged_out )(sp_session *session)
void(* metadata_updated )(sp_session *session)
void(* connection_error )(sp_session *session, sp_error error)
void(* message_to_user )(sp_session *session, const char *message)
void(* notify_main_thread )(sp_session *session)
int(* music_delivery )(sp_session *session, const sp_audioformat *format, const void *frames, int num_frames)
void(* play_token_lost )(sp_session *session)
void(* log_message )(sp_session *session, const char *data)


Detailed Description

Session callbacks

Registered when you create a session. If some callbacks should not be of interest, set them to NULL.

Examples:

jukebox.c, and session.c.


Field Documentation

Called when login has been processed and was successful

Parameters:
[in] session Session
[in] error Error code sp_error

Called when logout has been processed. Either called explicitly if you initialize a logout operation, or implicitly if there is a permanent connection error

Parameters:
[in] session Session

Called whenever metadata has been updated

If you have metadata cached outside of libspotify, you should purge your caches and fetch new versions.

Parameters:
[in] session Session

Called when there is a connection error, and the library has problems reconnecting to the Spotify service. Could be called multiple times (as long as the problem is present)

Parameters:
[in] session Session
[in] error Status code sp_error

void( * sp_session_callbacks::message_to_user)(sp_session *session, const char *message)

Called when the access point wants to display a message to the user

In the desktop client, these are shown in a blueish toolbar just below the search box.

Parameters:
[in] session Session
[in] message String in UTF-8 format.

Called when processing needs to take place on the main thread.

You need to call sp_session_process_events() in the main thread to get libspotify to do more work. Failure to do so may cause request timeouts, or a lost connection.

Parameters:
[in] session Session
Note:
This function is called from an internal session thread - you need to have proper synchronization!

int( * sp_session_callbacks::music_delivery)(sp_session *session, const sp_audioformat *format, const void *frames, int num_frames)

Called when there is decompressed audio data available.

Parameters:
[in] session Session
[in] format Audio format descriptor sp_audioformat
[in] frames Points to raw PCM data as described by format
[in] num_frames Number of available samples in frames.
Returns:
Number of frames consumed. This value can be used to rate limit the output from the library if your output buffers are saturated. The library will retry delivery in about 100ms.
Note:
This function is called from an internal session thread - you need to have proper synchronization!

This function must never block. If your output buffers are full you must return 0 to signal that the library should retry delivery in a short while.

Music has been paused because only one account may play music at the same time.

Parameters:
[in] session Session

void( * sp_session_callbacks::log_message)(sp_session *session, const char *data)

Logging callback.

Parameters:
[in] session Session
[in] data Log data


The documentation for this struct was generated from the following file:

Generated on Tue Apr 7 15:21:55 2009.
Copyright © 2006–2009 Spotify Ltd