1
0
Fork 0

Fix compilation under gcc 4.4

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3366
This commit is contained in:
Peter Veenstra 2009-04-27 09:17:03 +00:00
parent d261fb01fd
commit 076a8e78b8

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2007 The DOSBox Team
* Copyright (C) 2002-2009 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,13 +16,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: midi_alsa.h,v 1.18 2009-04-25 15:57:07 qbix79 Exp $ */
/* $Id: midi_alsa.h,v 1.19 2009-04-27 09:17:03 qbix79 Exp $ */
#define ALSA_PCM_OLD_HW_PARAMS_API
#define ALSA_PCM_OLD_SW_PARAMS_API
#include <alsa/asoundlib.h>
#include <ctype.h>
#include <string>
#include <sstream>
#define ADDR_DELIM ".:"
#if ((SND_LIB_MINOR >= 6) && (SND_LIB_MAJOR == 0)) || (SND_LIB_MAJOR >= 1)
@ -50,22 +51,24 @@ private:
snd_seq_flush_output(seq_handle);
}
int parse_addr(const char *arg, int *client, int *port) {
char *p;
bool parse_addr(const char *arg, int *client, int *port) {
std::string in(arg);
if(in.empty()) return false;
if (isdigit(*arg)) {
if ((p = strpbrk(arg, ADDR_DELIM)) == NULL)
return -1;
*client = atoi(arg);
*port = atoi(p + 1);
} else {
if (*arg == 's' || *arg == 'S') {
*client = SND_SEQ_ADDRESS_SUBSCRIBERS;
*port = 0;
} else
return -1;
if(in[0] == 's' || in[0] == 'S') {
*client = SND_SEQ_ADDRESS_SUBSCRIBERS;
*port = 0;
return true;
}
return 0;
if(in.find_first_of(ADDR_DELIM) == std::string::npos) return false;
std::istringstream inp(in);
int val1, val2; char c;
if(!(inp >> val1)) return false;
if(!(inp >> c )) return false;
if(!(inp >> val2)) return false;
*client = val1; *port = val2;
return true;
}
public:
MidiHandler_alsa() : MidiHandler() {};
@ -130,14 +133,14 @@ public:
// try to use port specified in config file
if (conf && conf[0]) {
safe_strncpy(var, conf, 10);
if (parse_addr(var, &seq_client, &seq_port) < 0) {
if (!parse_addr(var, &seq_client, &seq_port)) {
LOG_MSG("ALSA:Invalid alsa port %s", var);
return false;
}
defaultport = false;
}
// default port if none specified
else if (parse_addr("65:0", &seq_client, &seq_port) < 0) {
else if (!parse_addr("65:0", &seq_client, &seq_port)) {
LOG_MSG("ALSA:Invalid alsa port 65:0");
return false;
}