Skip to content

Commit

Permalink
ALSA: dice: use stream formats to add MIDI substreams
Browse files Browse the repository at this point in the history
In former commits, proxy structure gets members for cache of stream
formats. The cache can be used to count the number of MIDI substreams
to add.

This commit uses the cache for this purpose.

Signed-off-by: Takashi Sakamoto <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
takaswie authored and tiwai committed May 2, 2018
1 parent afa617f commit b8f7823
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions sound/firewire/dice/dice-midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,18 @@ int snd_dice_create_midi(struct snd_dice *dice)
.close = midi_close,
.trigger = midi_playback_trigger,
};
__be32 reg;
struct snd_rawmidi *rmidi;
struct snd_rawmidi_str *str;
unsigned int midi_in_ports, midi_out_ports;
int i;
int err;

/*
* Use the number of MIDI conformant data channel at current sampling
* transfer frequency.
*/
err = snd_dice_transaction_read_tx(dice, TX_NUMBER_MIDI,
&reg, sizeof(reg));
if (err < 0)
return err;
midi_in_ports = be32_to_cpu(reg);

err = snd_dice_transaction_read_rx(dice, RX_NUMBER_MIDI,
&reg, sizeof(reg));
if (err < 0)
return err;
midi_out_ports = be32_to_cpu(reg);
midi_in_ports = 0;
midi_out_ports = 0;
for (i = 0; i < MAX_STREAMS; ++i) {
midi_in_ports = max(midi_in_ports, dice->tx_midi_ports[i]);
midi_out_ports = max(midi_out_ports, dice->rx_midi_ports[i]);
}

if (midi_in_ports + midi_out_ports == 0)
return 0;
Expand Down

0 comments on commit b8f7823

Please sign in to comment.