fixed -Wshadow warnings
Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7143 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:

committed by
Eric Wong

parent
28008e6977
commit
07adb14e3c
14
src/audio.c
14
src/audio.c
@ -360,16 +360,16 @@ int openAudioDevice(AudioFormat * audioFormat)
|
|||||||
|
|
||||||
int playAudio(const char *playChunk, int size)
|
int playAudio(const char *playChunk, int size)
|
||||||
{
|
{
|
||||||
int send;
|
int send_size;
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
send = audioBufferSize - audioBufferPos;
|
send_size = audioBufferSize - audioBufferPos;
|
||||||
send = send < size ? send : size;
|
send_size = send_size < size ? send_size : size;
|
||||||
|
|
||||||
memcpy(audioBuffer + audioBufferPos, playChunk, send);
|
memcpy(audioBuffer + audioBufferPos, playChunk, send_size);
|
||||||
audioBufferPos += send;
|
audioBufferPos += send_size;
|
||||||
size -= send;
|
size -= send_size;
|
||||||
playChunk += send;
|
playChunk += send_size;
|
||||||
|
|
||||||
if (audioBufferPos == audioBufferSize) {
|
if (audioBufferPos == audioBufferSize) {
|
||||||
if (flushAudioBuffer() < 0)
|
if (flushAudioBuffer() < 0)
|
||||||
|
@ -62,39 +62,39 @@ typedef struct _OssData {
|
|||||||
|
|
||||||
static int getIndexForParam(int param)
|
static int getIndexForParam(int param)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int idx = 0;
|
||||||
|
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case SNDCTL_DSP_SPEED:
|
case SNDCTL_DSP_SPEED:
|
||||||
index = OSS_RATE;
|
idx = OSS_RATE;
|
||||||
break;
|
break;
|
||||||
case SNDCTL_DSP_CHANNELS:
|
case SNDCTL_DSP_CHANNELS:
|
||||||
index = OSS_CHANNELS;
|
idx = OSS_CHANNELS;
|
||||||
break;
|
break;
|
||||||
case SNDCTL_DSP_SAMPLESIZE:
|
case SNDCTL_DSP_SAMPLESIZE:
|
||||||
index = OSS_BITS;
|
idx = OSS_BITS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int findSupportedParam(OssData * od, int param, int val)
|
static int findSupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
|
|
||||||
for (i = 0; i < od->numSupported[index]; i++) {
|
for (i = 0; i < od->numSupported[idx]; i++) {
|
||||||
if (od->supported[index][i] == val)
|
if (od->supported[idx][i] == val)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int canConvert(int index, int val)
|
static int canConvert(int idx, int val)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (idx) {
|
||||||
case OSS_BITS:
|
case OSS_BITS:
|
||||||
if (val != 16)
|
if (val != 16)
|
||||||
return 0;
|
return 0;
|
||||||
@ -111,21 +111,21 @@ static int canConvert(int index, int val)
|
|||||||
static int getSupportedParam(OssData * od, int param, int val)
|
static int getSupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int least = val;
|
int least = val;
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
for (i = 0; i < od->numSupported[index]; i++) {
|
for (i = 0; i < od->numSupported[idx]; i++) {
|
||||||
diff = od->supported[index][i] - val;
|
diff = od->supported[idx][i] - val;
|
||||||
if (diff < 0)
|
if (diff < 0)
|
||||||
diff = -diff;
|
diff = -diff;
|
||||||
if (diff < least) {
|
if (diff < least) {
|
||||||
if (!canConvert(index, od->supported[index][i])) {
|
if (!canConvert(idx, od->supported[idx][i])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
least = diff;
|
least = diff;
|
||||||
ret = od->supported[index][i];
|
ret = od->supported[idx][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +135,10 @@ static int getSupportedParam(OssData * od, int param, int val)
|
|||||||
static int findUnsupportedParam(OssData * od, int param, int val)
|
static int findUnsupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
|
|
||||||
for (i = 0; i < od->numUnsupported[index]; i++) {
|
for (i = 0; i < od->numUnsupported[idx]; i++) {
|
||||||
if (od->unsupported[index][i] == val)
|
if (od->unsupported[idx][i] == val)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,58 +147,58 @@ static int findUnsupportedParam(OssData * od, int param, int val)
|
|||||||
|
|
||||||
static void addSupportedParam(OssData * od, int param, int val)
|
static void addSupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
|
|
||||||
od->numSupported[index]++;
|
od->numSupported[idx]++;
|
||||||
od->supported[index] = xrealloc(od->supported[index],
|
od->supported[idx] = xrealloc(od->supported[idx],
|
||||||
od->numSupported[index] * sizeof(int));
|
od->numSupported[idx] * sizeof(int));
|
||||||
od->supported[index][od->numSupported[index] - 1] = val;
|
od->supported[idx][od->numSupported[idx] - 1] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addUnsupportedParam(OssData * od, int param, int val)
|
static void addUnsupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
|
|
||||||
od->numUnsupported[index]++;
|
od->numUnsupported[idx]++;
|
||||||
od->unsupported[index] = xrealloc(od->unsupported[index],
|
od->unsupported[idx] = xrealloc(od->unsupported[idx],
|
||||||
od->numUnsupported[index] *
|
od->numUnsupported[idx] *
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
od->unsupported[index][od->numUnsupported[index] - 1] = val;
|
od->unsupported[idx][od->numUnsupported[idx] - 1] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeSupportedParam(OssData * od, int param, int val)
|
static void removeSupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
|
|
||||||
for (i = 0; i < od->numSupported[index] - 1; i++) {
|
for (i = 0; i < od->numSupported[idx] - 1; i++) {
|
||||||
if (od->supported[index][i] == val)
|
if (od->supported[idx][i] == val)
|
||||||
j = 1;
|
j = 1;
|
||||||
od->supported[index][i] = od->supported[index][i + j];
|
od->supported[idx][i] = od->supported[idx][i + j];
|
||||||
}
|
}
|
||||||
|
|
||||||
od->numSupported[index]--;
|
od->numSupported[idx]--;
|
||||||
od->supported[index] = xrealloc(od->supported[index],
|
od->supported[idx] = xrealloc(od->supported[idx],
|
||||||
od->numSupported[index] * sizeof(int));
|
od->numSupported[idx] * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeUnsupportedParam(OssData * od, int param, int val)
|
static void removeUnsupportedParam(OssData * od, int param, int val)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int index = getIndexForParam(param);
|
int idx = getIndexForParam(param);
|
||||||
|
|
||||||
for (i = 0; i < od->numUnsupported[index] - 1; i++) {
|
for (i = 0; i < od->numUnsupported[idx] - 1; i++) {
|
||||||
if (od->unsupported[index][i] == val)
|
if (od->unsupported[idx][i] == val)
|
||||||
j = 1;
|
j = 1;
|
||||||
od->unsupported[index][i] = od->unsupported[index][i + j];
|
od->unsupported[idx][i] = od->unsupported[idx][i + j];
|
||||||
}
|
}
|
||||||
|
|
||||||
od->numUnsupported[index]--;
|
od->numUnsupported[idx]--;
|
||||||
od->unsupported[index] = xrealloc(od->unsupported[index],
|
od->unsupported[idx] = xrealloc(od->unsupported[idx],
|
||||||
od->numUnsupported[index] *
|
od->numUnsupported[idx] *
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int isSupportedParam(OssData * od, int param, int val)
|
static int isSupportedParam(OssData * od, int param, int val)
|
||||||
|
@ -239,13 +239,13 @@ static int handlePause(int fd, int *permission, int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
char *test;
|
char *test;
|
||||||
int pause = strtol(argv[1], &test, 10);
|
int pause_flag = strtol(argv[1], &test, 10);
|
||||||
if (*test != '\0' || (pause != 0 && pause != 1)) {
|
if (*test != '\0' || (pause_flag != 0 && pause_flag != 1)) {
|
||||||
commandError(fd, ACK_ERROR_ARG, "\"%s\" is not 0 or 1",
|
commandError(fd, ACK_ERROR_ARG, "\"%s\" is not 0 or 1",
|
||||||
argv[1]);
|
argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return playerSetPause(fd, pause);
|
return playerSetPause(fd, pause_flag);
|
||||||
}
|
}
|
||||||
return playerPause(fd);
|
return playerPause(fd);
|
||||||
}
|
}
|
||||||
@ -929,7 +929,7 @@ static int handleSwapId(int fd, int *permission, int argc, char *argv[])
|
|||||||
static int handleSeek(int fd, int *permission, int argc, char *argv[])
|
static int handleSeek(int fd, int *permission, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int song;
|
int song;
|
||||||
int time;
|
int seek_time;
|
||||||
char *test;
|
char *test;
|
||||||
|
|
||||||
song = strtol(argv[1], &test, 10);
|
song = strtol(argv[1], &test, 10);
|
||||||
@ -938,19 +938,19 @@ static int handleSeek(int fd, int *permission, int argc, char *argv[])
|
|||||||
"\"%s\" is not a integer", argv[1]);
|
"\"%s\" is not a integer", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
time = strtol(argv[2], &test, 10);
|
seek_time = strtol(argv[2], &test, 10);
|
||||||
if (*test != '\0') {
|
if (*test != '\0') {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG,
|
||||||
"\"%s\" is not a integer", argv[2]);
|
"\"%s\" is not a integer", argv[2]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return seekSongInPlaylist(fd, song, time);
|
return seekSongInPlaylist(fd, song, seek_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSeekId(int fd, int *permission, int argc, char *argv[])
|
static int handleSeekId(int fd, int *permission, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
int time;
|
int seek_time;
|
||||||
char *test;
|
char *test;
|
||||||
|
|
||||||
id = strtol(argv[1], &test, 10);
|
id = strtol(argv[1], &test, 10);
|
||||||
@ -959,13 +959,13 @@ static int handleSeekId(int fd, int *permission, int argc, char *argv[])
|
|||||||
"\"%s\" is not a integer", argv[1]);
|
"\"%s\" is not a integer", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
time = strtol(argv[2], &test, 10);
|
seek_time = strtol(argv[2], &test, 10);
|
||||||
if (*test != '\0') {
|
if (*test != '\0') {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG,
|
||||||
"\"%s\" is not a integer", argv[2]);
|
"\"%s\" is not a integer", argv[2]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return seekSongInPlaylistById(fd, id, time);
|
return seekSongInPlaylistById(fd, id, seek_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleListAllInfo(int fd, int *permission, int argc, char *argv[])
|
static int handleListAllInfo(int fd, int *permission, int argc, char *argv[])
|
||||||
@ -994,17 +994,17 @@ static int handlePassword(int fd, int *permission, int argc, char *argv[])
|
|||||||
|
|
||||||
static int handleCrossfade(int fd, int *permission, int argc, char *argv[])
|
static int handleCrossfade(int fd, int *permission, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int time;
|
int xfade_time;
|
||||||
char *test;
|
char *test;
|
||||||
|
|
||||||
time = strtol(argv[1], &test, 10);
|
xfade_time = strtol(argv[1], &test, 10);
|
||||||
if (*test != '\0' || time < 0) {
|
if (*test != '\0' || xfade_time < 0) {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG,
|
||||||
"\"%s\" is not a integer >= 0", argv[1]);
|
"\"%s\" is not a integer >= 0", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlayerCrossFade(time);
|
setPlayerCrossFade(xfade_time);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -201,10 +201,10 @@ static int directoryPrintSongInfo(int fd, Song * song, void *data)
|
|||||||
|
|
||||||
static int sumSongTime(int fd, Song * song, void *data)
|
static int sumSongTime(int fd, Song * song, void *data)
|
||||||
{
|
{
|
||||||
unsigned long *time = (unsigned long *)data;
|
unsigned long *sum_time = (unsigned long *)data;
|
||||||
|
|
||||||
if (song->tag && song->tag->time >= 0)
|
if (song->tag && song->tag->time >= 0)
|
||||||
*time += song->tag->time;
|
*sum_time += song->tag->time;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -761,21 +761,21 @@ void closeMp3Directory(void)
|
|||||||
static Directory *findSubDirectory(Directory * directory, char *name)
|
static Directory *findSubDirectory(Directory * directory, char *name)
|
||||||
{
|
{
|
||||||
void *subDirectory;
|
void *subDirectory;
|
||||||
char *dup = xstrdup(name);
|
char *duplicated = xstrdup(name);
|
||||||
char *key;
|
char *key;
|
||||||
|
|
||||||
key = strtok(dup, "/");
|
key = strtok(duplicated, "/");
|
||||||
if (!key) {
|
if (!key) {
|
||||||
free(dup);
|
free(duplicated);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findInList(directory->subDirectories, key, &subDirectory)) {
|
if (findInList(directory->subDirectories, key, &subDirectory)) {
|
||||||
free(dup);
|
free(duplicated);
|
||||||
return (Directory *) subDirectory;
|
return (Directory *) subDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dup);
|
free(duplicated);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1264,9 +1264,9 @@ static Song *getSongDetails(char *file, char **shortnameRet,
|
|||||||
void *song = NULL;
|
void *song = NULL;
|
||||||
Directory *directory;
|
Directory *directory;
|
||||||
char *dir = NULL;
|
char *dir = NULL;
|
||||||
char *dup = xstrdup(file);
|
char *duplicated = xstrdup(file);
|
||||||
char *shortname = dup;
|
char *shortname = duplicated;
|
||||||
char *c = strtok(dup, "/");
|
char *c = strtok(duplicated, "/");
|
||||||
|
|
||||||
DEBUG("get song: %s\n", file);
|
DEBUG("get song: %s\n", file);
|
||||||
|
|
||||||
@ -1275,25 +1275,25 @@ static Song *getSongDetails(char *file, char **shortnameRet,
|
|||||||
c = strtok(NULL, "/");
|
c = strtok(NULL, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortname != dup) {
|
if (shortname != duplicated) {
|
||||||
for (c = dup; c < shortname - 1; c++) {
|
for (c = duplicated; c < shortname - 1; c++) {
|
||||||
if (*c == '\0')
|
if (*c == '\0')
|
||||||
*c = '/';
|
*c = '/';
|
||||||
}
|
}
|
||||||
dir = dup;
|
dir = duplicated;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(directory = getDirectory(dir))) {
|
if (!(directory = getDirectory(dir))) {
|
||||||
free(dup);
|
free(duplicated);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!findInList(directory->songs, shortname, &song)) {
|
if (!findInList(directory->songs, shortname, &song)) {
|
||||||
free(dup);
|
free(duplicated);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dup);
|
free(duplicated);
|
||||||
if (shortnameRet)
|
if (shortnameRet)
|
||||||
*shortnameRet = shortname;
|
*shortnameRet = shortname;
|
||||||
if (directoryRet)
|
if (directoryRet)
|
||||||
|
@ -62,12 +62,12 @@ static int flacFindVorbisCommentFloat(const FLAC__StreamMetadata * block,
|
|||||||
- pos;
|
- pos;
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
unsigned char tmp;
|
unsigned char tmp;
|
||||||
unsigned char *dup = &(block->data.vorbis_comment.
|
unsigned char *p = &(block->data.vorbis_comment.
|
||||||
comments[offset].entry[pos]);
|
comments[offset].entry[pos]);
|
||||||
tmp = dup[len];
|
tmp = p[len];
|
||||||
dup[len] = '\0';
|
p[len] = '\0';
|
||||||
*fl = atof((char *)dup);
|
*fl = atof((char *)p);
|
||||||
dup[len] = tmp;
|
p[len] = tmp;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,16 @@
|
|||||||
|
|
||||||
static int getAudiofileTotalTime(char *file)
|
static int getAudiofileTotalTime(char *file)
|
||||||
{
|
{
|
||||||
int time;
|
int total_time;
|
||||||
AFfilehandle af_fp = afOpenFile(file, "r", NULL);
|
AFfilehandle af_fp = afOpenFile(file, "r", NULL);
|
||||||
if (af_fp == AF_NULL_FILEHANDLE) {
|
if (af_fp == AF_NULL_FILEHANDLE) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
time = (int)
|
total_time = (int)
|
||||||
((double)afGetFrameCount(af_fp, AF_DEFAULT_TRACK)
|
((double)afGetFrameCount(af_fp, AF_DEFAULT_TRACK)
|
||||||
/ afGetRate(af_fp, AF_DEFAULT_TRACK));
|
/ afGetRate(af_fp, AF_DEFAULT_TRACK));
|
||||||
afCloseFile(af_fp);
|
afCloseFile(af_fp);
|
||||||
return time;
|
return total_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
||||||
@ -134,12 +134,12 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
|||||||
static MpdTag *audiofileTagDup(char *file)
|
static MpdTag *audiofileTagDup(char *file)
|
||||||
{
|
{
|
||||||
MpdTag *ret = NULL;
|
MpdTag *ret = NULL;
|
||||||
int time = getAudiofileTotalTime(file);
|
int total_time = getAudiofileTotalTime(file);
|
||||||
|
|
||||||
if (time >= 0) {
|
if (total_time >= 0) {
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = newMpdTag();
|
ret = newMpdTag();
|
||||||
ret->time = time;
|
ret->time = total_time;
|
||||||
} else {
|
} else {
|
||||||
DEBUG
|
DEBUG
|
||||||
("audiofileTagDup: Failed to get total song time from: %s\n",
|
("audiofileTagDup: Failed to get total song time from: %s\n",
|
||||||
|
@ -166,7 +166,7 @@ static void mod_close(mod_Data * data)
|
|||||||
static int mod_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
static int mod_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
||||||
{
|
{
|
||||||
mod_Data *data;
|
mod_Data *data;
|
||||||
float time = 0.0;
|
float total_time = 0.0;
|
||||||
int ret;
|
int ret;
|
||||||
float secPerByte;
|
float secPerByte;
|
||||||
|
|
||||||
@ -203,10 +203,10 @@ static int mod_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE);
|
ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE);
|
||||||
time += ret * secPerByte;
|
total_time += ret * secPerByte;
|
||||||
sendDataToOutputBuffer(cb, NULL, dc, 0,
|
sendDataToOutputBuffer(cb, NULL, dc, 0,
|
||||||
(char *)data->audio_buffer, ret, time,
|
(char *)data->audio_buffer, ret,
|
||||||
0, NULL);
|
total_time, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
flushOutputBuffer(cb);
|
flushOutputBuffer(cb);
|
||||||
|
@ -69,7 +69,7 @@ static signed long audio_linear_dither(unsigned int bits, mad_fixed_t sample,
|
|||||||
struct audio_dither *dither)
|
struct audio_dither *dither)
|
||||||
{
|
{
|
||||||
unsigned int scalebits;
|
unsigned int scalebits;
|
||||||
mad_fixed_t output, mask, random;
|
mad_fixed_t output, mask, rnd;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MIN = -MAD_F_ONE,
|
MIN = -MAD_F_ONE,
|
||||||
@ -86,10 +86,10 @@ static signed long audio_linear_dither(unsigned int bits, mad_fixed_t sample,
|
|||||||
scalebits = MAD_F_FRACBITS + 1 - bits;
|
scalebits = MAD_F_FRACBITS + 1 - bits;
|
||||||
mask = (1L << scalebits) - 1;
|
mask = (1L << scalebits) - 1;
|
||||||
|
|
||||||
random = prng(dither->random);
|
rnd = prng(dither->random);
|
||||||
output += (random & mask) - (dither->random & mask);
|
output += (rnd & mask) - (dither->random & mask);
|
||||||
|
|
||||||
dither->random = random;
|
dither->random = rnd;
|
||||||
|
|
||||||
if (output > MAX) {
|
if (output > MAX) {
|
||||||
output = MAX;
|
output = MAX;
|
||||||
@ -1093,16 +1093,16 @@ static int mp3_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
static MpdTag *mp3_tagDup(char *file)
|
static MpdTag *mp3_tagDup(char *file)
|
||||||
{
|
{
|
||||||
MpdTag *ret = NULL;
|
MpdTag *ret = NULL;
|
||||||
int time;
|
int total_time;
|
||||||
|
|
||||||
ret = id3Dup(file);
|
ret = id3Dup(file);
|
||||||
|
|
||||||
time = getMp3TotalTime(file);
|
total_time = getMp3TotalTime(file);
|
||||||
|
|
||||||
if (time >= 0) {
|
if (total_time >= 0) {
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = newMpdTag();
|
ret = newMpdTag();
|
||||||
ret->time = time;
|
ret->time = total_time;
|
||||||
} else {
|
} else {
|
||||||
DEBUG("mp3_tagDup: Failed to get total song time from: %s\n",
|
DEBUG("mp3_tagDup: Failed to get total song time from: %s\n",
|
||||||
file);
|
file);
|
||||||
|
@ -134,7 +134,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
unsigned long samplePos = 0;
|
unsigned long samplePos = 0;
|
||||||
mpc_uint32_t vbrUpdateAcc;
|
mpc_uint32_t vbrUpdateAcc;
|
||||||
mpc_uint32_t vbrUpdateBits;
|
mpc_uint32_t vbrUpdateBits;
|
||||||
float time;
|
float total_time;
|
||||||
int i;
|
int i;
|
||||||
ReplayGainInfo *replayGainInfo = NULL;
|
ReplayGainInfo *replayGainInfo = NULL;
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
s16++;
|
s16++;
|
||||||
|
|
||||||
if (chunkpos >= MPC_CHUNK_SIZE) {
|
if (chunkpos >= MPC_CHUNK_SIZE) {
|
||||||
time = ((float)samplePos) /
|
total_time = ((float)samplePos) /
|
||||||
dc->audioFormat.sampleRate;
|
dc->audioFormat.sampleRate;
|
||||||
|
|
||||||
bitRate = vbrUpdateBits *
|
bitRate = vbrUpdateBits *
|
||||||
@ -227,7 +227,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
sendDataToOutputBuffer(cb, inStream, dc,
|
sendDataToOutputBuffer(cb, inStream, dc,
|
||||||
inStream->seekable,
|
inStream->seekable,
|
||||||
chunk, chunkpos,
|
chunk, chunkpos,
|
||||||
time,
|
total_time,
|
||||||
bitRate, replayGainInfo);
|
bitRate, replayGainInfo);
|
||||||
|
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
@ -241,13 +241,13 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dc->stop && chunkpos > 0) {
|
if (!dc->stop && chunkpos > 0) {
|
||||||
time = ((float)samplePos) / dc->audioFormat.sampleRate;
|
total_time = ((float)samplePos) / dc->audioFormat.sampleRate;
|
||||||
|
|
||||||
bitRate =
|
bitRate =
|
||||||
vbrUpdateBits * dc->audioFormat.sampleRate / 1152 / 1000;
|
vbrUpdateBits * dc->audioFormat.sampleRate / 1152 / 1000;
|
||||||
|
|
||||||
sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable,
|
sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable,
|
||||||
chunk, chunkpos, time, bitRate,
|
chunk, chunkpos, total_time, bitRate,
|
||||||
replayGainInfo);
|
replayGainInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
static float mpcGetTime(char *file)
|
static float mpcGetTime(char *file)
|
||||||
{
|
{
|
||||||
InputStream inStream;
|
InputStream inStream;
|
||||||
float time = -1;
|
float total_time = -1;
|
||||||
|
|
||||||
mpc_reader reader;
|
mpc_reader reader;
|
||||||
mpc_streaminfo info;
|
mpc_streaminfo info;
|
||||||
@ -289,19 +289,19 @@ static float mpcGetTime(char *file)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
time = mpc_streaminfo_get_length(&info);
|
total_time = mpc_streaminfo_get_length(&info);
|
||||||
|
|
||||||
closeInputStream(&inStream);
|
closeInputStream(&inStream);
|
||||||
|
|
||||||
return time;
|
return total_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MpdTag *mpcTagDup(char *file)
|
static MpdTag *mpcTagDup(char *file)
|
||||||
{
|
{
|
||||||
MpdTag *ret = NULL;
|
MpdTag *ret = NULL;
|
||||||
float time = mpcGetTime(file);
|
float total_time = mpcGetTime(file);
|
||||||
|
|
||||||
if (time < 0) {
|
if (total_time < 0) {
|
||||||
DEBUG("mpcTagDup: Failed to get Songlength of file: %s\n",
|
DEBUG("mpcTagDup: Failed to get Songlength of file: %s\n",
|
||||||
file);
|
file);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -312,7 +312,7 @@ static MpdTag *mpcTagDup(char *file)
|
|||||||
ret = id3Dup(file);
|
ret = id3Dup(file);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = newMpdTag();
|
ret = newMpdTag();
|
||||||
ret->time = time;
|
ret->time = total_time;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ void freeLocateTagItem(LocateTagItem * item)
|
|||||||
static int strstrSearchTag(Song * song, int type, char *str)
|
static int strstrSearchTag(Song * song, int type, char *str)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *dup;
|
char *duplicate;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
|
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
|
||||||
@ -145,10 +145,10 @@ static int strstrSearchTag(Song * song, int type, char *str)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dup = strDupToUpper(song->tag->items[i].value);
|
duplicate = strDupToUpper(song->tag->items[i].value);
|
||||||
if (strstr(dup, str))
|
if (strstr(duplicate, str))
|
||||||
ret = 1;
|
ret = 1;
|
||||||
free(dup);
|
free(duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
35
src/ls.c
35
src/ls.c
@ -103,7 +103,7 @@ int lsPlaylists(int fd, char *utf8path)
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char *dup;
|
char *duplicated;
|
||||||
char *utf8;
|
char *utf8;
|
||||||
char s[MPD_PATH_MAX];
|
char s[MPD_PATH_MAX];
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
@ -128,21 +128,20 @@ int lsPlaylists(int fd, char *utf8path)
|
|||||||
|
|
||||||
while ((ent = readdir(dir))) {
|
while ((ent = readdir(dir))) {
|
||||||
size_t len = strlen(ent->d_name) + 1;
|
size_t len = strlen(ent->d_name) + 1;
|
||||||
dup = ent->d_name;
|
duplicated = ent->d_name;
|
||||||
if (mpd_likely(len <= maxlen) &&
|
if (mpd_likely(len <= maxlen) &&
|
||||||
dup[0] != '.' &&
|
duplicated[0] != '.' &&
|
||||||
(suff = strlen(dup) - suflen) > 0 &&
|
(suff = strlen(duplicated) - suflen) > 0 &&
|
||||||
dup[suff] == '.' &&
|
duplicated[suff] == '.' &&
|
||||||
strcmp(dup + suff + 1, PLAYLIST_FILE_SUFFIX) == 0) {
|
strcmp(duplicated + suff + 1, PLAYLIST_FILE_SUFFIX) == 0) {
|
||||||
memcpy(s + actlen, ent->d_name, len);
|
memcpy(s + actlen, ent->d_name, len);
|
||||||
if (stat(s, &st) == 0) {
|
if (stat(s, &st) == 0) {
|
||||||
if (S_ISREG(st.st_mode)) {
|
if (S_ISREG(st.st_mode)) {
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
list = makeList(NULL, 1);
|
list = makeList(NULL, 1);
|
||||||
dup[suff] = '\0';
|
duplicated[suff] = '\0';
|
||||||
utf8 = fs_charset_to_utf8(path_max_tmp,
|
utf8 = fs_charset_to_utf8(path_max_tmp,
|
||||||
dup);
|
duplicated);
|
||||||
if (utf8)
|
if (utf8)
|
||||||
insertInList(list, utf8, NULL);
|
insertInList(list, utf8, NULL);
|
||||||
}
|
}
|
||||||
@ -156,25 +155,27 @@ int lsPlaylists(int fd, char *utf8path)
|
|||||||
int i;
|
int i;
|
||||||
sortList(list);
|
sortList(list);
|
||||||
|
|
||||||
dup = xmalloc(strlen(utf8path) + 2);
|
duplicated = xmalloc(strlen(utf8path) + 2);
|
||||||
strcpy(dup, utf8path);
|
strcpy(duplicated, utf8path);
|
||||||
for (i = strlen(dup) - 1; i >= 0 && dup[i] == '/'; i--) {
|
for (i = strlen(duplicated) - 1;
|
||||||
dup[i] = '\0';
|
i >= 0 && duplicated[i] == '/';
|
||||||
|
i--) {
|
||||||
|
duplicated[i] = '\0';
|
||||||
}
|
}
|
||||||
if (strlen(dup))
|
if (strlen(duplicated))
|
||||||
strcat(dup, "/");
|
strcat(duplicated, "/");
|
||||||
|
|
||||||
node = list->firstNode;
|
node = list->firstNode;
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
if (!strchr(node->key, '\n')) {
|
if (!strchr(node->key, '\n')) {
|
||||||
fdprintf(fd, "playlist: %s%s\n", dup,
|
fdprintf(fd, "playlist: %s%s\n", duplicated,
|
||||||
node->key);
|
node->key);
|
||||||
}
|
}
|
||||||
node = node->nextNode;
|
node = node->nextNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeList(list);
|
freeList(list);
|
||||||
free(dup);
|
free(duplicated);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -66,7 +66,7 @@ void flushOutputBuffer(OutputBuffer * cb)
|
|||||||
|
|
||||||
int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
||||||
DecoderControl * dc, int seekable, void *dataIn,
|
DecoderControl * dc, int seekable, void *dataIn,
|
||||||
long dataInLen, float time, mpd_uint16 bitRate,
|
long dataInLen, float data_time, mpd_uint16 bitRate,
|
||||||
ReplayGainInfo * replayGainInfo)
|
ReplayGainInfo * replayGainInfo)
|
||||||
{
|
{
|
||||||
mpd_uint16 dataToSend;
|
mpd_uint16 dataToSend;
|
||||||
@ -128,7 +128,7 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
|||||||
} else
|
} else
|
||||||
cb->metaChunk[currentChunk] = -1;
|
cb->metaChunk[currentChunk] = -1;
|
||||||
cb->bitRate[currentChunk] = bitRate;
|
cb->bitRate[currentChunk] = bitRate;
|
||||||
cb->times[currentChunk] = time;
|
cb->times[currentChunk] = data_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkLeft = CHUNK_SIZE - cb->chunkSize[currentChunk];
|
chunkLeft = CHUNK_SIZE - cb->chunkSize[currentChunk];
|
||||||
|
10
src/player.c
10
src/player.c
@ -276,7 +276,7 @@ int playerPause(int fd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerSetPause(int fd, int pause)
|
int playerSetPause(int fd, int pause_flag)
|
||||||
{
|
{
|
||||||
PlayerControl *pc = &(getPlayerData()->playerControl);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
@ -285,11 +285,11 @@ int playerSetPause(int fd, int pause)
|
|||||||
|
|
||||||
switch (pc->state) {
|
switch (pc->state) {
|
||||||
case PLAYER_STATE_PLAY:
|
case PLAYER_STATE_PLAY:
|
||||||
if (pause)
|
if (pause_flag)
|
||||||
playerPause(fd);
|
playerPause(fd);
|
||||||
break;
|
break;
|
||||||
case PLAYER_STATE_PAUSE:
|
case PLAYER_STATE_PAUSE:
|
||||||
if (!pause)
|
if (!pause_flag)
|
||||||
playerPause(fd);
|
playerPause(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -436,7 +436,7 @@ void playerQueueUnlock(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerSeek(int fd, Song * song, float time)
|
int playerSeek(int fd, Song * song, float seek_time)
|
||||||
{
|
{
|
||||||
PlayerControl *pc = &(getPlayerData()->playerControl);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
@ -452,7 +452,7 @@ int playerSeek(int fd, Song * song, float time)
|
|||||||
|
|
||||||
if (pc->error == PLAYER_ERROR_NOERROR) {
|
if (pc->error == PLAYER_ERROR_NOERROR) {
|
||||||
resetPlayerMetadata();
|
resetPlayerMetadata();
|
||||||
pc->seekWhere = time;
|
pc->seekWhere = seek_time;
|
||||||
pc->seek = 1;
|
pc->seek = 1;
|
||||||
if (player_pid > 0 && pc->state == PLAYER_STATE_PAUSE)
|
if (player_pid > 0 && pc->state == PLAYER_STATE_PAUSE)
|
||||||
kill(player_pid, SIGCONT);
|
kill(player_pid, SIGCONT);
|
||||||
|
@ -279,7 +279,7 @@ void savePlaylistState(FILE *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
|
static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
|
||||||
int state, int current, int time)
|
int state, int current, int seek_time)
|
||||||
{
|
{
|
||||||
char *temp;
|
char *temp;
|
||||||
int song;
|
int song;
|
||||||
@ -300,7 +300,8 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
|
|||||||
}
|
}
|
||||||
if (state != PLAYER_STATE_STOP) {
|
if (state != PLAYER_STATE_STOP) {
|
||||||
seekSongInPlaylist(STDERR_FILENO,
|
seekSongInPlaylist(STDERR_FILENO,
|
||||||
playlist.length - 1, time);
|
playlist.length - 1,
|
||||||
|
seek_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!myFgets(buffer, PLAYLIST_BUFFER_SIZE, fp))
|
if (!myFgets(buffer, PLAYLIST_BUFFER_SIZE, fp))
|
||||||
@ -311,7 +312,7 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
|
|||||||
void readPlaylistState(FILE *fp)
|
void readPlaylistState(FILE *fp)
|
||||||
{
|
{
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int time = 0;
|
int seek_time = 0;
|
||||||
int state = PLAYER_STATE_STOP;
|
int state = PLAYER_STATE_STOP;
|
||||||
char buffer[PLAYLIST_BUFFER_SIZE];
|
char buffer[PLAYLIST_BUFFER_SIZE];
|
||||||
|
|
||||||
@ -330,7 +331,7 @@ void readPlaylistState(FILE *fp)
|
|||||||
}
|
}
|
||||||
} else if (strncmp(buffer, PLAYLIST_STATE_FILE_TIME,
|
} else if (strncmp(buffer, PLAYLIST_STATE_FILE_TIME,
|
||||||
strlen(PLAYLIST_STATE_FILE_TIME)) == 0) {
|
strlen(PLAYLIST_STATE_FILE_TIME)) == 0) {
|
||||||
time =
|
seek_time =
|
||||||
atoi(&(buffer[strlen(PLAYLIST_STATE_FILE_TIME)]));
|
atoi(&(buffer[strlen(PLAYLIST_STATE_FILE_TIME)]));
|
||||||
} else
|
} else
|
||||||
if (strncmp
|
if (strncmp
|
||||||
@ -380,7 +381,7 @@ void readPlaylistState(FILE *fp)
|
|||||||
if (state == PLAYER_STATE_STOP)
|
if (state == PLAYER_STATE_STOP)
|
||||||
current = -1;
|
current = -1;
|
||||||
loadPlaylistFromStateFile(fp, buffer, state,
|
loadPlaylistFromStateFile(fp, buffer, state,
|
||||||
current, time);
|
current, seek_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1460,7 +1461,7 @@ int getPlaylistLength(void)
|
|||||||
return playlist.length;
|
return playlist.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int seekSongInPlaylist(int fd, int song, float time)
|
int seekSongInPlaylist(int fd, int song, float seek_time)
|
||||||
{
|
{
|
||||||
int i = song;
|
int i = song;
|
||||||
|
|
||||||
@ -1491,14 +1492,14 @@ int seekSongInPlaylist(int fd, int song, float time)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return playerSeek(fd, playlist.songs[playlist.order[i]], time);
|
return playerSeek(fd, playlist.songs[playlist.order[i]], seek_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
int seekSongInPlaylistById(int fd, int id, float time)
|
int seekSongInPlaylistById(int fd, int id, float seek_time)
|
||||||
{
|
{
|
||||||
checkSongId(id);
|
checkSongId(id);
|
||||||
|
|
||||||
return seekSongInPlaylist(fd, playlist.idToPosition[id], time);
|
return seekSongInPlaylist(fd, playlist.idToPosition[id], seek_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPlaylistSongId(int song)
|
int getPlaylistSongId(int song)
|
||||||
|
@ -51,7 +51,7 @@ int handlePendingSignals(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chldSigHandler(int signal)
|
static void chldSigHandler(int sig)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int pid;
|
int pid;
|
||||||
|
@ -27,16 +27,16 @@
|
|||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
static ListNode *nodeOfStoredPlaylist(List *list, int index)
|
static ListNode *nodeOfStoredPlaylist(List *list, int idx)
|
||||||
{
|
{
|
||||||
int forward;
|
int forward;
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (index >= list->numberOfNodes || index < 0)
|
if (idx >= list->numberOfNodes || idx < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (index > (list->numberOfNodes/2)) {
|
if (idx > (list->numberOfNodes/2)) {
|
||||||
forward = 0;
|
forward = 0;
|
||||||
node = list->lastNode;
|
node = list->lastNode;
|
||||||
i = list->numberOfNodes - 1;
|
i = list->numberOfNodes - 1;
|
||||||
@ -47,7 +47,7 @@ static ListNode *nodeOfStoredPlaylist(List *list, int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
if (i == index)
|
if (i == idx)
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
if (forward) {
|
if (forward) {
|
||||||
|
28
src/tag.c
28
src/tag.c
@ -588,17 +588,17 @@ MpdTag *newMpdTag(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deleteItem(MpdTag * tag, int index)
|
static void deleteItem(MpdTag * tag, int idx)
|
||||||
{
|
{
|
||||||
assert(index < tag->numOfItems);
|
assert(idx < tag->numOfItems);
|
||||||
tag->numOfItems--;
|
tag->numOfItems--;
|
||||||
|
|
||||||
removeTagItemString(tag->items[index].type, tag->items[index].value);
|
removeTagItemString(tag->items[idx].type, tag->items[idx].value);
|
||||||
/* free(tag->items[index].value); */
|
/* free(tag->items[idx].value); */
|
||||||
|
|
||||||
if (tag->numOfItems - index > 0) {
|
if (tag->numOfItems - idx > 0) {
|
||||||
memmove(tag->items + index, tag->items + index + 1,
|
memmove(tag->items + idx, tag->items + idx + 1,
|
||||||
tag->numOfItems - index);
|
tag->numOfItems - idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag->numOfItems > 0) {
|
if (tag->numOfItems > 0) {
|
||||||
@ -704,21 +704,21 @@ int mpdTagsAreEqual(MpdTag * tag1, MpdTag * tag2)
|
|||||||
static void appendToTagItems(MpdTag * tag, int type, char *value, int len)
|
static void appendToTagItems(MpdTag * tag, int type, char *value, int len)
|
||||||
{
|
{
|
||||||
int i = tag->numOfItems;
|
int i = tag->numOfItems;
|
||||||
char *dup = xmalloc(len + 1);
|
char *duplicated = xmalloc(len + 1);
|
||||||
|
|
||||||
memcpy(dup, value, len);
|
memcpy(duplicated, value, len);
|
||||||
dup[len] = '\0';
|
duplicated[len] = '\0';
|
||||||
|
|
||||||
fixUtf8(dup);
|
fixUtf8(duplicated);
|
||||||
stripReturnChar(dup);
|
stripReturnChar(duplicated);
|
||||||
|
|
||||||
tag->numOfItems++;
|
tag->numOfItems++;
|
||||||
tag->items = xrealloc(tag->items, tag->numOfItems * sizeof(MpdTagItem));
|
tag->items = xrealloc(tag->items, tag->numOfItems * sizeof(MpdTagItem));
|
||||||
|
|
||||||
tag->items[i].type = type;
|
tag->items[i].type = type;
|
||||||
tag->items[i].value = getTagItemString(type, dup);
|
tag->items[i].value = getTagItemString(type, duplicated);
|
||||||
|
|
||||||
free(dup);
|
free(duplicated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addItemToMpdTagWithLen(MpdTag * tag, int itemType, char *value, int len)
|
void addItemToMpdTagWithLen(MpdTag * tag, int itemType, char *value, int len)
|
||||||
|
@ -67,11 +67,11 @@ void timer_add(Timer *timer, int size)
|
|||||||
|
|
||||||
void timer_sync(Timer *timer)
|
void timer_sync(Timer *timer)
|
||||||
{
|
{
|
||||||
int64_t sleep;
|
int64_t sleep_duration;
|
||||||
|
|
||||||
assert(timer->started);
|
assert(timer->started);
|
||||||
|
|
||||||
sleep = timer->time - now();
|
sleep_duration = timer->time - now();
|
||||||
if (sleep > 0)
|
if (sleep_duration > 0)
|
||||||
my_usleep(sleep);
|
my_usleep(sleep_duration);
|
||||||
}
|
}
|
||||||
|
16
src/volume.c
16
src/volume.c
@ -95,7 +95,7 @@ static int prepOssMixer(char *device)
|
|||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
|
char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
|
||||||
char *dup;
|
char *duplicated;
|
||||||
int i, j;
|
int i, j;
|
||||||
int devmask = 0;
|
int devmask = 0;
|
||||||
|
|
||||||
@ -106,16 +106,16 @@ static int prepOssMixer(char *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
|
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
|
||||||
dup = xstrdup(labels[i]);
|
duplicated = xstrdup(labels[i]);
|
||||||
/* eliminate spaces at the end */
|
/* eliminate spaces at the end */
|
||||||
j = strlen(dup) - 1;
|
j = strlen(duplicated) - 1;
|
||||||
while (j >= 0 && dup[j] == ' ')
|
while (j >= 0 && duplicated[j] == ' ')
|
||||||
dup[j--] = '\0';
|
duplicated[j--] = '\0';
|
||||||
if (strcasecmp(dup, param->value) == 0) {
|
if (strcasecmp(duplicated, param->value) == 0) {
|
||||||
free(dup);
|
free(duplicated);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(dup);
|
free(duplicated);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= SOUND_MIXER_NRDEVICES) {
|
if (i >= SOUND_MIXER_NRDEVICES) {
|
||||||
|
Reference in New Issue
Block a user