use our own portable version of usleep using select()
git-svn-id: https://svn.musicpd.org/mpd/trunk@578 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
917af619da
commit
3ab9841764
|
@ -371,7 +371,7 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
while(cb->begin==cb->end && cb->wrap &&
|
while(cb->begin==cb->end && cb->wrap &&
|
||||||
!dc->stop && !dc->seek)
|
!dc->stop && !dc->seek)
|
||||||
{
|
{
|
||||||
usleep(10000);
|
my_usleep(10000);
|
||||||
}
|
}
|
||||||
if(dc->seek) {
|
if(dc->seek) {
|
||||||
dc->seekError = 1;
|
dc->seekError = 1;
|
||||||
|
|
|
@ -111,7 +111,7 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
|
||||||
else {
|
else {
|
||||||
while(cb->begin==cb->end && cb->wrap &&
|
while(cb->begin==cb->end && cb->wrap &&
|
||||||
!dc->stop && !dc->seek){
|
!dc->stop && !dc->seek){
|
||||||
usleep(10000);
|
my_usleep(10000);
|
||||||
}
|
}
|
||||||
if(dc->stop) break;
|
if(dc->stop) break;
|
||||||
else if(dc->seek) continue;
|
else if(dc->seek) continue;
|
||||||
|
|
16
src/decode.c
16
src/decode.c
|
@ -79,7 +79,7 @@ void stopDecode(DecoderControl * dc) {
|
||||||
(dc->start || dc->state==DECODE_STATE_DECODE))
|
(dc->start || dc->state==DECODE_STATE_DECODE))
|
||||||
{
|
{
|
||||||
dc->stop = 1;
|
dc->stop = 1;
|
||||||
while(decode_pid && *decode_pid>0 && dc->stop) usleep(1000);
|
while(decode_pid && *decode_pid>0 && dc->stop) my_usleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
|
||||||
int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
|
int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
|
||||||
Buffer * cb)
|
Buffer * cb)
|
||||||
{
|
{
|
||||||
while(decode_pid && *decode_pid>0 && dc->start) usleep(1000);
|
while(decode_pid && *decode_pid>0 && dc->start) my_usleep(1000);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -164,7 +164,7 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
|
||||||
dc->seekError = 0;
|
dc->seekError = 0;
|
||||||
dc->seek = 1;
|
dc->seek = 1;
|
||||||
pc->bitRate = 0;
|
pc->bitRate = 0;
|
||||||
while(*decode_pid>0 && dc->seek) usleep(1000);
|
while(*decode_pid>0 && dc->seek) my_usleep(1000);
|
||||||
if(!dc->seekError) pc->elapsedTime = dc->seekWhere;
|
if(!dc->seekError) pc->elapsedTime = dc->seekWhere;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
|
||||||
dc->stop = 0;
|
dc->stop = 0;
|
||||||
}
|
}
|
||||||
else if(dc->seek) dc->start = 1;
|
else if(dc->seek) dc->start = 1;
|
||||||
else usleep(10000);
|
else my_usleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -339,7 +339,7 @@ void decode() {
|
||||||
{
|
{
|
||||||
processDecodeInput();
|
processDecodeInput();
|
||||||
if(quit) return;
|
if(quit) return;
|
||||||
usleep(1000);
|
my_usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!quit) {
|
while(!quit) {
|
||||||
|
@ -367,7 +367,7 @@ void decode() {
|
||||||
}
|
}
|
||||||
else doCrossFade = -1;
|
else doCrossFade = -1;
|
||||||
}
|
}
|
||||||
if(pause) usleep(10000);
|
if(pause) my_usleep(10000);
|
||||||
else if((cb->begin!=cb->end || cb->wrap) &&
|
else if((cb->begin!=cb->end || cb->wrap) &&
|
||||||
cb->begin!=cb->next)
|
cb->begin!=cb->next)
|
||||||
{
|
{
|
||||||
|
@ -461,7 +461,7 @@ void decode() {
|
||||||
quitDecode(pc,dc);
|
quitDecode(pc,dc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usleep(1000);
|
my_usleep(1000);
|
||||||
}
|
}
|
||||||
if(pc->queueState!=PLAYER_QUEUE_PLAY) {
|
if(pc->queueState!=PLAYER_QUEUE_PLAY) {
|
||||||
quit = 1;
|
quit = 1;
|
||||||
|
@ -484,7 +484,7 @@ void decode() {
|
||||||
quit = 1;
|
quit = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else usleep(1000);
|
else my_usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->totalPlayTime+= pc->elapsedTime-pc->beginTime; \
|
pc->totalPlayTime+= pc->elapsedTime-pc->beginTime; \
|
||||||
|
|
|
@ -182,7 +182,7 @@ int flacSendChunk(FlacData * data) {
|
||||||
while(data->cb->begin==data->cb->end && data->cb->wrap &&
|
while(data->cb->begin==data->cb->end && data->cb->wrap &&
|
||||||
!data->dc->stop && !data->dc->seek)
|
!data->dc->stop && !data->dc->seek)
|
||||||
{
|
{
|
||||||
usleep(10000);
|
my_usleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->dc->stop) return -1;
|
if(data->dc->stop) return -1;
|
||||||
|
|
|
@ -27,13 +27,14 @@
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "permission.h"
|
#include "permission.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -407,7 +407,7 @@ int openMp3(char * file, mp3DecodeData * data) {
|
||||||
|
|
||||||
int mp3ChildSendData(mp3DecodeData * data, Buffer * cb, DecoderControl * dc) {
|
int mp3ChildSendData(mp3DecodeData * data, Buffer * cb, DecoderControl * dc) {
|
||||||
while(cb->begin==cb->end && cb->wrap && !dc->stop && !dc->seek)
|
while(cb->begin==cb->end && cb->wrap && !dc->stop && !dc->seek)
|
||||||
usleep(10000);
|
my_usleep(10000);
|
||||||
if(dc->stop) return -1;
|
if(dc->stop) return -1;
|
||||||
/* just for now, so it doesn't hang */
|
/* just for now, so it doesn't hang */
|
||||||
if(dc->seek) return 0;
|
if(dc->seek) return 0;
|
||||||
|
|
|
@ -285,7 +285,7 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
while(cb->begin==cb->end && cb->wrap &&
|
while(cb->begin==cb->end && cb->wrap &&
|
||||||
!dc->stop && !dc->seek)
|
!dc->stop && !dc->seek)
|
||||||
{
|
{
|
||||||
usleep(10000);
|
my_usleep(10000);
|
||||||
}
|
}
|
||||||
if(dc->stop) {
|
if(dc->stop) {
|
||||||
eof = 1;
|
eof = 1;
|
||||||
|
|
|
@ -112,7 +112,7 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
|
||||||
while(cb->begin==cb->end && cb->wrap &&
|
while(cb->begin==cb->end && cb->wrap &&
|
||||||
!dc->stop && !dc->seek)
|
!dc->stop && !dc->seek)
|
||||||
{
|
{
|
||||||
usleep(10000);
|
my_usleep(10000);
|
||||||
}
|
}
|
||||||
if(dc->stop) break;
|
if(dc->stop) break;
|
||||||
else if(dc->seek) continue;
|
else if(dc->seek) continue;
|
||||||
|
|
14
src/player.c
14
src/player.c
|
@ -134,7 +134,7 @@ int playerInit() {
|
||||||
pc->queueLockState = PLAYER_QUEUE_UNLOCKED;
|
pc->queueLockState = PLAYER_QUEUE_UNLOCKED;
|
||||||
pc->unlockQueue = 0;
|
pc->unlockQueue = 0;
|
||||||
}
|
}
|
||||||
else usleep(10000);
|
else my_usleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -206,7 +206,7 @@ int playerPlay(FILE * fp, char * utf8file) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(player_pid>0 && pc->play) usleep(1000);
|
while(player_pid>0 && pc->play) my_usleep(1000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ int playerStop(FILE * fp) {
|
||||||
|
|
||||||
if(player_pid>0 && pc->state!=PLAYER_STATE_STOP) {
|
if(player_pid>0 && pc->state!=PLAYER_STATE_STOP) {
|
||||||
pc->stop = 1;
|
pc->stop = 1;
|
||||||
while(player_pid>0 && pc->stop) usleep(1000);
|
while(player_pid>0 && pc->stop) my_usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->queueState = PLAYER_QUEUE_BLANK;
|
pc->queueState = PLAYER_QUEUE_BLANK;
|
||||||
|
@ -242,7 +242,7 @@ int playerPause(FILE * fp) {
|
||||||
|
|
||||||
if(player_pid>0 && pc->state!=PLAYER_STATE_STOP) {
|
if(player_pid>0 && pc->state!=PLAYER_STATE_STOP) {
|
||||||
pc->pause = 1;
|
pc->pause = 1;
|
||||||
while(player_pid>0 && pc->pause) usleep(1000);
|
while(player_pid>0 && pc->pause) my_usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -361,7 +361,7 @@ void playerQueueLock() {
|
||||||
if(player_pid>0 && pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
|
if(player_pid>0 && pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
|
||||||
{
|
{
|
||||||
pc->lockQueue = 1;
|
pc->lockQueue = 1;
|
||||||
while(player_pid>0 && pc->lockQueue) usleep(1000);
|
while(player_pid>0 && pc->lockQueue) my_usleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ void playerQueueUnlock() {
|
||||||
if(player_pid>0 && pc->queueLockState==PLAYER_QUEUE_LOCKED)
|
if(player_pid>0 && pc->queueLockState==PLAYER_QUEUE_LOCKED)
|
||||||
{
|
{
|
||||||
pc->unlockQueue = 1;
|
pc->unlockQueue = 1;
|
||||||
while(player_pid>0 && pc->unlockQueue) usleep(1000);
|
while(player_pid>0 && pc->unlockQueue) my_usleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
|
||||||
if(pc->error==PLAYER_ERROR_NOERROR) {
|
if(pc->error==PLAYER_ERROR_NOERROR) {
|
||||||
pc->seekWhere = time;
|
pc->seekWhere = time;
|
||||||
pc->seek = 1;
|
pc->seek = 1;
|
||||||
while(player_pid>0 && pc->seek) usleep(1000);
|
while(player_pid>0 && pc->seek) my_usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
14
src/utils.c
14
src/utils.c
|
@ -18,8 +18,13 @@
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
char * myFgets(char * buffer, int bufferSize, FILE * fp) {
|
char * myFgets(char * buffer, int bufferSize, FILE * fp) {
|
||||||
char * ret = fgets(buffer,bufferSize,fp);
|
char * ret = fgets(buffer,bufferSize,fp);
|
||||||
|
@ -43,3 +48,12 @@ void stripReturnChar(char * string) {
|
||||||
*string = ' ';
|
*string = ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void my_usleep(long usec) {
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = usec;
|
||||||
|
|
||||||
|
select(0,NULL,NULL,NULL,&tv);
|
||||||
|
}
|
||||||
|
|
|
@ -29,4 +29,6 @@ char * strDupToUpper(char * str);
|
||||||
|
|
||||||
void stripReturnChar(char * string);
|
void stripReturnChar(char * string);
|
||||||
|
|
||||||
|
void my_usleep(long usec);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue