summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-27 21:14:52 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-27 21:14:52 +0200
commit8421cfd9886ec5ee19cde18b48853c2f9ea60c29 (patch)
treed4bbbf71976def458ceef1aa029e5ebe7d10af14
parent73b2efa14902f71a88fce4750aa6eef76ed859ae (diff)
downloadpianobar-windows-8421cfd9886ec5ee19cde18b48853c2f9ea60c29.tar.gz
pianobar-windows-8421cfd9886ec5ee19cde18b48853c2f9ea60c29.tar.bz2
pianobar-windows-8421cfd9886ec5ee19cde18b48853c2f9ea60c29.zip
client: Fix "delete station" segfault
Commit af2ceec1e540bae28fdd3ec07158dcd137d3c9da introduced a "fix" for the playback problem after setting curStation = NULL (not selecting a new station). Preserving finishedPlayback and setting url = NULL should fix both bugs.
-rw-r--r--src/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 4a41877..bd3a92c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -287,11 +287,12 @@ int main (int argc, char **argv) {
/* little hack, needed to signal: hey! we need a playlist, but don't
* free anything (there is nothing to be freed yet) */
memset (&player, 0, sizeof (player));
+ player.finishedPlayback = 1;
while (!doQuit) {
/* check whether player finished playing and start playing new
* song */
- if (player.finishedPlayback == 1 || curSong == NULL) {
+ if (player.finishedPlayback == 1) {
/* already played a song, clean up things */
if (player.url != NULL) {
scrobbleSong.length = BarSamplesToSeconds (player.samplerate,
@@ -312,7 +313,10 @@ int main (int argc, char **argv) {
}
WardrobeSongDestroy (&scrobbleSong);
free (player.url);
- memset (&player, 0, sizeof (player));
+ /* we must _not_ NULL the whole player structure (because
+ * of finishedPlayback which may be = 1), but url to
+ * indicate we already freed things; very ugly... */
+ player.url = NULL;
pthread_join (playerThread, NULL);
}
@@ -321,7 +325,7 @@ int main (int argc, char **argv) {
if (curSong != NULL) {
curSong = curSong->next;
}
- if (curSong == NULL && curStation != NULL) {
+ if (curSong == NULL) {
BarUiMsg ("Receiving new playlist... ");
PianoDestroyPlaylist (&ph);
PianoGetPlaylist (&ph, curStation->id);
@@ -344,7 +348,6 @@ int main (int argc, char **argv) {
scrobbleSong.title = strdup (curSong->title);
scrobbleSong.started = time (NULL);
- /* FIXME: why do we need to zero everything again? */
memset (&player, 0, sizeof (player));
player.url = strdup (curSong->audioUrl);