some more cleanups
git-svn-id: https://svn.musicpd.org/mpd/trunk@60 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
e1c839cd56
commit
8edc416344
|
@ -115,7 +115,7 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
|
|||
|
||||
++cb->end;
|
||||
|
||||
if(cb->end>=BUFFERED_CHUNKS) {
|
||||
if(cb->end>=buffered_chunks) {
|
||||
cb->end = 0;
|
||||
cb->wrap = 1;
|
||||
}
|
||||
|
|
|
@ -216,13 +216,16 @@ char ** readConf(char * file) {
|
|||
conf_params[conf_absolutePaths[i]]);
|
||||
exit(-1);
|
||||
}
|
||||
/* Parse ~ in path */
|
||||
else if(conf_params[conf_absolutePaths[i]] &&
|
||||
conf_params[conf_absolutePaths[i]][0]=='~')
|
||||
{
|
||||
struct passwd * pwd = NULL;
|
||||
char * path;
|
||||
int pos = 1;
|
||||
if(conf_params[conf_absolutePaths[i]][1]=='/') {
|
||||
if(conf_params[conf_absolutePaths[i]][1]=='/' ||
|
||||
conf_params[conf_absolutePaths[i]][1]=='\0')
|
||||
{
|
||||
uid_t uid = geteuid();
|
||||
if((pwd = getpwuid(uid)) == NULL) {
|
||||
ERROR("problems getting passwd entry "
|
||||
|
@ -251,7 +254,7 @@ char ** readConf(char * file) {
|
|||
if(foundSlash) *ch = '/';
|
||||
}
|
||||
path = malloc(strlen(pwd->pw_dir)+strlen(
|
||||
&(conf_params[conf_absolutePaths[i]][pos])));
|
||||
&(conf_params[conf_absolutePaths[i]][pos]))+1);
|
||||
strcpy(path,pwd->pw_dir);
|
||||
strcat(path,&(conf_params[conf_absolutePaths[i]][pos]));
|
||||
free(conf_params[conf_absolutePaths[i]]);
|
||||
|
|
20
src/decode.c
20
src/decode.c
|
@ -93,8 +93,8 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
|
|||
chunks = (af->sampleRate*af->bits*af->channels/8.0/CHUNK_SIZE);
|
||||
chunks = (chunks*pc->crossFade+0.5);
|
||||
|
||||
if(chunks>(BUFFERED_CHUNKS-buffered_before_play)) {
|
||||
chunks = BUFFERED_CHUNKS-buffered_before_play;
|
||||
if(chunks>(buffered_chunks-buffered_before_play)) {
|
||||
chunks = buffered_chunks-buffered_before_play;
|
||||
}
|
||||
|
||||
if(chunks<0) chunks = 0;
|
||||
|
@ -338,19 +338,19 @@ void decode() {
|
|||
<=crossFadeChunks) ||
|
||||
(cb->begin>cb->next &&
|
||||
(fadePosition=cb->next-cb->begin+
|
||||
BUFFERED_CHUNKS)<=crossFadeChunks)))
|
||||
buffered_chunks)<=crossFadeChunks)))
|
||||
{
|
||||
if(nextChunk<0) {
|
||||
crossFadeChunks = fadePosition;
|
||||
}
|
||||
nextChunk = cb->begin+crossFadeChunks;
|
||||
test = cb->end;
|
||||
if(cb->wrap) test+=BUFFERED_CHUNKS;
|
||||
if(cb->wrap) test+=buffered_chunks;
|
||||
if(nextChunk<test) {
|
||||
if(nextChunk>=BUFFERED_CHUNKS)
|
||||
if(nextChunk>=buffered_chunks)
|
||||
{
|
||||
nextChunk-=
|
||||
BUFFERED_CHUNKS;
|
||||
buffered_chunks;
|
||||
}
|
||||
pcm_mix(cb->chunks+cb->begin*
|
||||
CHUNK_SIZE,
|
||||
|
@ -393,7 +393,7 @@ void decode() {
|
|||
playAudio(cb->chunks+cb->begin*CHUNK_SIZE,
|
||||
cb->chunkSize[cb->begin]);
|
||||
cb->begin++;
|
||||
if(cb->begin>=BUFFERED_CHUNKS) {
|
||||
if(cb->begin>=buffered_chunks) {
|
||||
cb->begin = 0;
|
||||
cb->wrap = 0;
|
||||
}
|
||||
|
@ -404,12 +404,12 @@ void decode() {
|
|||
if(doCrossFade==1 && nextChunk>=0) {
|
||||
nextChunk = cb->begin+crossFadeChunks;
|
||||
test = cb->end;
|
||||
if(cb->wrap) test+=BUFFERED_CHUNKS;
|
||||
if(cb->wrap) test+=buffered_chunks;
|
||||
if(nextChunk<test) {
|
||||
if(nextChunk>=BUFFERED_CHUNKS)
|
||||
if(nextChunk>=buffered_chunks)
|
||||
{
|
||||
nextChunk-=
|
||||
BUFFERED_CHUNKS;
|
||||
buffered_chunks;
|
||||
}
|
||||
cb->begin = nextChunk;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ int flacSendChunk(FlacData * data) {
|
|||
data->cb->bitRate[data->cb->end] = 0;
|
||||
|
||||
data->cb->end++;
|
||||
if(data->cb->end>=BUFFERED_CHUNKS) {
|
||||
if(data->cb->end>=buffered_chunks) {
|
||||
data->cb->end = 0;
|
||||
data->cb->wrap = 1;
|
||||
}
|
||||
|
|
2
src/ls.c
2
src/ls.c
|
@ -32,7 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
char * dupAndStripPlaylistSuffix(char * file) {
|
||||
int size = strlen(file)-strlen(PLAYLIST_FILE_SUFFIX)-1;
|
||||
size_t size = strlen(file)-strlen(PLAYLIST_FILE_SUFFIX)-1;
|
||||
char * ret = malloc(size+1);
|
||||
|
||||
strncpy(ret,file,size);
|
||||
|
|
|
@ -374,7 +374,7 @@ int mp3ChildSendData(mp3DecodeData * data, Buffer * cb, DecoderControl * dc) {
|
|||
cb->times[cb->end] = data->elapsedTime;
|
||||
|
||||
cb->end++;
|
||||
if(cb->end>=BUFFERED_CHUNKS) {
|
||||
if(cb->end>=buffered_chunks) {
|
||||
cb->end = 0;
|
||||
cb->wrap = 1;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
|
|||
}
|
||||
cb->bitRate[cb->end] = bitRate;
|
||||
cb->end++;
|
||||
if(cb->end>=BUFFERED_CHUNKS) {
|
||||
if(cb->end>=buffered_chunks) {
|
||||
cb->end = 0;
|
||||
cb->wrap = 1;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ char * rmp2amp(char * relativePath) {
|
|||
|
||||
memset(absolutePath,0,MAXPATHLEN+1);
|
||||
|
||||
strcpy(absolutePath,musicDir);
|
||||
strncpy(absolutePath,musicDir,MAXPATHLEN);
|
||||
strncat(absolutePath,relativePath,MAXPATHLEN-strlen(musicDir));
|
||||
|
||||
return absolutePath;
|
||||
|
@ -145,7 +145,7 @@ char * rpp2app(char * relativePath) {
|
|||
|
||||
memset(absolutePath,0,MAXPATHLEN+1);
|
||||
|
||||
strcpy(absolutePath,playlistDir);
|
||||
strncpy(absolutePath,playlistDir,MAXPATHLEN);
|
||||
strncat(absolutePath,relativePath,MAXPATHLEN-strlen(musicDir));
|
||||
|
||||
return absolutePath;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <string.h>
|
||||
|
||||
int buffered_before_play;
|
||||
int BUFFERED_CHUNKS;
|
||||
int buffered_chunks;
|
||||
|
||||
PlayerData * playerData_pd;
|
||||
|
||||
|
@ -49,7 +49,7 @@ void initPlayerData() {
|
|||
}
|
||||
bufferSize*=1024;
|
||||
|
||||
BUFFERED_CHUNKS = bufferSize/CHUNK_SIZE;
|
||||
buffered_chunks = bufferSize/CHUNK_SIZE;
|
||||
|
||||
perc = strtod((getConf())[CONF_BUFFER_BEFORE_PLAY],&test);
|
||||
if(*test!='%' || perc<0 || perc>100) {
|
||||
|
@ -58,16 +58,16 @@ void initPlayerData() {
|
|||
(getConf())[CONF_BUFFER_BEFORE_PLAY]);
|
||||
exit(-1);
|
||||
}
|
||||
buffered_before_play = (perc/100)*BUFFERED_CHUNKS;
|
||||
if(buffered_before_play>BUFFERED_CHUNKS) {
|
||||
buffered_before_play = BUFFERED_CHUNKS;
|
||||
buffered_before_play = (perc/100)*buffered_chunks;
|
||||
if(buffered_before_play>buffered_chunks) {
|
||||
buffered_before_play = buffered_chunks;
|
||||
}
|
||||
else if(buffered_before_play<0) buffered_before_play = 0;
|
||||
|
||||
allocationSize = BUFFERED_CHUNKS*CHUNK_SIZE; /*actual buffer*/
|
||||
allocationSize+= BUFFERED_CHUNKS*sizeof(float); /*for times*/
|
||||
allocationSize+= BUFFERED_CHUNKS*sizeof(mpd_sint16); /*for chunkSize*/
|
||||
allocationSize+= BUFFERED_CHUNKS*sizeof(mpd_sint16); /*for bitRate*/
|
||||
allocationSize = buffered_chunks*CHUNK_SIZE; /*actual buffer*/
|
||||
allocationSize+= buffered_chunks*sizeof(float); /*for times*/
|
||||
allocationSize+= buffered_chunks*sizeof(mpd_sint16); /*for chunkSize*/
|
||||
allocationSize+= buffered_chunks*sizeof(mpd_sint16); /*for bitRate*/
|
||||
allocationSize+= sizeof(PlayerData); /*for playerData struct*/
|
||||
|
||||
if((shmid = shmget(IPC_PRIVATE,allocationSize,IPC_CREAT|0600))<0) {
|
||||
|
@ -87,11 +87,11 @@ void initPlayerData() {
|
|||
|
||||
buffer->chunks = ((char *)playerData_pd)+sizeof(PlayerData);
|
||||
buffer->chunkSize = (mpd_sint16 *)(((char *)buffer->chunks)+
|
||||
BUFFERED_CHUNKS*CHUNK_SIZE);
|
||||
buffered_chunks*CHUNK_SIZE);
|
||||
buffer->bitRate = (mpd_sint16 *)(((char *)buffer->chunkSize)+
|
||||
BUFFERED_CHUNKS*sizeof(mpd_sint16));
|
||||
buffered_chunks*sizeof(mpd_sint16));
|
||||
buffer->times = (float *)(((char *)buffer->bitRate)+
|
||||
BUFFERED_CHUNKS*sizeof(mpd_sint16));
|
||||
buffered_chunks*sizeof(mpd_sint16));
|
||||
|
||||
playerData_pd->playerControl.stop = 0;
|
||||
playerData_pd->playerControl.pause = 0;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define CHUNK_SIZE 1024
|
||||
|
||||
extern int buffered_before_play;
|
||||
extern int BUFFERED_CHUNKS;
|
||||
extern int buffered_chunks;
|
||||
|
||||
typedef struct _Buffer {
|
||||
char * chunks;
|
||||
|
|
|
@ -130,7 +130,7 @@ void initPlaylist() {
|
|||
playlist.songs = malloc(sizeof(Song *)*playlist_max_length);
|
||||
playlist.order = malloc(sizeof(Song *)*playlist_max_length);
|
||||
|
||||
memset(playlist.songs,(int)NULL,sizeof(char *)*playlist_max_length);
|
||||
memset(playlist.songs,0,sizeof(char *)*playlist_max_length);
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
|
|
Loading…
Reference in New Issue