libmpd  11.8.17
Basic

Data Structures

struct  _MpdData
 

Macros

#define __MPD_LIB__
 
#define TRUE   1
 
#define FALSE   0
 

Typedefs

typedef struct _MpdObj MpdObj
 
typedef void(* StatusChangedCallback) (MpdObj *mi, ChangedStatusType what, void *userdata)
 
typedef int(* ErrorCallback) (MpdObj *mi, int id, char *msg, void *userdata)
 
typedef void(* ConnectionChangedCallback) (MpdObj *mi, int connect, void *userdata)
 

Enumerations

enum  MpdError {
  MPD_OK = 0, MPD_ARGS_ERROR = -5, MPD_NOT_CONNECTED = -10, MPD_STATUS_FAILED = -20,
  MPD_LOCK_FAILED = -30, MPD_STATS_FAILED = -40, MPD_SERVER_ERROR = -50, MPD_SERVER_NOT_SUPPORTED = -51,
  MPD_DATABASE_PLAYLIST_EXIST = -60, MPD_PLAYLIST_EMPTY = -70, MPD_PLAYLIST_QUEUE_EMPTY = -75, MPD_PLAYER_NOT_PLAYING = -80,
  MPD_TAG_NOT_FOUND = -90, MPD_PLAYLIST_LOAD_FAILED = -100, MPD_FATAL_ERROR = -1000
}
 
enum  MpdServerCommand { MPD_SERVER_COMMAND_ALLOWED = TRUE, MPD_SERVER_COMMAND_NOT_ALLOWED = FALSE, MPD_SERVER_COMMAND_NOT_SUPPORTED = -1, MPD_SERVER_COMMAND_ERROR = -2 }
 
enum  ChangedStatusType {
  MPD_CST_PLAYLIST = 0x0001, MPD_CST_SONGPOS = 0x0002, MPD_CST_SONGID = 0x0004, MPD_CST_DATABASE = 0x0008,
  MPD_CST_UPDATING = 0x0010, MPD_CST_VOLUME = 0x0020, MPD_CST_TOTAL_TIME = 0x0040, MPD_CST_ELAPSED_TIME = 0x0080,
  MPD_CST_CROSSFADE = 0x0100, MPD_CST_RANDOM = 0x0200, MPD_CST_REPEAT = 0x0400, MPD_CST_AUDIO = 0x0800,
  MPD_CST_STATE = 0x1000, MPD_CST_PERMISSION = 0x2000, MPD_CST_BITRATE = 0x4000, MPD_CST_AUDIOFORMAT = 0x8000,
  MPD_CST_STORED_PLAYLIST = 0x20000, MPD_CST_SERVER_ERROR = 0x40000, MPD_CST_OUTPUT = 0x80000, MPD_CST_STICKER = 0x100000,
  MPD_CST_NEXTSONG = 0x200000, MPD_CST_SINGLE_MODE = 0x400000, MPD_CST_CONSUME_MODE = 0x800000, MPD_CST_REPLAYGAIN = 0x1000000
}
 

Functions

MpdObjmpd_new_default ()
 
MpdObjmpd_new (char *hostname, int port, char *password)
 
int mpd_set_hostname (MpdObj *mi, char *hostname)
 
const char * mpd_get_hostname (MpdObj *mi)
 
int mpd_set_password (MpdObj *mi, const char *password)
 
int mpd_set_port (MpdObj *mi, int port)
 
int mpd_set_connection_timeout (MpdObj *mi, float timeout)
 
int mpd_connect_real (MpdObj *mi, mpd_Connection *connection)
 
int mpd_connect (MpdObj *mi)
 
int mpd_disconnect (MpdObj *mi)
 
int mpd_check_connected (MpdObj *mi)
 
int mpd_check_error (MpdObj *mi)
 
void mpd_free (MpdObj *mi)
 
int mpd_send_password (MpdObj *mi)
 
void mpd_signal_connect_status_changed (MpdObj *mi, StatusChangedCallback status_changed, void *userdata)
 
void mpd_signal_connect_error (MpdObj *mi, ErrorCallback error, void *userdata)
 
void mpd_signal_connect_connection_changed (MpdObj *mi, ConnectionChangedCallback connection_changed, void *userdata)
 

Variables

char * libmpd_version
 

Detailed Description

Macro Definition Documentation

◆ __MPD_LIB__

#define __MPD_LIB__

Definition at line 34 of file libmpd.h.

◆ FALSE

#define FALSE   0

Defined for readability: False is 0.

Definition at line 49 of file libmpd.h.

◆ TRUE

#define TRUE   1

Defined for readability: True is 1.

Definition at line 44 of file libmpd.h.

