converted PlayerControl.state to enum
Don't write CPP when you can express the same in C... macros vs enum is a good example for that.
This commit is contained in:
parent
efde884a13
commit
b1de50f994
@ -148,6 +148,9 @@ int playerPause(mpd_unused int fd)
|
|||||||
int playerSetPause(int fd, int pause_flag)
|
int playerSetPause(int fd, int pause_flag)
|
||||||
{
|
{
|
||||||
switch (pc.state) {
|
switch (pc.state) {
|
||||||
|
case PLAYER_STATE_STOP:
|
||||||
|
break;
|
||||||
|
|
||||||
case PLAYER_STATE_PLAY:
|
case PLAYER_STATE_PLAY:
|
||||||
if (pause_flag)
|
if (pause_flag)
|
||||||
playerPause(fd);
|
playerPause(fd);
|
||||||
@ -176,7 +179,7 @@ int getPlayerTotalTime(void)
|
|||||||
return (int)(pc.totalTime + 0.5);
|
return (int)(pc.totalTime + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPlayerState(void)
|
enum player_state getPlayerState(void)
|
||||||
{
|
{
|
||||||
return pc.state;
|
return pc.state;
|
||||||
}
|
}
|
||||||
|
12
src/player.h
12
src/player.h
@ -24,9 +24,11 @@
|
|||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
#define PLAYER_STATE_STOP 0
|
enum player_state {
|
||||||
#define PLAYER_STATE_PAUSE 1
|
PLAYER_STATE_STOP = 0,
|
||||||
#define PLAYER_STATE_PLAY 2
|
PLAYER_STATE_PAUSE,
|
||||||
|
PLAYER_STATE_PLAY
|
||||||
|
};
|
||||||
|
|
||||||
enum player_command {
|
enum player_command {
|
||||||
PLAYER_COMMAND_NONE = 0,
|
PLAYER_COMMAND_NONE = 0,
|
||||||
@ -62,7 +64,7 @@ enum player_command {
|
|||||||
typedef struct _PlayerControl {
|
typedef struct _PlayerControl {
|
||||||
Notify notify;
|
Notify notify;
|
||||||
volatile enum player_command command;
|
volatile enum player_command command;
|
||||||
volatile mpd_sint8 state;
|
volatile enum player_state state;
|
||||||
volatile mpd_sint8 error;
|
volatile mpd_sint8 error;
|
||||||
volatile mpd_uint16 bitRate;
|
volatile mpd_uint16 bitRate;
|
||||||
volatile mpd_sint8 bits;
|
volatile mpd_sint8 bits;
|
||||||
@ -99,7 +101,7 @@ int getPlayerElapsedTime(void);
|
|||||||
|
|
||||||
unsigned long getPlayerBitRate(void);
|
unsigned long getPlayerBitRate(void);
|
||||||
|
|
||||||
int getPlayerState(void);
|
enum player_state getPlayerState(void);
|
||||||
|
|
||||||
void clearPlayerError(void);
|
void clearPlayerError(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user