void mpdc_destroy() { mpd_closeConnection(mpdz); mpdz = NULL; mpd_active = 0; }
int mpd_disconnect(MpdObj *mi) { /* lock */ mpd_lock_conn(mi); debug_printf(DEBUG_INFO, "disconnecting\n"); if(mi->connection) { mpd_closeConnection(mi->connection); mi->connection = NULL; } if(mi->status) { mpd_freeStatus(mi->status); mi->status = NULL; } if(mi->stats) { mpd_freeStats(mi->stats); mi->stats = NULL; } if(mi->CurrentSong) { mpd_freeSong(mi->CurrentSong); mi->CurrentSong = NULL; } mi->CurrentState.playlistid = -1; mi->CurrentState.queueid = -2; mi->CurrentState.storedplaylistid = -1; mi->CurrentState.state = -1; mi->CurrentState.songid = -1; mi->CurrentState.songpos = -1; mi->CurrentState.dbUpdateTime = 0; mi->CurrentState.updatingDb = 0; mi->CurrentState.repeat = -1; mi->CurrentState.random = -1; mi->CurrentState.volume = -2; mi->CurrentState.xfade = -1; mi->CurrentState.totaltime = 0; mi->CurrentState.elapsedtime = 0; mi->CurrentState.bitrate = 0; mi->CurrentState.samplerate = 0; mi->CurrentState.channels = 0; mi->CurrentState.bits = 0; mi->CurrentState.playlistLength = 0; mi->CurrentState.error[0] = '\0'; /* search stuff */ mi->search_type = MPD_SEARCH_TYPE_NONE; /* no need to initialize, but set it to anything anyway*/ mi->search_field = MPD_TAG_ITEM_ARTIST; memcpy(&(mi->OldState), &(mi->CurrentState) , sizeof(MpdServerState)); mpd_free_queue_ob(mi); mpd_server_free_commands(mi); /*don't reset errors */ /* Remove this signal, we don't actually disconnect */ if(mi->connected) { /* set disconnect flag */ mi->connected = FALSE; if(mi->the_connection_changed_callback != NULL) { mi->the_connection_changed_callback( mi, FALSE, mi->the_connection_changed_signal_userdata ); } } debug_printf(DEBUG_INFO, "Disconnect completed\n"); return MPD_OK; }