Typedef Documentation

◆ ConnectionChangedCallback

typedef void(* ConnectionChangedCallback) (MpdObj *mi, int connect, void *userdata)
Parameters
mia MpdObj
connect1 if you are now connected, 0 if you are disconnected.
userdatauser data set when the signal handler was connected. Signal is triggered when the connection state changes.

Definition at line 434 of file libmpd.h.

◆ ErrorCallback

typedef int(* ErrorCallback) (MpdObj *mi, int id, char *msg, void *userdata)
Parameters
mia MpdObj
idThe error Code.
msghuman-readable informative error message.
userdatauser data set when the signal handler was connected. This signal is called when an error has occurred in the communication with mpd.

return: TRUE if libmpd should disconnect.

Examples
testcase.c.

Definition at line 423 of file libmpd.h.

◆ MpdObj

typedef struct _MpdObj MpdObj

The Main Mpd Object. Don't access any of the internal values directly, but use the provided functions.

Definition at line 100 of file libmpd.h.

◆ StatusChangedCallback

typedef void(* StatusChangedCallback) (MpdObj *mi, ChangedStatusType what, void *userdata)
Parameters
mia MpdObj
whata ChangedStatusType that determines what changed triggered the signal. This is a bitmask.
userdatauser data set when the signal handler was connected.

Signal that gets called when the state of mpd has changed. Look ChangedStatusType to see the possible events.

Examples
testcase.c.

Definition at line 409 of file libmpd.h.

Enumeration Type Documentation

◆ ChangedStatusType

Bitwise enumeration to determine what triggered the status_changed signals This is used in combination with the StatusChangedCallback

void status_changed_callback(MpdObj *mi, ChangedStatusType what)
{
if(what&MPD_CST_SONGID)
{
// act on song change
}
if(what&MPD_CST_RANDOM)
{
// act on random change
}
// etc.
}
Enumerator
MPD_CST_PLAYLIST 

The playlist has changed

MPD_CST_SONGPOS 

The song position of the playing song has changed

MPD_CST_SONGID 

The songid of the playing song has changed

MPD_CST_DATABASE 

The database has changed.

MPD_CST_UPDATING 

the state of updating the database has changed.

MPD_CST_VOLUME 

the volume has changed

MPD_CST_TOTAL_TIME 

The total time of the currently playing song has changed

MPD_CST_ELAPSED_TIME 

The elapsed time of the current song has changed.

MPD_CST_CROSSFADE 

The crossfade time has changed.

MPD_CST_RANDOM 

The random state is changed.

MPD_CST_REPEAT 

repeat state is changed.

MPD_CST_AUDIO 

Not implemented

MPD_CST_STATE 

The state of the player has changed.

MPD_CST_PERMISSION 

The permissions the client has, has changed.

MPD_CST_BITRATE 

The bitrate of the playing song has changed.

MPD_CST_AUDIOFORMAT 

the audio format of the playing song changed.

MPD_CST_STORED_PLAYLIST 

the queue has changed

MPD_CST_SERVER_ERROR 

server error

MPD_CST_OUTPUT 

output changed

MPD_CST_STICKER 

Sticker changed

MPD_CST_NEXTSONG 

Next song changed

MPD_CST_SINGLE_MODE 

Single mode changed

MPD_CST_CONSUME_MODE 

Consume mode changed

MPD_CST_REPLAYGAIN 

Replaygain mode changed

Definition at line 349 of file libmpd.h.

◆ MpdError

enum MpdError

Enum that represent the errors libmpd functions can return

Enumerator
MPD_OK 

Command/function completed succesfull

MPD_ARGS_ERROR 

Error in the function's arguments

MPD_NOT_CONNECTED 

Action failed because there is no connection to an mpd daemon

MPD_STATUS_FAILED 

Failed to grab status

MPD_LOCK_FAILED 

Connection is still locked

MPD_STATS_FAILED 

Failed to grab status

MPD_SERVER_ERROR 

Mpd server returned an error

MPD_SERVER_NOT_SUPPORTED 

Mpd doesn't support this feature

MPD_DATABASE_PLAYLIST_EXIST 

The playlist already exists

MPD_PLAYLIST_EMPTY 

Playlist is empty

MPD_PLAYLIST_QUEUE_EMPTY 

Playlist queue is empty

MPD_PLAYER_NOT_PLAYING 

Player isn't Playing

MPD_TAG_NOT_FOUND 

Tag Item not found

MPD_PLAYLIST_LOAD_FAILED 
MPD_FATAL_ERROR 

Fatal error, something I am not sure what todo with

Definition at line 58 of file libmpd.h.

◆ MpdServerCommand

