diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-01-31 17:43:00 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-01-31 17:43:00 +0100 |
commit | ef4fe8e4c89bcf8df9b3f74d285d8bbd71a09eea (patch) | |
tree | 9fccf82e53d3df2f41546c609a613872c48c0ee9 /src | |
parent | b91dada75f804ccca64644f6d40276db4815f4b3 (diff) | |
download | pianobar-ef4fe8e4c89bcf8df9b3f74d285d8bbd71a09eea.tar.gz pianobar-ef4fe8e4c89bcf8df9b3f74d285d8bbd71a09eea.tar.bz2 pianobar-ef4fe8e4c89bcf8df9b3f74d285d8bbd71a09eea.zip |
Switch to clang for debugging build + fix issues
Diffstat (limited to 'src')
-rw-r--r-- | src/libpiano/piano.h | 9 | ||||
-rw-r--r-- | src/libpiano/response.c | 31 | ||||
-rw-r--r-- | src/player.c | 4 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h index ce66171..d8b84ce 100644 --- a/src/libpiano/piano.h +++ b/src/libpiano/piano.h @@ -310,14 +310,17 @@ size_t PianoListCount (const PianoListHead_t * const l); #define PianoListCountP(l) PianoListCount(&(l)->head) void *PianoListAppend (PianoListHead_t * const l, PianoListHead_t * const e) __attribute__ ((warn_unused_result)); -#define PianoListAppendP(l,e) PianoListAppend(&(l)->head, &(e)->head) +#define PianoListAppendP(l,e) PianoListAppend(((l) == NULL) ? NULL : &(l)->head, \ + &(e)->head) void *PianoListDelete (PianoListHead_t * const l, PianoListHead_t * const e) __attribute__ ((warn_unused_result)); -#define PianoListDeleteP(l,e) PianoListDelete(&(l)->head, &(e)->head) +#define PianoListDeleteP(l,e) PianoListDelete(((l) == NULL) ? NULL : &(l)->head, \ + &(e)->head) #define PianoListNextP(e) ((void *) (e)->head.next) void *PianoListPrepend (PianoListHead_t * const l, PianoListHead_t * const e) __attribute__ ((warn_unused_result)); -#define PianoListPrependP(l,e) PianoListPrepend (&(l)->head, &(e)->head) +#define PianoListPrependP(l,e) PianoListPrepend (((l) == NULL) ? NULL : &(l)->head, \ + &(e)->head) void *PianoListGet (PianoListHead_t * const l, const size_t n); #define PianoListGetP(l,n) PianoListGet (&(l)->head, n) #define PianoListForeachP(l) for (; (l) != NULL; (l) = (void *) (l)->head.next) diff --git a/src/libpiano/response.c b/src/libpiano/response.c index 41bbfd3..53d22c1 100644 --- a/src/libpiano/response.c +++ b/src/libpiano/response.c @@ -130,9 +130,8 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { switch (reqData->step) { case 0: { /* decrypt timestamp */ - const char *cryptedTimestamp = json_object_get_string ( + const char * const cryptedTimestamp = json_object_get_string ( json_object_object_get (result, "syncTime")); - unsigned long timestamp = 0; const time_t realTimestamp = time (NULL); char *decryptedTimestamp = NULL; size_t decryptedSize; @@ -142,8 +141,10 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { cryptedTimestamp, &decryptedSize)) != NULL && decryptedSize > 4) { /* skip four bytes garbage(?) at beginning */ - timestamp = strtoul (decryptedTimestamp+4, NULL, 0); - ph->timeOffset = realTimestamp - timestamp; + const unsigned long timestamp = strtoul ( + decryptedTimestamp+4, NULL, 0); + ph->timeOffset = (long int) realTimestamp - + (long int) timestamp; ret = PIANO_RET_CONTINUE_REQUEST; } free (decryptedTimestamp); @@ -177,7 +178,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { json_object *stations = json_object_object_get (result, "stations"), *mix = NULL; - for (size_t i=0; i < json_object_array_length (stations); i++) { + for (int i = 0; i < json_object_array_length (stations); i++) { PianoStation_t *tmpStation; json_object *s = json_object_array_get_idx (stations, i); @@ -200,7 +201,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { if (mix != NULL) { PianoStation_t *curStation = ph->stations; PianoListForeachP (curStation) { - for (size_t i = 0; i < json_object_array_length (mix); i++) { + for (int i = 0; i < json_object_array_length (mix); i++) { json_object *id = json_object_array_get_idx (mix, i); if (strcmp (json_object_get_string (id), curStation->id) == 0) { @@ -224,7 +225,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { json_object *items = json_object_object_get (result, "items"); assert (items != NULL); - for (size_t i=0; i < json_object_array_length (items); i++) { + for (int i = 0; i < json_object_array_length (items); i++) { json_object *s = json_object_array_get_idx (items, i); PianoSong_t *song; @@ -342,7 +343,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { /* get artists */ json_object *artists = json_object_object_get (result, "artists"); if (artists != NULL) { - for (size_t i=0; i < json_object_array_length (artists); i++) { + for (int i = 0; i < json_object_array_length (artists); i++) { json_object *a = json_object_array_get_idx (artists, i); PianoArtist_t *artist; @@ -361,7 +362,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { /* get songs */ json_object *songs = json_object_object_get (result, "songs"); if (songs != NULL) { - for (size_t i=0; i < json_object_array_length (songs); i++) { + for (int i = 0; i < json_object_array_length (songs); i++) { json_object *s = json_object_array_get_idx (songs, i); PianoSong_t *song; @@ -415,7 +416,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { /* get genre stations */ json_object *categories = json_object_object_get (result, "categories"); if (categories != NULL) { - for (size_t i = 0; i < json_object_array_length (categories); i++) { + for (int i = 0; i < json_object_array_length (categories); i++) { json_object *c = json_object_array_get_idx (categories, i); PianoGenreCategory_t *tmpGenreCategory; @@ -431,7 +432,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { json_object *stations = json_object_object_get (c, "stations"); if (stations != NULL) { - for (size_t k = 0; + for (int k = 0; k < json_object_array_length (stations); k++) { json_object *s = json_object_array_get_idx (stations, k); @@ -486,7 +487,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { sizeof (*reqData->retExplain)); strncpy (reqData->retExplain, "We're playing this track " "because it features ", strSize); - for (size_t i=0; i < json_object_array_length (explanations); i++) { + for (int i = 0; i < json_object_array_length (explanations); i++) { json_object *e = json_object_array_get_idx (explanations, i); const char *s = json_object_get_string ( @@ -521,7 +522,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { /* songs */ json_object *songs = json_object_object_get (music, "songs"); if (songs != NULL) { - for (size_t i = 0; i < json_object_array_length (songs); i++) { + for (int i = 0; i < json_object_array_length (songs); i++) { json_object *s = json_object_array_get_idx (songs, i); PianoSong_t *seedSong; @@ -543,7 +544,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { json_object *artists = json_object_object_get (music, "artists"); if (artists != NULL) { - for (size_t i = 0; i < json_object_array_length (artists); i++) { + for (int i = 0; i < json_object_array_length (artists); i++) { json_object *a = json_object_array_get_idx (artists, i); PianoArtist_t *seedArtist; @@ -566,7 +567,7 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { "feedback"); if (feedback != NULL) { json_object_object_foreach (feedback, key, val) { - for (size_t i = 0; i < json_object_array_length (val); i++) { + for (int i = 0; i < json_object_array_length (val); i++) { json_object *s = json_object_array_get_idx (val, i); PianoSong_t *feedbackSong; diff --git a/src/player.c b/src/player.c index 939b326..55b9e90 100644 --- a/src/player.c +++ b/src/player.c @@ -83,8 +83,8 @@ unsigned int BarPlayerCalcScale (const float applyGain) { */ static inline signed short int applyReplayGain (const signed short int value, const unsigned int scale) { - int tmpReplayBuf = value * scale; - /* avoid clipping */ + int tmpReplayBuf = value * (signed int) scale; + /* clipping */ if (tmpReplayBuf > SHRT_MAX*RG_SCALE_FACTOR) { return SHRT_MAX; } else if (tmpReplayBuf < SHRT_MIN*RG_SCALE_FACTOR) { |