fix a stupid bug where i was storing the decode_pid directorly from fork()

call, and since decode_pid is shared now, it may get assigned zero after
the parent assigns it the true pid, not good!!

git-svn-id: https://svn.musicpd.org/mpd/trunk@124 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-02-29 08:10:52 +00:00
parent cfd0e18dc4
commit 41b63bbe47
2 changed files with 7 additions and 4 deletions

View File

@ -114,6 +114,8 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
if(dc->start || dc->error!=DECODE_ERROR_NOERROR) { if(dc->start || dc->error!=DECODE_ERROR_NOERROR) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN); strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
printf("error: %i, start: %i, decode_pid: %i\n",dc->error,
dc->start,*decode_pid);
pc->error = PLAYER_ERROR_FILE; pc->error = PLAYER_ERROR_FILE;
quitDecode(pc,dc); quitDecode(pc,dc);
return -1; return -1;
@ -198,9 +200,9 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af, int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
DecoderControl * dc) { DecoderControl * dc) {
decode_pid = &(pc->decode_pid); decode_pid = &(pc->decode_pid);
*decode_pid = fork(); int pid = fork();
if(*decode_pid==0) { if(pid==0) {
/* CHILD */ /* CHILD */
while(1) { while(1) {
@ -247,11 +249,12 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
exit(0); exit(0);
/* END OF CHILD */ /* END OF CHILD */
} }
else if(*decode_pid<0) { else if(pid<0) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN); strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_SYSTEM; pc->error = PLAYER_ERROR_SYSTEM;
return -1; return -1;
} }
else *decode_pid = pid;
return 0; return 0;
} }

View File

@ -479,7 +479,7 @@ void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, AudioFormat * af) {
int mp3_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { int mp3_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
mp3DecodeData data; mp3DecodeData data;
if(openMp3(dc->file,&data) < 0) { if(openMp3(dc->file,&data) < 0) {
ERROR("Input does not appear to be a mp3 bit stream.\n"); ERROR("Input does not appear to be a mp3 bit stream.\n");
return -1; return -1;