enum that represents the state of a command.

Enumerator
MPD_SERVER_COMMAND_ALLOWED 
MPD_SERVER_COMMAND_NOT_ALLOWED 
MPD_SERVER_COMMAND_NOT_SUPPORTED 
MPD_SERVER_COMMAND_ERROR 

Definition at line 106 of file libmpd.h.

Function Documentation

◆ mpd_check_connected()

int mpd_check_connected ( MpdObj mi)
Parameters
mia MpdObj

Checks if MpdObj is connected

Returns
True when connected

◆ mpd_check_error()

int mpd_check_error ( MpdObj mi)
Parameters
mia MpdObj

Checks if there was an error

Returns
True when there is an error

◆ mpd_connect()

int mpd_connect ( MpdObj mi)
Parameters
mia MpdObj

Connect to the mpd daemon. Warning: mpd_connect connects anonymous, to authenticate use mpd_send_password

Returns
returns a MpdError, MPD_OK when successful
Examples
testcase.c.

◆ mpd_connect_real()

int mpd_connect_real ( MpdObj mi,
mpd_Connection connection 
)

◆ mpd_disconnect()

int mpd_disconnect ( MpdObj mi)
Parameters
miThe MpdObj to disconnect

Disconnect the current connection

Returns
MPD_OK (always)

◆ mpd_free()

void mpd_free ( MpdObj mi)
Parameters
mia MpdObj

Free the MpdObj, when still connected the connection will be disconnected first

Examples
testcase.c.

◆ mpd_get_hostname()

const char* mpd_get_hostname ( MpdObj mi)
Parameters
mia MpdObj

gets the set hostname

Returns
a const char representing the hostname

◆ mpd_new()

MpdObj* mpd_new ( char *  hostname,
int  port,
char *  password 
)
Parameters
hostnameThe hostname to connect to
portThe port to connect to
passwordThe password to use for the connection, or NULL for no password

Create a new MpdObj with provided settings:

Returns
the new MpdObj
Examples
testcase.c.

◆ mpd_new_default()

MpdObj* mpd_new_default ( )

mpd_new_default

Create a new MpdObj with default settings. Hostname will be set to "localhost". Port will be 6600.

same as calling:

mpd_new("localhost",6600,NULL);
Returns
the new MpdObj

◆ mpd_send_password()

int mpd_send_password ( MpdObj mi)
Parameters
mia MpdObj

Forces libmpd to re-authenticate itself.

When successful it will trigger the "permission" changed signal.

Returns
: a MpdError
Examples
testcase.c.

◆ mpd_set_connection_timeout()

int mpd_set_connection_timeout ( MpdObj mi,
float  timeout 
)
Parameters
mia MpdObj
timeoutA timeout (in seconds)

Set the timeout of the connection. If already connected the timeout of the running connection

Returns
a MpdError. (MPD_OK if everything went ok)
Examples
testcase.c.

◆ mpd_set_hostname()

int mpd_set_hostname ( MpdObj mi,
char *  hostname 
)
Parameters
mia MpdObj
hostnameThe new hostname to use

set the hostname

Returns
a MpdError. (MPD_OK if everything went ok)

◆ mpd_set_password()

int mpd_set_password ( MpdObj mi,
const char *  password 
)
Parameters
mia MpdObj
passwordThe new password to use

Set the password

Returns
a MpdError. (MPD_OK if everything went ok)
Examples
testcase.c.

◆ mpd_set_port()

int mpd_set_port ( MpdObj mi,
int  port 
)
Parameters
mia MpdObj
portThe port to use. (Default: 6600)

Set the Port number

Returns
a MpdError. (MPD_OK if everything went ok)

◆ mpd_signal_connect_connection_changed()

void mpd_signal_connect_connection_changed ( MpdObj mi,
ConnectionChangedCallback  connection_changed,
void *  userdata 
)
Parameters
mia MpdObj
connection_changeda ConnectionChangedCallback
userdatauser data passed to the callback

◆ mpd_signal_connect_error()

void mpd_signal_connect_error ( MpdObj mi,
ErrorCallback  error,
void *  userdata 
)
Parameters
mia MpdObj
errora ErrorCallback
userdatauser data passed to the callback
Examples
testcase.c.

◆ mpd_signal_connect_status_changed()

void mpd_signal_connect_status_changed ( MpdObj mi,
StatusChangedCallback  status_changed,
void *  userdata 
)
Parameters
mia MpdObj
status_changeda StatusChangedCallback
userdatauser data passed to the callback
Examples
testcase.c.

Variable Documentation

◆ libmpd_version

char* libmpd_version

Copyright 2006 Qball Cow