fix -Wcast-qual -Wwrite-strings warnings
The previous patch enabled these warnings. In Eric's branch, they were worked around with a generic deconst_ptr() function. There are several places where we can add "const" to pointers, and in others, libraries want non-const strings. In the latter, convert string literals to "static char[]" variables - this takes the same space, and seems safer than deconsting a string literal.
This commit is contained in:
parent
b67bb05d05
commit
4dd9d4b2fd
@ -31,8 +31,8 @@ static const size_t sample_size = sizeof(jack_default_audio_sample_t);
|
|||||||
|
|
||||||
typedef struct _JackData {
|
typedef struct _JackData {
|
||||||
/* configuration */
|
/* configuration */
|
||||||
char *name;
|
const char *name;
|
||||||
char *output_ports[2];
|
const char *output_ports[2];
|
||||||
int ringbuf_sz;
|
int ringbuf_sz;
|
||||||
|
|
||||||
/* locks */
|
/* locks */
|
||||||
@ -52,6 +52,7 @@ typedef struct _JackData {
|
|||||||
static JackData *newJackData(void)
|
static JackData *newJackData(void)
|
||||||
{
|
{
|
||||||
JackData *ret;
|
JackData *ret;
|
||||||
|
|
||||||
ret = xcalloc(sizeof(JackData), 1);
|
ret = xcalloc(sizeof(JackData), 1);
|
||||||
|
|
||||||
ret->name = "mpd";
|
ret->name = "mpd";
|
||||||
@ -97,12 +98,12 @@ static void freeJackData(AudioOutput *audioOutput)
|
|||||||
freeJackClient(jd);
|
freeJackClient(jd);
|
||||||
|
|
||||||
if (strcmp(jd->name, "mpd") != 0)
|
if (strcmp(jd->name, "mpd") != 0)
|
||||||
free(jd->name);
|
xfree(jd->name);
|
||||||
|
|
||||||
for ( i = ARRAY_SIZE(jd->output_ports); --i >= 0; ) {
|
for ( i = ARRAY_SIZE(jd->output_ports); --i >= 0; ) {
|
||||||
if (!jd->output_ports[i])
|
if (!jd->output_ports[i])
|
||||||
continue;
|
continue;
|
||||||
free(jd->output_ports[i]);
|
xfree(jd->output_ports[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(jd);
|
free(jd);
|
||||||
@ -267,7 +268,7 @@ static int jack_testDefault(void)
|
|||||||
static int connect_jack(AudioOutput *audioOutput)
|
static int connect_jack(AudioOutput *audioOutput)
|
||||||
{
|
{
|
||||||
JackData *jd = audioOutput->data;
|
JackData *jd = audioOutput->data;
|
||||||
char **jports;
|
const char **jports;
|
||||||
char *port_name;
|
char *port_name;
|
||||||
|
|
||||||
if ( (jd->client = jack_client_new(jd->name)) == NULL ) {
|
if ( (jd->client = jack_client_new(jd->name)) == NULL ) {
|
||||||
@ -304,9 +305,9 @@ static int connect_jack(AudioOutput *audioOutput)
|
|||||||
|
|
||||||
/* hay que buscar que hay */
|
/* hay que buscar que hay */
|
||||||
if ( !jd->output_ports[1]
|
if ( !jd->output_ports[1]
|
||||||
&& (jports = (char **)jack_get_ports(jd->client, NULL, NULL,
|
&& (jports = jack_get_ports(jd->client, NULL, NULL,
|
||||||
JackPortIsPhysical|
|
JackPortIsPhysical|
|
||||||
JackPortIsInput)) ) {
|
JackPortIsInput)) ) {
|
||||||
jd->output_ports[0] = jports[0];
|
jd->output_ports[0] = jports[0];
|
||||||
jd->output_ports[1] = jports[1] ? jports[1] : jports[0];
|
jd->output_ports[1] = jports[1] ? jports[1] : jports[0];
|
||||||
DEBUG("output_ports: %s %s\n",
|
DEBUG("output_ports: %s %s\n",
|
||||||
|
@ -637,7 +637,7 @@ static int myShout_play(AudioOutput * audioOutput,
|
|||||||
|
|
||||||
for (i = 0; i < samples; i++) {
|
for (i = 0; i < samples; i++) {
|
||||||
for (j = 0; j < sd->audioFormat->channels; j++) {
|
for (j = 0; j < sd->audioFormat->channels; j++) {
|
||||||
vorbbuf[j][i] = (*((mpd_sint16 *) playChunk)) / 32768.0;
|
vorbbuf[j][i] = (*((const mpd_sint16 *) playChunk)) / 32768.0;
|
||||||
playChunk += bytes;
|
playChunk += bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,21 @@ static BOOL mod_mpd_IsThere(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char drv_name[] = "MPD";
|
||||||
|
static char drv_version[] = "MPD Output Driver v0.1";
|
||||||
|
|
||||||
|
#if (LIBMIKMOD_VERSION > 0x030106)
|
||||||
|
static char drv_alias[] = "mpd";
|
||||||
|
#endif
|
||||||
|
|
||||||
static MDRIVER drv_mpd = {
|
static MDRIVER drv_mpd = {
|
||||||
NULL,
|
NULL,
|
||||||
"MPD",
|
drv_name,
|
||||||
"MPD Output Driver v0.1",
|
drv_version,
|
||||||
0,
|
0,
|
||||||
255,
|
255,
|
||||||
#if (LIBMIKMOD_VERSION > 0x030106)
|
#if (LIBMIKMOD_VERSION > 0x030106)
|
||||||
"mpd", /* Alias */
|
drv_alias,
|
||||||
#if (LIBMIKMOD_VERSION >= 0x030200)
|
#if (LIBMIKMOD_VERSION >= 0x030200)
|
||||||
NULL, /* CmdLineHelp */
|
NULL, /* CmdLineHelp */
|
||||||
#endif
|
#endif
|
||||||
@ -92,6 +99,8 @@ static int mod_mikModInitError;
|
|||||||
|
|
||||||
static int mod_initMikMod(void)
|
static int mod_initMikMod(void)
|
||||||
{
|
{
|
||||||
|
static char params[] = "";
|
||||||
|
|
||||||
if (mod_mikModInitError)
|
if (mod_mikModInitError)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -110,7 +119,7 @@ static int mod_initMikMod(void)
|
|||||||
md_mode = (DMODE_SOFT_MUSIC | DMODE_INTERP | DMODE_STEREO |
|
md_mode = (DMODE_SOFT_MUSIC | DMODE_INTERP | DMODE_STEREO |
|
||||||
DMODE_16BITS);
|
DMODE_16BITS);
|
||||||
|
|
||||||
if (MikMod_Init("")) {
|
if (MikMod_Init(params)) {
|
||||||
ERROR("Could not init MikMod: %s\n",
|
ERROR("Could not init MikMod: %s\n",
|
||||||
MikMod_strerror(MikMod_errno));
|
MikMod_strerror(MikMod_errno));
|
||||||
mod_mikModInitError = 1;
|
mod_mikModInitError = 1;
|
||||||
|
@ -235,34 +235,38 @@ static char *wavpack_tag(WavpackContext *wpc, char *key)
|
|||||||
|
|
||||||
static ReplayGainInfo *wavpack_replaygain(WavpackContext *wpc)
|
static ReplayGainInfo *wavpack_replaygain(WavpackContext *wpc)
|
||||||
{
|
{
|
||||||
|
static char replaygain_track_gain[] = "replaygain_track_gain";
|
||||||
|
static char replaygain_album_gain[] = "replaygain_album_gain";
|
||||||
|
static char replaygain_track_peak[] = "replaygain_track_peak";
|
||||||
|
static char replaygain_album_peak[] = "replaygain_album_peak";
|
||||||
ReplayGainInfo *replayGainInfo;
|
ReplayGainInfo *replayGainInfo;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
replayGainInfo = newReplayGainInfo();
|
replayGainInfo = newReplayGainInfo();
|
||||||
|
|
||||||
value = wavpack_tag(wpc, "replaygain_track_gain");
|
value = wavpack_tag(wpc, replaygain_track_gain);
|
||||||
if (value) {
|
if (value) {
|
||||||
replayGainInfo->trackGain = atof(value);
|
replayGainInfo->trackGain = atof(value);
|
||||||
free(value);
|
free(value);
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = wavpack_tag(wpc, "replaygain_album_gain");
|
value = wavpack_tag(wpc, replaygain_album_gain);
|
||||||
if (value) {
|
if (value) {
|
||||||
replayGainInfo->albumGain = atof(value);
|
replayGainInfo->albumGain = atof(value);
|
||||||
free(value);
|
free(value);
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = wavpack_tag(wpc, "replaygain_track_peak");
|
value = wavpack_tag(wpc, replaygain_track_peak);
|
||||||
if (value) {
|
if (value) {
|
||||||
replayGainInfo->trackPeak = atof(value);
|
replayGainInfo->trackPeak = atof(value);
|
||||||
free(value);
|
free(value);
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = wavpack_tag(wpc, "replaygain_album_peak");
|
value = wavpack_tag(wpc, replaygain_album_peak);
|
||||||
if (value) {
|
if (value) {
|
||||||
replayGainInfo->albumPeak = atof(value);
|
replayGainInfo->albumPeak = atof(value);
|
||||||
free(value);
|
free(value);
|
||||||
|
@ -301,11 +301,6 @@ int deleteFromList(List * list, const char *key)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_const_string(const char *p)
|
|
||||||
{
|
|
||||||
free((char *)p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void deleteNodeFromList(List * list, ListNode * node)
|
void deleteNodeFromList(List * list, ListNode * node)
|
||||||
{
|
{
|
||||||
assert(list != NULL);
|
assert(list != NULL);
|
||||||
@ -326,7 +321,7 @@ void deleteNodeFromList(List * list, ListNode * node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (list->strdupKeys)
|
if (list->strdupKeys)
|
||||||
free_const_string(node->key);
|
xfree(node->key);
|
||||||
free(node);
|
free(node);
|
||||||
list->numberOfNodes--;
|
list->numberOfNodes--;
|
||||||
|
|
||||||
@ -353,7 +348,7 @@ void freeList(void *list)
|
|||||||
while (tmpNode != NULL) {
|
while (tmpNode != NULL) {
|
||||||
tmpNode2 = tmpNode->nextNode;
|
tmpNode2 = tmpNode->nextNode;
|
||||||
if (((List *) list)->strdupKeys)
|
if (((List *) list)->strdupKeys)
|
||||||
free_const_string(tmpNode->key);
|
xfree(tmpNode->key);
|
||||||
if (((List *) list)->freeDataFunc) {
|
if (((List *) list)->freeDataFunc) {
|
||||||
((List *) list)->freeDataFunc(tmpNode->data);
|
((List *) list)->freeDataFunc(tmpNode->data);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,7 @@ static int pcm_getSampleRateConverter(void)
|
|||||||
const char *conf = getConfigParamValue(CONF_SAMPLERATE_CONVERTER);
|
const char *conf = getConfigParamValue(CONF_SAMPLERATE_CONVERTER);
|
||||||
long convalgo;
|
long convalgo;
|
||||||
char *test;
|
char *test;
|
||||||
|
const char *test2;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
@ -162,12 +163,12 @@ static int pcm_getSampleRateConverter(void)
|
|||||||
|
|
||||||
len = strlen(conf);
|
len = strlen(conf);
|
||||||
for (convalgo = 0 ; ; convalgo++) {
|
for (convalgo = 0 ; ; convalgo++) {
|
||||||
test = (char *)src_get_name(convalgo);
|
test2 = src_get_name(convalgo);
|
||||||
if (!test) {
|
if (!test2) {
|
||||||
convalgo = SRC_SINC_FASTEST;
|
convalgo = SRC_SINC_FASTEST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strncasecmp(test, conf, len) == 0)
|
if (strncasecmp(test2, conf, len) == 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +240,7 @@ static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate,
|
|||||||
data->data_out = xrealloc(data->data_out, dataOutSize);
|
data->data_out = xrealloc(data->data_out, dataOutSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
src_short_to_float_array((short *)inBuffer, data->data_in,
|
src_short_to_float_array((const short *)inBuffer, data->data_in,
|
||||||
data->input_frames * channels);
|
data->input_frames * channels);
|
||||||
|
|
||||||
error = src_process(convState->state, data);
|
error = src_process(convState->state, data);
|
||||||
@ -305,7 +306,7 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer,
|
|||||||
static char *buf;
|
static char *buf;
|
||||||
static size_t len;
|
static size_t len;
|
||||||
char *outBuffer = NULL;
|
char *outBuffer = NULL;
|
||||||
mpd_sint16 *in;
|
const mpd_sint16 *in;
|
||||||
mpd_sint16 *out;
|
mpd_sint16 *out;
|
||||||
int inSamples, i;
|
int inSamples, i;
|
||||||
|
|
||||||
@ -320,7 +321,7 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer,
|
|||||||
outBuffer = buf;
|
outBuffer = buf;
|
||||||
|
|
||||||
inSamples = inSize >> 1;
|
inSamples = inSize >> 1;
|
||||||
in = (mpd_sint16 *)inBuffer;
|
in = (const mpd_sint16 *)inBuffer;
|
||||||
out = (mpd_sint16 *)outBuffer;
|
out = (mpd_sint16 *)outBuffer;
|
||||||
for (i = 0; i < inSamples; i++) {
|
for (i = 0; i < inSamples; i++) {
|
||||||
*out++ = *in;
|
*out++ = *in;
|
||||||
@ -338,7 +339,7 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer,
|
|||||||
outBuffer = buf;
|
outBuffer = buf;
|
||||||
|
|
||||||
inSamples = inSize >> 2;
|
inSamples = inSize >> 2;
|
||||||
in = (mpd_sint16 *)inBuffer;
|
in = (const mpd_sint16 *)inBuffer;
|
||||||
out = (mpd_sint16 *)outBuffer;
|
out = (mpd_sint16 *)outBuffer;
|
||||||
for (i = 0; i < inSamples; i++) {
|
for (i = 0; i < inSamples; i++) {
|
||||||
*out = (*in++) / 2;
|
*out = (*in++) / 2;
|
||||||
@ -359,7 +360,7 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer,
|
|||||||
static char *buf;
|
static char *buf;
|
||||||
static size_t len;
|
static size_t len;
|
||||||
char *outBuffer = NULL;
|
char *outBuffer = NULL;
|
||||||
mpd_sint8 *in;
|
const mpd_sint8 *in;
|
||||||
mpd_sint16 *out;
|
mpd_sint16 *out;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -372,7 +373,7 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer,
|
|||||||
}
|
}
|
||||||
outBuffer = buf;
|
outBuffer = buf;
|
||||||
|
|
||||||
in = (mpd_sint8 *)inBuffer;
|
in = (const mpd_sint8 *)inBuffer;
|
||||||
out = (mpd_sint16 *)outBuffer;
|
out = (mpd_sint16 *)outBuffer;
|
||||||
for (i = 0; i < inSize; i++)
|
for (i = 0; i < inSize; i++)
|
||||||
*out++ = (*in++) << 8;
|
*out++ = (*in++) << 8;
|
||||||
|
Loading…
Reference in New Issue
Block a user