mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-06 13:29:59 -05:00
Changed data type of alsa-lib handles from 'void *' to the specific type for
the handle in use. This should be more type-safe as the compiler will perform checking on type now.
This commit is contained in:
parent
9679707a00
commit
19811bb9b4
15 changed files with 417 additions and 404 deletions
|
|
@ -31,13 +31,13 @@
|
|||
#define SND_FILE_RAWMIDI "/dev/snd/midiC%iD%i"
|
||||
#define SND_RAWMIDI_VERSION_MAX SND_PROTOCOL_VERSION( 1, 0, 0 )
|
||||
|
||||
typedef struct {
|
||||
struct snd_rawmidi {
|
||||
int card;
|
||||
int device;
|
||||
int fd;
|
||||
} snd_rawmidi_t;
|
||||
};
|
||||
|
||||
int snd_rawmidi_open(void **handle, int card, int device, int mode)
|
||||
int snd_rawmidi_open(snd_rawmidi_t **handle, int card, int device, int mode)
|
||||
{
|
||||
int fd, ver;
|
||||
char filename[32];
|
||||
|
|
@ -73,12 +73,12 @@ int snd_rawmidi_open(void **handle, int card, int device, int mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_close(void *handle)
|
||||
int snd_rawmidi_close(snd_rawmidi_t *handle)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
int res;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi)
|
||||
return -EINVAL;
|
||||
res = close(rmidi->fd) < 0 ? -errno : 0;
|
||||
|
|
@ -86,22 +86,22 @@ int snd_rawmidi_close(void *handle)
|
|||
return res;
|
||||
}
|
||||
|
||||
int snd_rawmidi_file_descriptor(void *handle)
|
||||
int snd_rawmidi_file_descriptor(snd_rawmidi_t *handle)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi)
|
||||
return -EINVAL;
|
||||
return rmidi->fd;
|
||||
}
|
||||
|
||||
int snd_rawmidi_block_mode(void *handle, int enable)
|
||||
int snd_rawmidi_block_mode(snd_rawmidi_t *handle, int enable)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
long flags;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi)
|
||||
return -EINVAL;
|
||||
if ((flags = fcntl(rmidi->fd, F_GETFL)) < 0)
|
||||
|
|
@ -115,11 +115,11 @@ int snd_rawmidi_block_mode(void *handle, int enable)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info)
|
||||
int snd_rawmidi_info(snd_rawmidi_t *handle, snd_rawmidi_info_t * info)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || !info)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INFO, info) < 0)
|
||||
|
|
@ -127,11 +127,11 @@ int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params)
|
||||
int snd_rawmidi_output_params(snd_rawmidi_t *handle, snd_rawmidi_output_params_t * params)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || !params)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_PARAMS, params) < 0)
|
||||
|
|
@ -139,11 +139,11 @@ int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_input_params(void *handle, snd_rawmidi_input_params_t * params)
|
||||
int snd_rawmidi_input_params(snd_rawmidi_t *handle, snd_rawmidi_input_params_t * params)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || !params)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_PARAMS, params) < 0)
|
||||
|
|
@ -151,11 +151,11 @@ int snd_rawmidi_input_params(void *handle, snd_rawmidi_input_params_t * params)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_output_status(void *handle, snd_rawmidi_output_status_t * status)
|
||||
int snd_rawmidi_output_status(snd_rawmidi_t *handle, snd_rawmidi_output_status_t * status)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || !status)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_STATUS, status) < 0)
|
||||
|
|
@ -163,11 +163,11 @@ int snd_rawmidi_output_status(void *handle, snd_rawmidi_output_status_t * status
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_input_status(void *handle, snd_rawmidi_input_status_t * status)
|
||||
int snd_rawmidi_input_status(snd_rawmidi_t *handle, snd_rawmidi_input_status_t * status)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || !status)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_STATUS, status) < 0)
|
||||
|
|
@ -175,11 +175,11 @@ int snd_rawmidi_input_status(void *handle, snd_rawmidi_input_status_t * status)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_drain_output(void *handle)
|
||||
int snd_rawmidi_drain_output(snd_rawmidi_t *handle)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_DRAIN_OUTPUT) < 0)
|
||||
|
|
@ -187,11 +187,11 @@ int snd_rawmidi_drain_output(void *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_flush_output(void *handle)
|
||||
int snd_rawmidi_flush_output(snd_rawmidi_t *handle)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_OUTPUT) < 0)
|
||||
|
|
@ -199,11 +199,11 @@ int snd_rawmidi_flush_output(void *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_rawmidi_flush_input(void *handle)
|
||||
int snd_rawmidi_flush_input(snd_rawmidi_t *handle)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi)
|
||||
return -EINVAL;
|
||||
if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_INPUT) < 0)
|
||||
|
|
@ -211,12 +211,12 @@ int snd_rawmidi_flush_input(void *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ssize_t snd_rawmidi_write(void *handle, const void *buffer, size_t size)
|
||||
ssize_t snd_rawmidi_write(snd_rawmidi_t *handle, const void *buffer, size_t size)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
ssize_t result;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || (!buffer && size > 0) || size < 0)
|
||||
return -EINVAL;
|
||||
result = write(rmidi->fd, buffer, size);
|
||||
|
|
@ -225,12 +225,12 @@ ssize_t snd_rawmidi_write(void *handle, const void *buffer, size_t size)
|
|||
return result;
|
||||
}
|
||||
|
||||
ssize_t snd_rawmidi_read(void *handle, void *buffer, size_t size)
|
||||
ssize_t snd_rawmidi_read(snd_rawmidi_t *handle, void *buffer, size_t size)
|
||||
{
|
||||
snd_rawmidi_t *rmidi;
|
||||
ssize_t result;
|
||||
|
||||
rmidi = (snd_rawmidi_t *) handle;
|
||||
rmidi = handle;
|
||||
if (!rmidi || (!buffer && size > 0) || size < 0)
|
||||
return -EINVAL;
|
||||
result = read(rmidi->fd, buffer, size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue