Added clear playlist command.
This commit is contained in:
parent
c6edaa4382
commit
d0eaa14b8c
5 changed files with 30 additions and 6 deletions
|
@ -90,7 +90,7 @@ Guides for other distibutions will appear in future. If you know one, feel free
|
|||
## TODO
|
||||
|
||||
- [x] Add pause command
|
||||
- [ ] Add clear playlist command
|
||||
- [x] Add clear playlist command
|
||||
- [ ] Add navigation inside song
|
||||
- [ ] Add notification support
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define FORWARD 'f'
|
||||
#define BACKWARD 'b'
|
||||
#define PAUSE 'p'
|
||||
#define CLEAR 'c'
|
||||
#define NEWLINE '\n'
|
||||
|
||||
#endif /* __COMMANDS_H__ */
|
||||
|
|
|
@ -3,7 +3,7 @@ PREFIX = /usr/local
|
|||
MANPREFIX = $(PREFIX)/share/man
|
||||
|
||||
# Name of program
|
||||
VERSION = 1.2.0
|
||||
VERSION = 1.3.0
|
||||
NAME = pipeplayer
|
||||
|
||||
# Compiler
|
||||
|
|
|
@ -25,6 +25,8 @@ free_playlist(struct playlist *playlist)
|
|||
|
||||
// Clear playlist dir
|
||||
free(playlist->dir);
|
||||
|
||||
playlist->need_free = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
29
threads.c
29
threads.c
|
@ -55,6 +55,7 @@ play_thread(void *vargp)
|
|||
|
||||
for (; playlist->index < playlist->length; playlist->index++) {
|
||||
prepare_to_play(player, playlist->array[playlist->index]);
|
||||
LOG_INFO("Playing %s", playlist->array[playlist->index]);
|
||||
play(player);
|
||||
|
||||
// If paused
|
||||
|
@ -62,6 +63,7 @@ play_thread(void *vargp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
free_playlist(playlist);
|
||||
playlist->need_cancel = false;
|
||||
player->playing = false;
|
||||
|
||||
|
@ -118,25 +120,43 @@ input_thread(void *vargp)
|
|||
_restart_playlist_thread(playlist, vargp);
|
||||
break;
|
||||
|
||||
|
||||
// Only when playlist is loaded
|
||||
case CLEAR:
|
||||
LOG_DEBUG("Case: CLEAR");
|
||||
|
||||
if (!playlist->need_cancel)
|
||||
break;
|
||||
free_playlist(playlist);
|
||||
pthread_cancel(*thread_player);
|
||||
playlist->need_cancel = false;
|
||||
break;
|
||||
|
||||
case FORWARD:
|
||||
LOG_DEBUG("Case: FORWARD");
|
||||
|
||||
if (!playlist->need_cancel)
|
||||
break;
|
||||
|
||||
playlist->index = (playlist->index + 1) % playlist->length;
|
||||
_restart_playlist_thread(playlist, vargp);
|
||||
break;
|
||||
|
||||
case BACKWARD:
|
||||
LOG_DEBUG("Case: BACKWARD");
|
||||
|
||||
if (!playlist->need_cancel)
|
||||
break;
|
||||
|
||||
playlist->index = (playlist->index + playlist->length - 1) % playlist->length;
|
||||
_restart_playlist_thread(playlist, vargp);
|
||||
break;
|
||||
|
||||
case PAUSE:
|
||||
LOG_DEBUG("Case: PAUSE");
|
||||
// Pause only if playlist need cancel (play something)
|
||||
if (!playlist->need_cancel) {
|
||||
LOG_DEBUG("Skip pause");
|
||||
|
||||
if (!playlist->need_cancel)
|
||||
break;
|
||||
}
|
||||
|
||||
if (player->playing)
|
||||
player->playing = false;
|
||||
|
@ -144,6 +164,7 @@ input_thread(void *vargp)
|
|||
pthread_create(thread_player, NULL, play_thread, vargp);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unknown command: %s\n", command);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue