mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Extended for switch interface for mixer/pcm/rawmidi...
This commit is contained in:
parent
67188280d0
commit
d9579f4b1c
2 changed files with 364 additions and 1 deletions
|
|
@ -24,8 +24,30 @@ int snd_ctl_switch_write( void *handle, int switchn, struct snd_ctl_switch *data
|
|||
int snd_ctl_pcm_info( void *handle, int dev, snd_pcm_info_t *info );
|
||||
int snd_ctl_pcm_playback_info( void *handle, int dev, snd_pcm_playback_info_t *info );
|
||||
int snd_ctl_pcm_record_info( void *handle, int dev, snd_pcm_record_info_t *info );
|
||||
int snd_ctl_pcm_playback_switches( void *handle, int dev );
|
||||
int snd_ctl_pcm_playback_switch( void *handle, int dev, const char *channel_id );
|
||||
int snd_ctl_pcm_playback_switch_read( void *handle, int dev, int switchn, snd_pcm_switch_t *data );
|
||||
int snd_ctl_pcm_playback_switch_write( void *handle, int dev, int switchn, snd_pcm_switch_t *data );
|
||||
int snd_ctl_pcm_record_switches( void *handle, int dev );
|
||||
int snd_ctl_pcm_record_switch( void *handle, int dev, const char *channel_id );
|
||||
int snd_ctl_pcm_record_switch_read( void *handle, int dev, int switchn, snd_pcm_switch_t *data );
|
||||
int snd_ctl_pcm_record_switch_write( void *handle, int dev, int switchn, snd_pcm_switch_t *data );
|
||||
int snd_ctl_mixer_info( void *handle, int dev, snd_mixer_info_t *info );
|
||||
int snd_ctl_mixer_switches( void *handle, int dev );
|
||||
int snd_ctl_mixer_switch( void *handle, int dev, const char *channel_id );
|
||||
int snd_ctl_mixer_switch_read( void *handle, int dev, int switchn, snd_mixer_switch_t *data );
|
||||
int snd_ctl_mixer_switch_write( void *handle, int dev, int switchn, snd_mixer_switch_t *data );
|
||||
int snd_ctl_rawmidi_info( void *handle, int dev, snd_rawmidi_info_t *info );
|
||||
int snd_ctl_rawmidi_output_info( void *handle, int dev, snd_rawmidi_output_info_t *info );
|
||||
int snd_ctl_rawmidi_input_info( void *handle, int dev, snd_rawmidi_input_info_t *info );
|
||||
int snd_ctl_rawmidi_output_switches( void *handle, int dev );
|
||||
int snd_ctl_rawmidi_output_switch( void *handle, int dev, const char *channel_id );
|
||||
int snd_ctl_rawmidi_output_switch_read( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data );
|
||||
int snd_ctl_rawmidi_output_switch_write( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data );
|
||||
int snd_ctl_rawmidi_input_switches( void *handle, int dev );
|
||||
int snd_ctl_rawmidi_input_switch( void *handle, int dev, const char *channel_id );
|
||||
int snd_ctl_rawmidi_input_switch_read( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data );
|
||||
int snd_ctl_rawmidi_input_switch_write( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ int snd_ctl_switch( void *handle, const char *switch_id )
|
|||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
/* bellow implementation isn't optimized for speed */
|
||||
/* info about switches should be cached in the snd_mixer_t structure */
|
||||
/* info about switches should be cached in the snd_ctl_t structure */
|
||||
if ( (switches = snd_ctl_switches( handle )) < 0 )
|
||||
return switches;
|
||||
for ( idx = 0; idx < switches; idx++ ) {
|
||||
|
|
@ -191,6 +191,132 @@ int snd_ctl_pcm_record_info( void *handle, int dev, snd_pcm_record_info_t *info
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_playback_switches( void *handle, int dev )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
int result;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_PSWITCHES, &result ) < 0 )
|
||||
return -errno;
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_playback_switch( void *handle, int dev, const char *switch_id )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
snd_pcm_switch_t uswitch;
|
||||
int idx, switches, err;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
/* bellow implementation isn't optimized for speed */
|
||||
/* info about switches should be cached in the snd_ctl_t structure */
|
||||
if ( (switches = snd_ctl_pcm_playback_switches( handle, dev )) < 0 )
|
||||
return switches;
|
||||
for ( idx = 0; idx < switches; idx++ ) {
|
||||
if ( (err = snd_ctl_pcm_playback_switch_read( handle, dev, idx, &uswitch )) < 0 )
|
||||
return err;
|
||||
if ( !strncmp( switch_id, uswitch.name, sizeof( uswitch.name ) ) )
|
||||
return idx;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_playback_switch_read( void *handle, int dev, int switchn, snd_pcm_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_PSWITCH_READ, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_playback_switch_write( void *handle, int dev, int switchn, snd_pcm_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_PSWITCH_WRITE, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_record_switches( void *handle, int dev )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
int result;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_RSWITCHES, &result ) < 0 )
|
||||
return -errno;
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_record_switch( void *handle, int dev, const char *switch_id )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
snd_pcm_switch_t uswitch;
|
||||
int idx, switches, err;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
/* bellow implementation isn't optimized for speed */
|
||||
/* info about switches should be cached in the snd_ctl_t structure */
|
||||
if ( (switches = snd_ctl_pcm_record_switches( handle, dev )) < 0 )
|
||||
return switches;
|
||||
for ( idx = 0; idx < switches; idx++ ) {
|
||||
if ( (err = snd_ctl_pcm_record_switch_read( handle, dev, idx, &uswitch )) < 0 )
|
||||
return err;
|
||||
if ( !strncmp( switch_id, uswitch.name, sizeof( uswitch.name ) ) )
|
||||
return idx;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_record_switch_read( void *handle, int dev, int switchn, snd_pcm_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_RSWITCH_READ, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_pcm_record_switch_write( void *handle, int dev, int switchn, snd_pcm_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_PCM_RSWITCH_WRITE, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_mixer_info( void *handle, int dev, snd_mixer_info_t *info )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
|
@ -204,6 +330,69 @@ int snd_ctl_mixer_info( void *handle, int dev, snd_mixer_info_t *info )
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_mixer_switches( void *handle, int dev )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
int result;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_MIXER_SWITCHES, &result ) < 0 )
|
||||
return -errno;
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_ctl_mixer_switch( void *handle, int dev, const char *switch_id )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
snd_mixer_switch_t uswitch;
|
||||
int idx, switches, err;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
/* bellow implementation isn't optimized for speed */
|
||||
/* info about switches should be cached in the snd_ctl_t structure */
|
||||
if ( (switches = snd_ctl_mixer_switches( handle, dev )) < 0 )
|
||||
return switches;
|
||||
for ( idx = 0; idx < switches; idx++ ) {
|
||||
if ( (err = snd_ctl_mixer_switch_read( handle, dev, idx, &uswitch )) < 0 )
|
||||
return err;
|
||||
if ( !strncmp( switch_id, uswitch.name, sizeof( uswitch.name ) ) )
|
||||
return idx;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int snd_ctl_mixer_switch_read( void *handle, int dev, int switchn, snd_mixer_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_MIXER_SWITCH_READ, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_mixer_switch_write( void *handle, int dev, int switchn, snd_mixer_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_MIXER_SWITCH_WRITE, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_info( void *handle, int dev, snd_rawmidi_info_t *info )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
|
@ -216,3 +405,155 @@ int snd_ctl_rawmidi_info( void *handle, int dev, snd_rawmidi_info_t *info )
|
|||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_output_info( void *handle, int dev, snd_rawmidi_output_info_t *info )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_OUTPUT_INFO, info ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_input_info( void *handle, int dev, snd_rawmidi_input_info_t *info )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_INPUT_INFO, info ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_output_switches( void *handle, int dev )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
int result;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_OSWITCHES, &result ) < 0 )
|
||||
return -errno;
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_output_switch( void *handle, int dev, const char *switch_id )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
snd_rawmidi_switch_t uswitch;
|
||||
int idx, switches, err;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
/* bellow implementation isn't optimized for speed */
|
||||
/* info about switches should be cached in the snd_ctl_t structure */
|
||||
if ( (switches = snd_ctl_rawmidi_output_switches( handle, dev )) < 0 )
|
||||
return switches;
|
||||
for ( idx = 0; idx < switches; idx++ ) {
|
||||
if ( (err = snd_ctl_rawmidi_output_switch_read( handle, dev, idx, &uswitch )) < 0 )
|
||||
return err;
|
||||
if ( !strncmp( switch_id, uswitch.name, sizeof( uswitch.name ) ) )
|
||||
return idx;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_output_switch_read( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_OSWITCH_READ, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_output_switch_write( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_OSWITCH_WRITE, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_input_switches( void *handle, int dev )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
int result;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_ISWITCHES, &result ) < 0 )
|
||||
return -errno;
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_input_switch( void *handle, int dev, const char *switch_id )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
snd_rawmidi_switch_t uswitch;
|
||||
int idx, switches, err;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
/* bellow implementation isn't optimized for speed */
|
||||
/* info about switches should be cached in the snd_ctl_t structure */
|
||||
if ( (switches = snd_ctl_rawmidi_input_switches( handle, dev )) < 0 )
|
||||
return switches;
|
||||
for ( idx = 0; idx < switches; idx++ ) {
|
||||
if ( (err = snd_ctl_rawmidi_input_switch_read( handle, dev, idx, &uswitch )) < 0 )
|
||||
return err;
|
||||
if ( !strncmp( switch_id, uswitch.name, sizeof( uswitch.name ) ) )
|
||||
return idx;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_input_switch_read( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_ISWITCH_READ, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_rawmidi_input_switch_write( void *handle, int dev, int switchn, snd_rawmidi_switch_t *data )
|
||||
{
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
ctl = (snd_ctl_t *)handle;
|
||||
if ( !ctl ) return -EINVAL;
|
||||
data -> switchn = switchn;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev ) < 0 )
|
||||
return -errno;
|
||||
if ( ioctl( ctl -> fd, SND_CTL_IOCTL_RAWMIDI_ISWITCH_WRITE, data ) < 0 )
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue