1998-08-27 20:47:51 +00:00
|
|
|
/*
|
|
|
|
|
* RawMIDI Interface - main file
|
|
|
|
|
* Copyright (c) 1998 by Jaroslav Kysela <perex@jcu.cz>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
1998-08-30 21:08:44 +00:00
|
|
|
#include "asoundlib.h"
|
1998-08-27 20:47:51 +00:00
|
|
|
|
1998-08-28 14:04:48 +00:00
|
|
|
#define SND_FILE_RAWMIDI "/dev/snd/midi%i%i"
|
1998-12-27 01:01:47 +00:00
|
|
|
#define SND_RAWMIDI_VERSION_MAX SND_PROTOCOL_VERSION( 1, 0, 0 )
|
1998-11-27 14:57:39 +00:00
|
|
|
|
1998-08-27 20:47:51 +00:00
|
|
|
typedef struct {
|
1998-11-27 14:57:39 +00:00
|
|
|
int card;
|
|
|
|
|
int device;
|
|
|
|
|
int fd;
|
1998-08-27 20:47:51 +00:00
|
|
|
} snd_rawmidi_t;
|
1998-11-27 14:57:39 +00:00
|
|
|
|
|
|
|
|
int snd_rawmidi_open(void **handle, int card, int device, int mode)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
int fd, ver;
|
|
|
|
|
char filename[32];
|
|
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
*handle = NULL;
|
|
|
|
|
if (card < 0 || card >= SND_CARDS)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
sprintf(filename, SND_FILE_RAWMIDI, card, device);
|
|
|
|
|
if ((fd = open(filename, mode)) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
if (ioctl(fd, SND_RAWMIDI_IOCTL_PVERSION, &ver) < 0) {
|
|
|
|
|
close(fd);
|
|
|
|
|
return -errno;
|
|
|
|
|
}
|
1998-12-27 01:01:47 +00:00
|
|
|
if (SND_PROTOCOL_UNCOMPATIBLE(ver, SND_RAWMIDI_VERSION_MAX)) {
|
1998-11-27 14:57:39 +00:00
|
|
|
close(fd);
|
|
|
|
|
return -SND_ERROR_UNCOMPATIBLE_VERSION;
|
|
|
|
|
}
|
|
|
|
|
rmidi = (snd_rawmidi_t *) calloc(1, sizeof(snd_rawmidi_t));
|
|
|
|
|
if (rmidi == NULL) {
|
|
|
|
|
close(fd);
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
rmidi->card = card;
|
|
|
|
|
rmidi->device = device;
|
|
|
|
|
rmidi->fd = fd;
|
|
|
|
|
*handle = rmidi;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_close(void *handle)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
res = close(rmidi->fd) < 0 ? -errno : 0;
|
|
|
|
|
free(rmidi);
|
|
|
|
|
return res;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_file_descriptor(void *handle)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
return rmidi->fd;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_block_mode(void *handle, int enable)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
long flags;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
1999-01-06 15:25:15 +00:00
|
|
|
if ((flags = fcntl(rmidi->fd, F_GETFL)) < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -errno;
|
|
|
|
|
if (enable)
|
|
|
|
|
flags &= ~O_NONBLOCK;
|
1999-01-13 14:51:21 +00:00
|
|
|
else
|
|
|
|
|
flags |= O_NONBLOCK;
|
1999-01-06 15:25:15 +00:00
|
|
|
if (fcntl(rmidi->fd, F_SETFL, flags) < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !info)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INFO, info) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_output_switches(void *handle)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCHES, &result) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return result;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_output_switch(void *handle, const char *switch_id)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
snd_rawmidi_switch_t uswitch;
|
|
|
|
|
int idx, switches, err;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !switch_id)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
/* bellow implementation isn't optimized for speed */
|
|
|
|
|
/* info about switches should be cached in the snd_mixer_t structure */
|
|
|
|
|
if ((switches = snd_rawmidi_output_switches(handle)) < 0)
|
|
|
|
|
return switches;
|
|
|
|
|
for (idx = 0; idx < switches; idx++) {
|
|
|
|
|
if ((err = snd_rawmidi_output_switch_read(handle, idx, &uswitch)) < 0)
|
|
|
|
|
return err;
|
|
|
|
|
if (!strncmp(switch_id, uswitch.name, sizeof(uswitch.name)))
|
|
|
|
|
return idx;
|
|
|
|
|
}
|
|
|
|
|
return -EINVAL;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_output_switch_read(void *handle, int switchn, snd_rawmidi_switch_t * data)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !data || switchn < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
1998-12-27 01:01:47 +00:00
|
|
|
bzero(data, sizeof(snd_rawmidi_switch_t));
|
1998-11-27 14:57:39 +00:00
|
|
|
data->switchn = switchn;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_READ, data) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
1998-11-27 14:57:39 +00:00
|
|
|
|
|
|
|
|
int snd_rawmidi_output_switch_write(void *handle, int switchn, snd_rawmidi_switch_t * data)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
1998-08-27 20:47:51 +00:00
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !data || switchn < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
data->switchn = switchn;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_WRITE, data) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1998-08-28 14:04:48 +00:00
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_input_switches(void *handle)
|
1998-08-28 14:04:48 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCHES, &result) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return result;
|
1998-08-28 14:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_input_switch(void *handle, const char *switch_id)
|
1998-08-28 14:04:48 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
snd_rawmidi_switch_t uswitch;
|
|
|
|
|
int idx, switches, err;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !switch_id)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
/* bellow implementation isn't optimized for speed */
|
|
|
|
|
/* info about switches should be cached in the snd_mixer_t structure */
|
|
|
|
|
if ((switches = snd_rawmidi_input_switches(handle)) < 0)
|
|
|
|
|
return switches;
|
|
|
|
|
for (idx = 0; idx < switches; idx++) {
|
|
|
|
|
if ((err = snd_rawmidi_input_switch_read(handle, idx, &uswitch)) < 0)
|
|
|
|
|
return err;
|
|
|
|
|
if (!strncmp(switch_id, uswitch.name, sizeof(uswitch.name)))
|
|
|
|
|
return idx;
|
|
|
|
|
}
|
|
|
|
|
return -EINVAL;
|
1998-08-28 14:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_input_switch_read(void *handle, int switchn, snd_rawmidi_switch_t * data)
|
1998-08-28 14:04:48 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !data || switchn < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
1998-12-27 01:01:47 +00:00
|
|
|
bzero(data, sizeof(snd_rawmidi_switch_t));
|
1998-11-27 14:57:39 +00:00
|
|
|
data->switchn = switchn;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_READ, data) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-28 14:04:48 +00:00
|
|
|
}
|
1998-11-27 14:57:39 +00:00
|
|
|
|
|
|
|
|
int snd_rawmidi_input_switch_write(void *handle, int switchn, snd_rawmidi_switch_t * data)
|
1998-08-28 14:04:48 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
1998-08-28 14:04:48 +00:00
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !data || switchn < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
data->switchn = switchn;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_WRITE, data) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1998-08-27 20:47:51 +00:00
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !params)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_PARAMS, params) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_input_params(void *handle, snd_rawmidi_input_params_t * params)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !params)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_PARAMS, params) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_output_status(void *handle, snd_rawmidi_output_status_t * status)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !status)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_STATUS, status) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_input_status(void *handle, snd_rawmidi_input_status_t * status)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || !status)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_STATUS, status) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_drain_output(void *handle)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_DRAIN_OUTPUT) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_flush_output(void *handle)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_OUTPUT) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
int snd_rawmidi_flush_input(void *handle)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
|
|
|
|
if (!rmidi)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_INPUT) < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return 0;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
ssize_t snd_rawmidi_write(void *handle, const void *buffer, size_t size)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
ssize_t result;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || (!buffer && size > 0) || size < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
result = write(rmidi->fd, buffer, size);
|
|
|
|
|
if (result < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return result;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-27 14:57:39 +00:00
|
|
|
ssize_t snd_rawmidi_read(void *handle, void *buffer, size_t size)
|
1998-08-27 20:47:51 +00:00
|
|
|
{
|
1998-11-27 14:57:39 +00:00
|
|
|
snd_rawmidi_t *rmidi;
|
|
|
|
|
ssize_t result;
|
|
|
|
|
|
|
|
|
|
rmidi = (snd_rawmidi_t *) handle;
|
1998-12-27 01:01:47 +00:00
|
|
|
if (!rmidi || (!buffer && size > 0) || size < 0)
|
1998-11-27 14:57:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
result = read(rmidi->fd, buffer, size);
|
|
|
|
|
if (result < 0)
|
|
|
|
|
return -errno;
|
|
|
|
|
return result;
|
1998-08-27 20:47:51 +00:00
|
|
|
}
|