Browse Source

Correct GetPortTypeId, various cleanup.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2546 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
7bfa336f7d
12 changed files with 30 additions and 25 deletions
  1. +2
    -2
      common/JackAPI.cpp
  2. +1
    -1
      common/JackDriverLoader.cpp
  3. +1
    -1
      common/JackLibAPI.cpp
  4. +3
    -3
      common/JackMidiAPI.cpp
  5. +2
    -2
      common/JackPort.cpp
  6. +6
    -9
      common/JackPortType.cpp
  7. +2
    -0
      common/JackPortType.h
  8. +2
    -0
      common/JackRequest.h
  9. +1
    -1
      common/JackThread.h
  10. +6
    -3
      common/varargs.h
  11. +2
    -2
      windows/JackWinNamedPipe.cpp
  12. +2
    -1
      windows/JackWinThread.h

+ 2
- 2
common/JackAPI.cpp View File

@@ -1636,7 +1636,7 @@ EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intcl
if (client == NULL) {
jack_error("jack_get_internal_client_name called with a NULL client");
return NULL;
} else if (intclient < 0 || intclient >= CLIENT_NUM) {
} else if (intclient >= CLIENT_NUM) {
jack_error("jack_get_internal_client_name: incorrect client");
return NULL;
} else {
@@ -1710,7 +1710,7 @@ EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack
if (client == NULL) {
jack_error("jack_internal_client_unload called with a NULL client");
return (jack_status_t)(JackNoSuchClient | JackFailure);
} else if (intclient < 0 || intclient >= CLIENT_NUM) {
} else if (intclient >= CLIENT_NUM) {
jack_error("jack_internal_client_unload: incorrect client");
return (jack_status_t)(JackNoSuchClient | JackFailure);
} else {


+ 1
- 1
common/JackDriverLoader.cpp View File

@@ -238,7 +238,7 @@ jackctl_parse_driver_params (jackctl_driver *driver_ptr, int argc, char* argv[])
unsigned long i;
int opt;
JSList * node_ptr;
jackctl_parameter_t * param;
jackctl_parameter_t * param = NULL;
union jackctl_parameter_value value;

if (argc <= 1)


+ 1
- 1
common/JackLibAPI.cpp View File

@@ -122,7 +122,7 @@ EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options
{
va_list ap;
va_start(ap, status);
jack_client_t* res = jack_client_open_aux(ext_client_name, options, status, ap);
jack_client_t* res = jack_client_open_aux(ext_client_name, options, status, ap);
va_end(ap);
return res;
}


+ 3
- 3
common/JackMidiAPI.cpp View File

@@ -75,7 +75,7 @@ int jack_midi_event_get(jack_midi_event_t *event, void* port_buffer, jack_nframe
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer;
if (!buf || !buf->IsValid())
return -EINVAL;
if (event_index < 0 || event_index >= buf->event_count)
if (event_index >= buf->event_count)
return -ENOBUFS;
JackMidiEvent* ev = &buf->events[event_index];
event->time = ev->time;
@@ -107,7 +107,7 @@ jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer;
if (!buf && !buf->IsValid())
return 0;
if (time < 0 || time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time))
if (time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time))
return 0;
return buf->ReserveEvent(time, data_size);
}
@@ -119,7 +119,7 @@ int jack_midi_event_write(void* port_buffer,
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer;
if (!buf && !buf->IsValid())
return -EINVAL;
if (time < 0 || time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time))
if (time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time))
return -EINVAL;
jack_midi_data_t* dest = buf->ReserveEvent(time, data_size);
if (!dest)


+ 2
- 2
common/JackPort.cpp View File

@@ -45,8 +45,8 @@ JackPort::JackPort()

bool JackPort::Allocate(int refnum, const char* port_name, const char* port_type, JackPortFlags flags)
{
int id = GetPortTypeId(port_type);
if (id < 0)
jack_port_type_id_t id = GetPortTypeId(port_type);
if (id == PORT_TYPES_MAX)
return false;
fTypeId = id;
fFlags = flags;


+ 6
- 9
common/JackPortType.cpp View File

@@ -29,25 +29,22 @@ namespace Jack
{

static const JackPortType* port_types[] =
{
&gAudioPortType,
&gMidiPortType,
};

enum
{
PORT_TYPES_MAX = sizeof(port_types) / sizeof(port_types[0])
&gAudioPortType,
&gMidiPortType,
};

jack_port_type_id_t PORT_TYPES_MAX = sizeof(port_types) / sizeof(port_types[0]);

jack_port_type_id_t GetPortTypeId(const char* port_type)
{
for (int i = 0; i < PORT_TYPES_MAX; ++i) {
for (jack_port_type_id_t i = 0; i < PORT_TYPES_MAX; ++i) {
const JackPortType* type = port_types[i];
assert(type != 0);
if (strcmp(port_type, type->name) == 0)
return i;
}
return -1;
return PORT_TYPES_MAX;
}

const JackPortType* GetPortType(jack_port_type_id_t type_id)


+ 2
- 0
common/JackPortType.h View File

@@ -27,6 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace Jack
{

extern jack_port_type_id_t PORT_TYPES_MAX;

struct JackPortType
{
const char* name;


+ 2
- 0
common/JackRequest.h View File

@@ -823,7 +823,9 @@ struct JackInternalClientHandleResult : public JackResult
struct JackInternalClientLoadRequest : public JackRequest
{

#ifndef MAX_PATH
#define MAX_PATH 256
#endif

int fRefNum;
char fName[JACK_CLIENT_NAME_SIZE + 1];


+ 1
- 1
common/JackThread.h View File

@@ -65,7 +65,7 @@ class JackRunnableInterface
namespace detail
{

class JackThread
class EXPORT JackThread
{

public:


+ 6
- 3
common/varargs.h View File

@@ -37,19 +37,22 @@ extern "C"
}
jack_varargs_t;

static const char* jack_default_server_name (void) {
static const char* jack_default_server_name (void)
{
const char *server_name;
if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL)
server_name = "default";
return server_name;
}

static inline void jack_varargs_init (jack_varargs_t *va) {
static inline void jack_varargs_init (jack_varargs_t *va)
{
memset (va, 0, sizeof(jack_varargs_t));
va->server_name = (char*)jack_default_server_name();
}

static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) {
static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va)
{
// initialize default settings
jack_varargs_init (va);



+ 2
- 2
windows/JackWinNamedPipe.cpp View File

@@ -35,7 +35,7 @@ int JackWinNamedPipe::Read(void* data, int len)
{
DWORD read;
BOOL res = ReadFile(fNamedPipe, data, len, &read, NULL);
if (read != len) {
if (read != (DWORD)len) {
jack_error("Cannot read named pipe err = %ld", GetLastError());
return -1;
} else {
@@ -47,7 +47,7 @@ int JackWinNamedPipe::Write(void* data, int len)
{
DWORD written;
BOOL res = WriteFile(fNamedPipe, data, len, &written, NULL);
if (written != len) {
if (written != (DWORD)len) {
jack_error("Cannot write named pipe err = %ld", GetLastError());
return -1;
} else {


+ 2
- 1
windows/JackWinThread.h View File

@@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define __JackWinThread__

#include "JackThread.h"
#include "JackExports.h"
#include <windows.h>

namespace Jack
@@ -34,7 +35,7 @@ typedef DWORD (WINAPI *ThreadCallback)(void *arg);
\brief Windows threads.
*/

class JackWinThread : public detail::JackThread
class EXPORT JackWinThread : public detail::JackThread
{

private:


Loading…
Cancel
Save