From 1c6ddc0b669be4d3a11dfb915a086f44f8f88979 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Wed, 27 Jul 2022 21:10:49 -0400 Subject: cleanup --- moc_library.c | 95 ----------------------------------------------------------- 1 file changed, 95 deletions(-) diff --git a/moc_library.c b/moc_library.c index a76d5aa..7fd484b 100644 --- a/moc_library.c +++ b/moc_library.c @@ -436,102 +436,7 @@ void *moc_loop(void *input) { } } } -void *moc_loop2(void *input) { - struct moc *data = (struct moc*)input; - - int srv_sock = -1; - - srv_sock = moc_server_connect(); - if(srv_sock == -1) { - pthread_mutex_lock(&data->lock); - data->status = FAILED_TO_CONNECT; - pthread_mutex_unlock(&data->lock); - pthread_exit(NULL); - } - data->status = CONNECTED; - - while(1) { - - int state = 0; - int ev = 0; - - while(ev != EV_DATA) { - send_int(srv_sock, CMD_GET_STATE); - if (!get_int(srv_sock, &ev)) { - fprintf(stderr, "Can't get data from the server.\n"); - } - fprintf(stderr, "EVENT: 0x%02x\n", ev); - } - - if(!get_int(srv_sock, &state)) { - fprintf(stderr, "Can't get state from the server!\n"); - } - fprintf(stderr, "Got state%d\n", state); - - pthread_mutex_lock(&data->lock); - if(state == STATE_PLAY) { - data->state = PLAYING; - fprintf(stderr, "moc: playing\n"); - } - if(state == STATE_PAUSE) { - data->state = PAUSED; - fprintf(stderr, "moc: paused\n"); - } - if(state == STATE_STOP) { - data->state = STOPPED; - fprintf(stderr, "moc: stopped\n"); - } - pthread_mutex_unlock(&data->lock); - continue; - - char *file = get_curr_file(srv_sock); - fprintf(stderr, "moc: filename: %s\n", file); - - send_int(srv_sock, CMD_GET_FILE_TAGS); - send_str(srv_sock, file); - send_int(srv_sock,TAGS_COMMENTS | TAGS_TIME); - - // filename first. - if (!(data->filename = get_str(srv_sock))) { - fprintf(stderr, "Error while receiving filename\n"); - } - - if (!(data->title = get_str(srv_sock))) { - fprintf(stderr, "Error while receiving title\n"); - } - - if (!(data->artist = get_str(srv_sock))) { - fprintf(stderr, "Error while receiving artist\n"); - } - - if (!(data->album = get_str(srv_sock))) { - fprintf(stderr, "Error while receiving album\n"); - } - - if (!get_int(srv_sock, &data->track)) { - fprintf(stderr, "Error while receiving track\n"); - } - - if (!get_int(srv_sock, &data->time)) { - fprintf(stderr, "Error while receiving time\n"); - } - - if (!get_int(srv_sock, &data->filled)) { - fprintf(stderr, "Error while receiving filled\n"); - } - - - - fprintf(stderr, "moc: end switch\n"); - - pthread_mutex_unlock(&data->lock); - fprintf(stderr, "end lock\n"); - } - - fprintf(stderr, "moc: end of loop\n"); - return NULL; -} extern struct moc *moc_init() { struct moc *moc = (struct moc*)malloc(sizeof(struct moc)); -- cgit v1.2.1