Commit 85a525d6 authored by sletz's avatar sletz
Browse files

Fix errors found by cppcheck.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3947 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 8b069b93
......@@ -194,7 +194,7 @@ namespace Jack {
}
if (fgets(buf, sizeof(buf), in) == NULL) {
fclose(in);
pclose(in);
return -1;
}
......@@ -202,7 +202,7 @@ namespace Jack {
if (buf[len - 1] != '\n') {
/* didn't get a whole line */
fclose(in);
pclose(in);
return -1;
}
......@@ -210,7 +210,7 @@ namespace Jack {
memcpy(jack_tmpdir, buf, len - 1);
jack_tmpdir[len - 1] = '\0';
fclose(in);
pclose(in);
return 0;
}
#endif
......
......@@ -46,7 +46,6 @@ InternalMetro::InternalMetro(int freq, double max_amp, int dur_arg, int bpm, cha
{
sample_t scale;
int i, attack_length, decay_length;
double *amp;
int attack_percent = 1, decay_percent = 10;
const char *bpm_string = "bpm";
......@@ -59,7 +58,7 @@ InternalMetro::InternalMetro(int freq, double max_amp, int dur_arg, int bpm, cha
}
if ((client = jack_client_open (client_name, JackNullOption, NULL)) == 0) {
fprintf (stderr, "jack server not running?\n");
return ;
return;
}
jack_set_process_callback (client, process_audio, this);
......@@ -81,11 +80,11 @@ InternalMetro::InternalMetro(int freq, double max_amp, int dur_arg, int bpm, cha
", wave length = %" PRIu32 "\n", tone_length,
wave_length);
*/
return ;
return;
}
if (attack_length + decay_length > (int)tone_length) {
fprintf (stderr, "invalid attack/decay\n");
return ;
return;
}
/* Build the wave table */
......@@ -110,7 +109,6 @@ InternalMetro::InternalMetro(int freq, double max_amp, int dur_arg, int bpm, cha
if (jack_activate (client)) {
fprintf(stderr, "cannot activate client");
return;
}
}
......@@ -120,4 +118,6 @@ InternalMetro::~InternalMetro()
jack_port_unregister(client, input_port);
jack_port_unregister(client, output_port);
jack_client_close(client);
free(amp);
free(wave);
}
......@@ -53,6 +53,7 @@ extern "C"
int bpm;
jack_nframes_t tone_length, wave_length;
sample_t *wave;
double *amp;
long offset ;
InternalMetro(int freq, double max_amp, int dur_arg, int bpm, char* client_name);
......
......@@ -257,7 +257,7 @@ main (int argc, char *argv[])
if (jack_activate (client)) {
fprintf (stderr, "cannot activate client\n");
return 1;
goto error;
}
/* install a signal handler to properly quits jack client */
......@@ -282,5 +282,9 @@ main (int argc, char *argv[])
};
jack_client_close(client);
error:
free(amp);
free(wave);
exit (0);
}
......@@ -881,7 +881,7 @@ extern "C"
switch (param->character) {
case 'd':
device_name = strdup (param->value.str);
device_name = param->value.str;
break;
case 'p':
cmlparams.period_size = param->value.ui;
......
......@@ -2002,8 +2002,8 @@ extern "C"
switch (param->character) {
case 'd':
capture_driver_uid = strdup(param->value.str);
playback_driver_uid = strdup(param->value.str);
capture_driver_uid = param->value.str;
playback_driver_uid = param->value.str;
break;
case 'D':
......@@ -2026,14 +2026,14 @@ extern "C"
case 'C':
capture = true;
if (strcmp(param->value.str, "none") != 0) {
capture_driver_uid = strdup(param->value.str);
capture_driver_uid = param->value.str;
}
break;
case 'P':
playback = true;
if (strcmp(param->value.str, "none") != 0) {
playback_driver_uid = strdup(param->value.str);
playback_driver_uid = param->value.str;
}
break;
......
......@@ -985,20 +985,20 @@ EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine
case 'C':
capture = true;
if (strcmp(param->value.str, "none") != 0) {
capture_pcm_name = strdup(param->value.str);
capture_pcm_name = param->value.str;
}
break;
case 'P':
playback = true;
if (strcmp(param->value.str, "none") != 0) {
playback_pcm_name = strdup(param->value.str);
playback_pcm_name = param->value.str;
}
break;
case 'd':
playback_pcm_name = strdup (param->value.str);
capture_pcm_name = strdup (param->value.str);
playback_pcm_name = param->value.str;
capture_pcm_name = param->value.str;
break;
case 'e':
......
......@@ -904,20 +904,20 @@ EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine
case 'C':
capture = true;
if (strcmp(param->value.str, "none") != 0) {
capture_pcm_name = strdup(param->value.str);
capture_pcm_name = param->value.str;
}
break;
case 'P':
playback = true;
if (strcmp(param->value.str, "none") != 0) {
playback_pcm_name = strdup(param->value.str);
playback_pcm_name = param->value.str;
}
break;
case 'd':
playback_pcm_name = strdup (param->value.str);
capture_pcm_name = strdup (param->value.str);
playback_pcm_name = param->value.str;
capture_pcm_name = param->value.str;
break;
case 'b':
......
......@@ -60,7 +60,6 @@ ExternalMetro::ExternalMetro(int freq, double max_amp, int dur_arg, int bpm, con
{
sample_t scale;
int i, attack_length, decay_length;
double *amp;
int attack_percent = 1, decay_percent = 10;
const char *bpm_string = "bpm";
jack_options_t options = JackNullOption;
......@@ -131,6 +130,8 @@ ExternalMetro::~ExternalMetro()
jack_port_unregister(client, input_port);
jack_port_unregister(client, output_port);
jack_client_close(client);
free(amp);
free(wave);
}
int main (int argc, char *argv[])
......
......@@ -53,6 +53,7 @@ extern "C"
int bpm;
jack_nframes_t tone_length, wave_length;
sample_t *wave;
double *amp;
long offset ;
ExternalMetro(int freq, double max_amp, int dur_arg, int bpm, const char* client_name = "metro");
......
......@@ -404,8 +404,8 @@ extern "C"
{
case 'd':
capture_pcm_name = strdup(param->value.str);
playback_pcm_name = strdup(param->value.str);
capture_pcm_name = param->value.str;
playback_pcm_name = param->value.str;
break;
case 'D':
......@@ -428,14 +428,14 @@ extern "C"
case 'C':
capture = true;
if (strcmp(param->value.str, "none") != 0) {
capture_pcm_name = strdup(param->value.str);
capture_pcm_name = param->value.str;
}
break;
case 'P':
playback = TRUE;
if (strcmp(param->value.str, "none") != 0) {
playback_pcm_name = strdup(param->value.str);
playback_pcm_name = param->value.str;
}
break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment