Merged rawmidi M4 files into the main ones.

The first attempt to create documentation for the RawMidi API.
This commit is contained in:
Jaroslav Kysela 2001-03-20 16:46:45 +00:00
parent 76c38e3687
commit e8a01ea4ed
10 changed files with 744 additions and 475 deletions

View File

@ -2,12 +2,32 @@ PROJECT_NAME = "ALSA project - the C library reference"
OUTPUT_DIRECTORY = doxygen
GENERATE_LATEX = NO
GENERATE_MAN = NO
GENERATE_RTF = NO
CASE_SENSE_NAMES = NO
INPUT = ../../alsa-driver/include/asound.h ../include/asoundlib.h ../src
EXCLUDE = ../src/control/control_local.h \
../src/pcm/atomic.h \
../src/pcm/interval.h \
../src/pcm/interval_inline.h \
../src/pcm/mask.h \
../src/pcm/mask_inline.h \
../src/pcm/pcm_local.h \
../src/pcm/pcm_meter.h \
../src/pcm/pcm_plugin.h \
../src/pcm/plugin_ops.h \
../src/mixer/mixer_local.h \
../src/rawmidi/rawmidi_local.h \
../src/seq/seq_local.h
RECURSIVE = YES
FILE_PATTERNS = *.c *.h
#EXAMPLE_PATH = example_test.cpp
QUIET = NO
QUIET = YES
EXTRACT_ALL = YES
EXTRACT_STATIC = YES
RECURSIVE = YES
PREDEFINED = DOC_PUBLIC
EXTRACT_ALL = NO
EXTRACT_STATIC = NO
JAVADOC_AUTOBRIEF = NO
INHERIT_DOCS = YES
ENABLED_SECTIONS = "static"
OPTIMIZE_OUTPUT_FOR_C = YES # doxygen 1.2.6 option

View File

@ -4,7 +4,7 @@ sysinclude_HEADERS = asoundlib.h
# This is the order they will be concatenated into asoundlib.h!
#
header_files=header.h version.h global.h input.h output.h error.h \
pcm.h pcm_m4.h rawmidi.h rawmidi_m4.h timer.h \
pcm.h pcm_m4.h rawmidi.h timer.h \
hwdep.h hwdep_m4.h control.h control_m4.h \
mixer.h mixer_m4.h \
seq.h seqmid.h seq_midi_event.h \

View File

@ -1,7 +1,11 @@
/*
* Application interface library for the ALSA driver
* Copyright (c) by Jaroslav Kysela <perex@suse.cz>
* Abramo Bagnara <abramo@alsa-project.org>
/**
* \file asoundlib.h
* \author Jaroslav Kysela <perex@suse.cz>
* \author Abramo Bagnara <abramo@alsa-project.org>
* \author Takashi Iwai <tiwai@suse.de>
* \date 1998-2001
*
* Application interface library for the ALSA driver
*
*
* This library is free software; you can redistribute it and/or modify

View File

@ -50,8 +50,46 @@ int snd_rawmidi_close(snd_rawmidi_t *rmidi);
int snd_rawmidi_poll_descriptors_count(snd_rawmidi_t *rmidi);
int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rmidi, struct pollfd *pfds, unsigned int space);
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock);
size_t snd_rawmidi_info_sizeof();
#define snd_rawmidi_info_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_info_t *) alloca(snd_rawmidi_info_sizeof()); memset(*ptr, 0, snd_rawmidi_info_sizeof()); } while (0)
int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr);
void snd_rawmidi_info_free(snd_rawmidi_info_t *obj);
void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src);
unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *obj);
snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *obj);
int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj);
const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj);
const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj);
const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *obj);
void snd_rawmidi_info_set_device(snd_rawmidi_info_t *obj, unsigned int val);
void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val);
void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val);
int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info);
size_t snd_rawmidi_params_sizeof();
#define snd_rawmidi_params_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_params_t *) alloca(snd_rawmidi_params_sizeof()); memset(*ptr, 0, snd_rawmidi_params_sizeof()); } while (0)
int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr);
void snd_rawmidi_params_free(snd_rawmidi_params_t *obj);
void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src);
int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val);
size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params);
int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val);
size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params);
int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, int val);
int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params);
int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params);
int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params);
size_t snd_rawmidi_status_sizeof();
#define snd_rawmidi_status_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_status_t *) alloca(snd_rawmidi_status_sizeof()); memset(*ptr, 0, snd_rawmidi_status_sizeof()); } while (0)
int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr);
void snd_rawmidi_status_free(snd_rawmidi_status_t *obj);
void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src);
void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *obj, snd_timestamp_t *ptr);
size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *obj);
size_t snd_rawmidi_status_get_avail_max(const snd_rawmidi_status_t *obj);
int snd_rawmidi_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status);
int snd_rawmidi_drain(snd_rawmidi_t *rmidi);
int snd_rawmidi_drop(snd_rawmidi_t *rmidi);
@ -60,8 +98,6 @@ ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size);
const char *snd_rawmidi_name(snd_rawmidi_t *rmidi);
snd_rawmidi_type_t snd_rawmidi_type(snd_rawmidi_t *rmidi);
int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params);
#ifdef __cplusplus
}
#endif

View File

@ -1,67 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
size_t snd_rawmidi_params_sizeof();
#define snd_rawmidi_params_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_params_t *) alloca(snd_rawmidi_params_sizeof()); memset(*ptr, 0, snd_rawmidi_params_sizeof()); } while (0)
int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr);
void snd_rawmidi_params_free(snd_rawmidi_params_t *obj);
void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src);
int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val);
size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params);
int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val);
size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params);
int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, int val);
int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params);
size_t snd_rawmidi_info_sizeof();
#define snd_rawmidi_info_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_info_t *) alloca(snd_rawmidi_info_sizeof()); memset(*ptr, 0, snd_rawmidi_info_sizeof()); } while (0)
int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr);
void snd_rawmidi_info_free(snd_rawmidi_info_t *obj);
void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src);
unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *obj);
snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *obj);
int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj);
const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj);
const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj);
const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj);
unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *obj);
void snd_rawmidi_info_set_device(snd_rawmidi_info_t *obj, unsigned int val);
void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val);
void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val);
size_t snd_rawmidi_status_sizeof();
#define snd_rawmidi_status_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_status_t *) alloca(snd_rawmidi_status_sizeof()); memset(*ptr, 0, snd_rawmidi_status_sizeof()); } while (0)
int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr);
void snd_rawmidi_status_free(snd_rawmidi_status_t *obj);
void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src);
void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *obj, snd_timestamp_t *ptr);
size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *obj);
size_t snd_rawmidi_status_get_avail_max(const snd_rawmidi_status_t *obj);
#ifdef __cplusplus
}
#endif

View File

@ -1,4 +1,4 @@
/*!
/**
* \file error.c
* Error code handling routines.
*/
@ -30,13 +30,17 @@
#include <string.h>
#include "local.h"
/**
* \if static
* Array of error codes in US ASCII.
* \endif
*/
static const char *snd_error_codes[] =
{
"Sound protocol is not compatible"
};
/*!
* \fn const char * snd_strerror(int errnum)
/**
* \brief Get the error string.
* \param errnum The error code number.
*
@ -54,9 +58,8 @@ const char *snd_strerror(int errnum)
return snd_error_codes[errnum];
}
#ifndef DOC_PUBLIC
/*!
* \fn static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...)
/**
* \if static
* \brief The default error handler function.
* \param file The filename where the error was hit.
* \param line The line number.
@ -66,6 +69,7 @@ const char *snd_strerror(int errnum)
* \param ... Optional arguments.
*
* Prints the error message including location to stderr.
* \endif
*/
static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...)
{
@ -78,18 +82,13 @@ static void snd_lib_error_default(const char *file, int line, const char *functi
putc('\n', stderr);
va_end(arg);
}
#endif /* !DOC_PUBLIC */
#ifndef DOC_PUBLIC
/*!
* \var snd_lib_error_handler_t *snd_lib_error;
/**
* Pointer to the error handler function.
*/
snd_lib_error_handler_t *snd_lib_error = snd_lib_error_default;
#endif /* !DOC_PUBLIC */
/*!
* \fn int snd_lib_error_set_handler(snd_lib_error_handler_t *handler)
/**
* \brief Set the error handler.
* \param handler The pointer to the new error handler function.
*

View File

@ -1,6 +1,6 @@
EXTRA_LTLIBRARIES=librawmidi.la
librawmidi_la_SOURCES = rawmidi.c rawmidi_m4.c rawmidi_hw.c
librawmidi_la_SOURCES = rawmidi.c rawmidi_hw.c
noinst_HEADERS = rawmidi_local.h
all: librawmidi.la

View File

@ -1,7 +1,24 @@
/**
* \file rawmidi/rawmidi.c
* \author Jaroslav Kysela <perex@suse.cz>
* \author Abramo Bagnara <abramo@alsa-project.org>
* \date 2000-2001
*
* RawMidi Interface is designed to write or read raw (unchanged) MIDI
* data over the MIDI line. MIDI stands Musical Instrument Digital Interface
* and more information about this standard can be found at
* http://www.midi.org.
*
* RawMidi devices are opened exclusively for a selected direction.
* While more than one process may not open a given MIDI device in the same
* direction simultaneously, seperate processes may open a single MIDI device
* in different directions (i.e. process one opens a MIDI device in write
* direction and process two opens the same device in read direction). MIDI
* devices return EBUSY error to applications when other applications have
* already opened the requested direction (nonblock behaviour) or wait
* until the device is not available (block behaviour).
*/
/*
* RawMIDI Interface - main file
* Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
* Abramo Bagnara <abramo@alsa-project.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@ -27,144 +44,17 @@
#include <dlfcn.h>
#include "rawmidi_local.h"
const char *snd_rawmidi_name(snd_rawmidi_t *rawmidi)
{
assert(rawmidi);
return rawmidi->name;
}
snd_rawmidi_type_t snd_rawmidi_type(snd_rawmidi_t *rawmidi)
{
assert(rawmidi);
return rawmidi->type;
}
int snd_rawmidi_close(snd_rawmidi_t *rmidi)
{
int err;
assert(rmidi);
if ((err = rmidi->ops->close(rmidi)) < 0)
return err;
if (rmidi->name)
free(rmidi->name);
free(rmidi);
return 0;
}
int _snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return rmidi->poll_fd;
}
int snd_rawmidi_poll_descriptors_count(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return 1;
}
int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rmidi, struct pollfd *pfds, unsigned int space)
{
assert(rmidi);
if (space >= 1) {
pfds->fd = rmidi->poll_fd;
pfds->events = rmidi->stream == SND_RAWMIDI_STREAM_OUTPUT ? POLLOUT : POLLIN;
return 1;
}
return 0;
}
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock)
{
int err;
assert(rmidi);
assert(!(rmidi->mode & SND_RAWMIDI_APPEND));
if ((err = rmidi->ops->nonblock(rmidi, nonblock)) < 0)
return err;
if (nonblock)
rmidi->mode |= SND_RAWMIDI_NONBLOCK;
else
rmidi->mode &= ~SND_RAWMIDI_NONBLOCK;
return 0;
}
int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info)
{
assert(rmidi);
assert(info);
return rmidi->ops->info(rmidi, info);
}
int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params)
{
int err;
assert(rmidi);
assert(params);
err = rmidi->ops->params(rmidi, params);
if (err < 0)
return err;
rmidi->buffer_size = params->buffer_size;
rmidi->avail_min = params->avail_min;
rmidi->no_active_sensing = params->no_active_sensing;
return 0;
}
int snd_rawmidi_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status)
{
assert(rmidi);
assert(status);
return rmidi->ops->status(rmidi, status);
}
int snd_rawmidi_drop(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return rmidi->ops->drop(rmidi);
}
int snd_rawmidi_drain(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return rmidi->ops->drain(rmidi);
}
ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size)
{
assert(rmidi);
assert(rmidi->stream == SND_RAWMIDI_STREAM_OUTPUT);
assert(buffer || size == 0);
return rmidi->ops->write(rmidi, buffer, size);
}
ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size)
{
assert(rmidi);
assert(rmidi->stream == SND_RAWMIDI_STREAM_INPUT);
assert(buffer || size == 0);
return rmidi->ops->read(rmidi, buffer, size);
}
int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params)
{
assert(rmidi);
assert(params);
params->buffer_size = rmidi->buffer_size;
params->avail_min = rmidi->avail_min;
params->no_active_sensing = rmidi->no_active_sensing;
return 0;
}
int snd_rawmidi_params_default(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params)
{
assert(rmidi);
assert(params);
params->buffer_size = page_size();
params->avail_min = 1;
params->no_active_sensing = 0;
return 0;
}
/**
* \brief Opens a new connection to the RawMidi interface.
* \param inputp Returned input handle
* \param outputp Returned output handle
* \param name ASCII identifier of the RawMidi stream
* \param mode Open mode
* \return a negative error code on failure or zero on success
*
* Opens a new connection to the RawMidi interface specified with
* an ASCII identifier and mode.
*/
int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
const char *name, int mode)
{
@ -270,3 +160,631 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
return 0;
}
/**
* \brief close rawmidi handle
* \param rmidi rawmidi handle
* \return zero if success otherwise a negative error code
*
* Closes the specified rawmidi handle and frees all associated
* resources.
*/
int snd_rawmidi_close(snd_rawmidi_t *rmidi)
{
int err;
assert(rmidi);
if ((err = rmidi->ops->close(rmidi)) < 0)
return err;
if (rmidi->name)
free(rmidi->name);
free(rmidi);
return 0;
}
/**
* \brief get identifier of rawmidi handle
* \param rawmidi a rawmidi handle
* \return ascii identifier of rawmidi handle
*
* Returns the ASCII identifier of given rawmidi handle. It's the same
* identifier as for snd_rawmidi_open().
*/
const char *snd_rawmidi_name(snd_rawmidi_t *rawmidi)
{
assert(rawmidi);
return rawmidi->name;
}
/**
* \brief get type of rawmidi handle
* \param rawmidi a rawmidi handle
* \return type of rawmidi handle
*
* Returns the type #snd_rawmidi_type_t of given rawmidi handle.
*/
snd_rawmidi_type_t snd_rawmidi_type(snd_rawmidi_t *rawmidi)
{
assert(rawmidi);
return rawmidi->type;
}
/**
* \brief get count of poll descriptors for rawmidi handle
* \param rmidi rawmidi handle
* \return count of poll descriptors
*/
int snd_rawmidi_poll_descriptors_count(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return 1;
}
/**
* \brief get poll descriptors
* \param rmidi rawmidi handle
* \param pfds array of poll descriptors
* \param space space in the poll descriptor array
* \return count of filled descriptors
*/
int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rmidi, struct pollfd *pfds, unsigned int space)
{
assert(rmidi);
if (space >= 1) {
pfds->fd = rmidi->poll_fd;
pfds->events = rmidi->stream == SND_RAWMIDI_STREAM_OUTPUT ? POLLOUT : POLLIN;
return 1;
}
return 0;
}
/**
* \brief set nonblock mode
* \param rmidi rawmidi handle
* \param nonblock 0 = block, 1 = nonblock mode
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock)
{
int err;
assert(rmidi);
assert(!(rmidi->mode & SND_RAWMIDI_APPEND));
if ((err = rmidi->ops->nonblock(rmidi, nonblock)) < 0)
return err;
if (nonblock)
rmidi->mode |= SND_RAWMIDI_NONBLOCK;
else
rmidi->mode &= ~SND_RAWMIDI_NONBLOCK;
return 0;
}
/**
* \brief get size of the snd_rawmidi_info_t structure in bytes
* \return size of the snd_rawmidi_info_t structure in bytes
*/
size_t snd_rawmidi_info_sizeof()
{
return sizeof(snd_rawmidi_info_t);
}
/**
* \brief allocate a new snd_rawmidi_info_t structure
* \param ptr returned pointer
* \return zero if success or a negative error code if fails
*
* Allocates a new snd_rawmidi_params_t structure using the standard
* malloc C library function.
*/
int snd_rawmidi_info_malloc(snd_rawmidi_info_t **info)
{
assert(info);
*info = calloc(1, sizeof(snd_rawmidi_info_t));
if (!*info)
return -ENOMEM;
return 0;
}
/**
* \brief frees the snd_rawmidi_info_t structure
* \param params pointer to the snd_rawmidi_info_t structure to free
*
* Frees the given snd_rawmidi_params_t structure using the standard
* free C library function.
*/
void snd_rawmidi_info_free(snd_rawmidi_info_t *info)
{
assert(info);
free(info);
}
/**
* \brief copy one snd_rawmidi_info_t structure to another
* \param dst destination snd_rawmidi_info_t structure
* \param src source snd_rawmidi_info_t structure
*/
void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src)
{
assert(dst && src);
*dst = *src;
}
/**
* \brief get rawmidi device number
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi device number
*/
unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *info)
{
assert(info);
return info->device;
}
/**
* \brief get rawmidi subdevice number
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi subdevice number
*/
unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *info)
{
assert(info);
return info->subdevice;
}
/**
* \brief get rawmidi stream identification
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi stream identification
*/
snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *info)
{
assert(info);
return snd_int_to_enum(info->stream);
}
/**
* \brief get rawmidi card number
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi card number
*/
int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *info)
{
assert(info);
return info->card;
}
/**
* \brief get rawmidi flags
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi flags
*/
unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *info)
{
assert(info);
return info->flags;
}
/**
* \brief get rawmidi hardware driver identifier
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi hardware driver identifier
*/
const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *info)
{
assert(info);
return info->id;
}
/**
* \brief get rawmidi hardware driver name
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi hardware driver name
*/
const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *info)
{
assert(info);
return info->name;
}
/**
* \brief get rawmidi subdevice name
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi subdevice name
*/
const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *info)
{
assert(info);
return info->subname;
}
/**
* \brief get rawmidi count of subdevices
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi count of subdevices
*/
unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *info)
{
assert(info);
return info->subdevices_count;
}
/**
* \brief get rawmidi available count of subdevices
* \param info pointer to a snd_rawmidi_info_t structure
* \return rawmidi available count of subdevices
*/
unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *info)
{
assert(info);
return info->subdevices_avail;
}
/**
* \brief set rawmidi device number
* \param info pointer to a snd_rawmidi_info_t structure
* \param val device number
*/
void snd_rawmidi_info_set_device(snd_rawmidi_info_t *info, unsigned int val)
{
assert(info);
info->device = val;
}
/**
* \brief set rawmidi subdevice number
* \param info pointer to a snd_rawmidi_info_t structure
* \param val subdevice number
*/
void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *info, unsigned int val)
{
assert(info);
info->subdevice = val;
}
/**
* \brief set rawmidi stream identifier
* \param info pointer to a snd_rawmidi_info_t structure
* \param val rawmidi stream identifier
*/
void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *info, snd_rawmidi_stream_t val)
{
assert(info);
info->stream = snd_enum_to_int(val);
}
/**
* \brief get information about rawmidi handle
* \param rmidi rawmidi handle
* \param info pointer to a snd_rawmidi_info_t structure to be filled
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info)
{
assert(rmidi);
assert(info);
return rmidi->ops->info(rmidi, info);
}
/**
* \brief get size of the snd_rawmidi_params_t structure in bytes
* \return size of the snd_rawmidi_params_t structure in bytes
*/
size_t snd_rawmidi_params_sizeof()
{
return sizeof(snd_rawmidi_params_t);
}
/**
* \brief allocate the snd_rawmidi_params_t structure
* \param ptr returned pointer
* \return zero if success or a negative error code if fails
*
* Allocates a new snd_rawmidi_params_t structure using the standard
* malloc C library function.
*/
int snd_rawmidi_params_malloc(snd_rawmidi_params_t **params)
{
assert(params);
*params = calloc(1, sizeof(snd_rawmidi_params_t));
if (!*params)
return -ENOMEM;
return 0;
}
/**
* \brief frees the snd_rawmidi_params_t structure
* \param params pointer to the #snd_rawmidi_params_t structure to free
*
* Frees the given snd_rawmidi_params_t structure using the standard
* free C library function.
*/
void snd_rawmidi_params_free(snd_rawmidi_params_t *params)
{
assert(params);
free(params);
}
/**
* \brief copy one snd_rawmidi_params_t structure to another
* \param dst destination snd_rawmidi_params_t structure
* \param src source snd_rawmidi_params_t structure
*/
void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src)
{
assert(dst && src);
*dst = *src;
}
/**
* \brief setup the default parameters
* \param rmidi rawmidi handle
* \param params pointer to a snd_rawmidi_params_t structure
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_params_default(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params)
{
assert(rmidi);
assert(params);
params->buffer_size = page_size();
params->avail_min = 1;
params->no_active_sensing = 0;
return 0;
}
/**
* \brief set rawmidi I/O ring buffer size
* \param rmidi rawmidi handle
* \param params pointer to a snd_rawmidi_params_t structure
* \param val size in bytes
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val)
{
assert(rmidi && params);
assert(val > params->avail_min);
params->buffer_size = val;
return 0;
}
/**
* \brief get rawmidi I/O ring buffer size
* \param params pointer to a snd_rawmidi_params_t structure
* \return size of rawmidi I/O ring buffer in bytes
*/
size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params)
{
assert(params);
return params->buffer_size;
}
/**
* \brief set minimum available bytes in rawmidi I/O ring buffer for wakeup
* \param rmidi rawmidi handle
* \param params pointer to a snd_rawmidi_params_t structure
* \param val desired value
*/
int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val)
{
assert(rmidi && params);
assert(val < params->buffer_size);
params->avail_min = val;
return 0;
}
/**
* \brief get minimum available bytes in rawmidi I/O ring buffer for wakeup
* \param params pointer to snd_rawmidi_params_t structure
* \return minimum available bytes
*/
size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params)
{
assert(params);
return params->avail_min;
}
/**
* \brief set no-active-sensing action on snd_rawmidi_close()
* \param rmidi rawmidi handle
* \param params pointer to snd_rawmidi_params_t structure
* \param val value: 0 = enable to send the active sensing message, 1 = disable
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, int val)
{
assert(rmidi && params);
params->no_active_sensing = val;
return 0;
}
/**
* \brief get no-active-sensing action status
* \param params pointer to snd_rawmidi_params_t structure
* \return the current status (0 = enable, 1 = disable the active sensing message)
*/
int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params)
{
assert(params);
return params->no_active_sensing;
}
/**
* \brief get parameters about rawmidi stream
* \param rmidi rawmidi handle
* \param params pointer to a snd_rawmidi_params_t structure to be filled
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params)
{
int err;
assert(rmidi);
assert(params);
err = rmidi->ops->params(rmidi, params);
if (err < 0)
return err;
rmidi->buffer_size = params->buffer_size;
rmidi->avail_min = params->avail_min;
rmidi->no_active_sensing = params->no_active_sensing;
return 0;
}
/**
* \brief get current parameters about rawmidi stream
* \param rmidi rawmidi handle
* \param params pointer to a snd_rawmidi_params_t structure to be filled
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params)
{
assert(rmidi);
assert(params);
params->buffer_size = rmidi->buffer_size;
params->avail_min = rmidi->avail_min;
params->no_active_sensing = rmidi->no_active_sensing;
return 0;
}
/**
* \brief get size of the snd_rawmidi_status_t structure in bytes
* \return size of the snd_rawmidi_status_t structure in bytes
*/
size_t snd_rawmidi_status_sizeof()
{
return sizeof(snd_rawmidi_status_t);
}
/**
* \brief allocate the snd_rawmidi_status_t structure
* \param ptr returned pointer
* \return zero if success or a negative error code if fails
*
* Allocates a new snd_rawmidi_status_t structure using the standard
* malloc C library function.
*/
int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr)
{
assert(ptr);
*ptr = calloc(1, sizeof(snd_rawmidi_status_t));
if (!*ptr)
return -ENOMEM;
return 0;
}
/**
* \brief frees the snd_rawmidi_status_t structure
* \param status pointer to the snd_rawmidi_status_t structure to free
*
* Frees the given snd_rawmidi_status_t structure using the standard
* free C library function.
*/
void snd_rawmidi_status_free(snd_rawmidi_status_t *status)
{
assert(status);
free(status);
}
/**
* \brief copy one snd_rawmidi_status_t structure to another
* \param dst destination snd_rawmidi_status_t structure
* \param src source snd_rawmidi_status_t structure
*/
void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src)
{
assert(dst && src);
*dst = *src;
}
/**
* \brief get the start timestamp
* \param status pointer to a snd_rawmidi_status_t structure
* \param tstamp returned timestamp value
*/
void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *status, snd_timestamp_t *tstamp)
{
assert(status && tstamp);
*tstamp = status->tstamp;
}
/**
* \brief get current available bytes in the rawmidi I/O ring buffer
* \param status pointer to a snd_rawmidi_status_t structure
* \return current available bytes in the rawmidi I/O ring buffer
*/
size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *status)
{
assert(status);
return status->avail;
}
/**
* \brief get count of xruns
* \param status pointer to a snd_rawmidi_status_t structure
* \return count of xruns
*/
size_t snd_rawmidi_status_get_xruns(const snd_rawmidi_status_t *status)
{
assert(status);
return status->xruns;
}
/**
* \brief get status of rawmidi stream
* \param rmidi rawmidi handle
* \param status pointer to a snd_rawmidi_status_t structure to be filled
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status)
{
assert(rmidi);
assert(status);
return rmidi->ops->status(rmidi, status);
}
/**
* \brief drop all bytes in the rawmidi I/O ring buffer immediately
* \param rmidi rawmidi handle
* \return zero if success otherwise a negative error code
*/
int snd_rawmidi_drop(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return rmidi->ops->drop(rmidi);
}
/**
* \brief drain all bytes in the rawmidi I/O ring buffer
* \param rmidi rawmidi handle
* \return zero if success otherwise a negative error code
*
* Waits until all MIDI bytes are not drained (sent) to the
* hardware device.
*/
int snd_rawmidi_drain(snd_rawmidi_t *rmidi)
{
assert(rmidi);
return rmidi->ops->drain(rmidi);
}
/**
* \brief write MIDI bytes to MIDI stream
* \param rmidi rawmidi handle
* \param buffer buffer containing MIDI bytes
* \param size output buffer size in bytes
*/
ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size)
{
assert(rmidi);
assert(rmidi->stream == SND_RAWMIDI_STREAM_OUTPUT);
assert(buffer || size == 0);
return rmidi->ops->write(rmidi, buffer, size);
}
/**
* \brief read MIDI bytes from MIDI stream
* \param rmidi rawmidi handle
* \param buffer buffer to store the input MIDI bytes
* \param size input buffer size in bytes
*/
ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size)
{
assert(rmidi);
assert(rmidi->stream == SND_RAWMIDI_STREAM_INPUT);
assert(buffer || size == 0);
return rmidi->ops->read(rmidi, buffer, size);
}

View File

@ -36,8 +36,6 @@ typedef struct {
ssize_t (*read)(snd_rawmidi_t *rawmidi, void *buffer, size_t size);
} snd_rawmidi_ops_t;
struct _snd_rawmidi {
char *name;
snd_rawmidi_type_t type;
@ -54,4 +52,3 @@ struct _snd_rawmidi {
int snd_rawmidi_hw_open(snd_rawmidi_t **input, snd_rawmidi_t **output,
const char *name, int card, int device, int subdevice,
int mode);

View File

@ -1,238 +0,0 @@
/*
* Rawmidi - Automatically generated functions
* Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
*
*
* 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 "rawmidi_local.h"
size_t snd_rawmidi_params_sizeof()
{
return sizeof(snd_rawmidi_params_t);
}
int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr)
{
assert(ptr);
*ptr = calloc(1, sizeof(snd_rawmidi_params_t));
if (!*ptr)
return -ENOMEM;
return 0;
}
void snd_rawmidi_params_free(snd_rawmidi_params_t *obj)
{
free(obj);
}
void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src)
{
assert(dst && src);
*dst = *src;
}
int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val)
{
assert(rmidi && params);
assert(val > params->avail_min);
params->buffer_size = val;
return 0;
}
size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params)
{
assert(params);
return params->buffer_size;
}
int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val)
{
assert(rmidi && params);
assert(val < params->buffer_size);
params->avail_min = val;
return 0;
}
size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params)
{
assert(params);
return params->avail_min;
}
int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, int val)
{
assert(rmidi && params);
params->no_active_sensing = val;
return 0;
}
int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params)
{
assert(params);
return params->no_active_sensing;
}
size_t snd_rawmidi_info_sizeof()
{
return sizeof(snd_rawmidi_info_t);
}
int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr)
{
assert(ptr);
*ptr = calloc(1, sizeof(snd_rawmidi_info_t));
if (!*ptr)
return -ENOMEM;
return 0;
}
void snd_rawmidi_info_free(snd_rawmidi_info_t *obj)
{
free(obj);
}
void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src)
{
assert(dst && src);
*dst = *src;
}
unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->device;
}
unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->subdevice;
}
snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *obj)
{
assert(obj);
return snd_int_to_enum(obj->stream);
}
int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->card;
}
unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->flags;
}
const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->id;
}
const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->name;
}
const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->subname;
}
unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->subdevices_count;
}
unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *obj)
{
assert(obj);
return obj->subdevices_avail;
}
void snd_rawmidi_info_set_device(snd_rawmidi_info_t *obj, unsigned int val)
{
assert(obj);
obj->device = val;
}
void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val)
{
assert(obj);
obj->subdevice = val;
}
void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val)
{
assert(obj);
obj->stream = snd_enum_to_int(val);
}
size_t snd_rawmidi_status_sizeof()
{
return sizeof(snd_rawmidi_status_t);
}
int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr)
{
assert(ptr);
*ptr = calloc(1, sizeof(snd_rawmidi_status_t));
if (!*ptr)
return -ENOMEM;
return 0;
}
void snd_rawmidi_status_free(snd_rawmidi_status_t *obj)
{
free(obj);
}
void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src)
{
assert(dst && src);
*dst = *src;
}
void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *obj, snd_timestamp_t *ptr)
{
assert(obj && ptr);
*ptr = obj->tstamp;
}
size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *obj)
{
assert(obj);
return obj->avail;
}
size_t snd_rawmidi_status_get_avail_max(const snd_rawmidi_status_t *obj)
{
assert(obj);
return obj->xruns;
}