[alsa-devel] [PATCH 05/15] ALSA: dice: Add support for MIDI capture/playback
Clemens Ladisch
clemens at ladisch.de
Sun Dec 7 22:44:29 CET 2014
Takashi Sakamoto wrote:
> This commit adds a support for MIDI capture/playback
>
> +++ b/sound/firewire/dice/dice-midi.c
> +static int capture_open(struct snd_rawmidi_substream *substream)
> +{
> + struct snd_dice *dice = substream->rmidi->private_data;
> + int err;
> +
> + err = snd_dice_stream_lock_try(dice);
> + if (err < 0)
> + return err;
> +
> + mutex_lock(&dice->mutex);
> +
> + dice->substreams_counter++;
> + err = snd_dice_stream_start_duplex(dice, 0);
> +
> + mutex_unlock(&dice->mutex);
> +
> + if (err < 0)
> + snd_dice_stream_lock_release(dice);
> +
> + return err;
> +}
> +
> +static int playback_open(struct snd_rawmidi_substream *substream)
> +{
> + struct snd_dice *dice = substream->rmidi->private_data;
> + int err;
> +
> + err = snd_dice_stream_lock_try(dice);
> + if (err < 0)
> + return err;
> +
> + mutex_lock(&dice->mutex);
> +
> + dice->substreams_counter++;
> + err = snd_dice_stream_start_duplex(dice, 0);
> +
> + mutex_unlock(&dice->mutex);
> +
> + if (err < 0)
> + snd_dice_stream_lock_release(dice);
> +
> + return err;
> +}
These two functions are identical.
> +static int capture_close(struct snd_rawmidi_substream *substream)
> +{
> + struct snd_dice *dice = substream->rmidi->private_data;
> +
> + mutex_lock(&dice->mutex);
> +
> + dice->substreams_counter--;
> + snd_dice_stream_stop_duplex(dice);
> +
> + mutex_unlock(&dice->mutex);
> +
> + snd_dice_stream_lock_release(dice);
> + return 0;
> +}
> +
> +static int playback_close(struct snd_rawmidi_substream *substream)
> +{
> + struct snd_dice *dice = substream->rmidi->private_data;
> +
> + mutex_lock(&dice->mutex);
> +
> + dice->substreams_counter--;
> + snd_dice_stream_stop_duplex(dice);
> +
> + mutex_unlock(&dice->mutex);
> +
> + snd_dice_stream_lock_release(dice);
> + return 0;
> +}
These two too.
> +static void set_midi_substream_names(struct snd_dice *dice,
> + struct snd_rawmidi_str *str)
> +{
> + list_for_each_entry(subs, &str->substreams, list) {
> + snprintf(subs->name, sizeof(subs->name),
> + "%s MIDI %d", dice->card->shortname, subs->number + 1);
This is not really important, but the number is useless when the
device has only one MIDI port.
Regards,
Clemens
More information about the Alsa-devel
mailing list