playerData: move player_pid into the main playerData structure

No point in doing all that extra work for one variable...

git-svn-id: https://svn.musicpd.org/mpd/trunk@4511 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong 2006-08-01 04:18:48 +00:00
parent 5aca21a502
commit 2532bc36d2
2 changed files with 3 additions and 20 deletions

View File

@ -34,7 +34,6 @@ int buffered_chunks;
#define DEFAULT_BUFFER_BEFORE_PLAY 0 #define DEFAULT_BUFFER_BEFORE_PLAY 0
static PlayerData *playerData_pd; static PlayerData *playerData_pd;
int *player_pid;
void initPlayerData(void) void initPlayerData(void)
{ {
@ -104,22 +103,6 @@ void initPlayerData(void)
ERROR("problems shmctl'ing\n"); ERROR("problems shmctl'ing\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* maybe the following should be put in the same shm block as the previous
* or maybe even made a part of the playerData struct
*/
allocationSize = sizeof(int);
if ((shmid = shmget(IPC_PRIVATE, allocationSize, IPC_CREAT | 0600)) < 0) {
ERROR("problems shmget'ing\n");
exit(EXIT_FAILURE);
}
if (!(player_pid = shmat(shmid, NULL, 0))) {
ERROR("problems shmat'ing\n");
exit(EXIT_FAILURE);
}
if (shmctl(shmid, IPC_RMID, NULL) < 0) {
ERROR("problems shmctl'ing\n");
exit(EXIT_FAILURE);
}
buffer = &(playerData_pd->buffer); buffer = &(playerData_pd->buffer);
@ -172,16 +155,15 @@ PlayerData *getPlayerData(void)
int getPlayerPid(void) int getPlayerPid(void)
{ {
return *player_pid; return playerData_pd->pid;
} }
void setPlayerPid(int pid) void setPlayerPid(int pid)
{ {
*player_pid = pid; playerData_pd->pid = pid;
} }
void freePlayerData(void) void freePlayerData(void)
{ {
shmdt(playerData_pd); shmdt(playerData_pd);
shmdt(player_pid);
} }

View File

@ -38,6 +38,7 @@ typedef struct _PlayerData {
PlayerControl playerControl; PlayerControl playerControl;
DecoderControl decoderControl; DecoderControl decoderControl;
mpd_sint8 audioDeviceEnabled[AUDIO_MAX_DEVICES]; mpd_sint8 audioDeviceEnabled[AUDIO_MAX_DEVICES];
int pid;
} PlayerData; } PlayerData;
void initPlayerData(); void initPlayerData();