aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audiofile_decode.c2
-rw-r--r--src/conf.c7
-rw-r--r--src/decode.c20
-rw-r--r--src/flac_decode.c2
-rw-r--r--src/ls.c2
-rw-r--r--src/mp3_decode.c2
-rw-r--r--src/ogg_decode.c2
-rw-r--r--src/path.c4
-rw-r--r--src/playerData.c24
-rw-r--r--src/playerData.h2
-rw-r--r--src/playlist.c2
11 files changed, 36 insertions, 33 deletions
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index 71723722..19f4623d 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -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;
}
diff --git a/src/conf.c b/src/conf.c
index 889a0086..b6d03b03 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -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]]);
diff --git a/src/decode.c b/src/decode.c
index ecedc330..f9e07db6 100644
--- a/src/decode.c
+++ b/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;
}
diff --git a/src/flac_decode.c b/src/flac_decode.c
index 5f7ac428..2708795c 100644
--- a/src/flac_decode.c
+++ b/src/flac_decode.c
@@ -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;
}
diff --git a/src/ls.c b/src/ls.c
index 4c974690..85c7b6a0 100644
--- a/src/ls.c
+++ b/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);
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index 086e3be1..6681c846 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -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;
}
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index 249b3490..158428be 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -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;
}
diff --git a/src/path.c b/src/path.c
index c9124090..a7f143dc 100644
--- a/src/path.c
+++ b/src/path.c
@@ -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;
diff --git a/src/playerData.c b/src/playerData.c
index 71925862..4a95f1d8 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -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;
diff --git a/src/playerData.h b/src/playerData.h
index 003c59ca..fccf782b 100644
--- a/src/playerData.h
+++ b/src/playerData.h
@@ -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;
diff --git a/src/playlist.c b/src/playlist.c
index eec721cf..e9b0c322 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -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));