summaryrefslogtreecommitdiff
path: root/sound/firewire/motu/motu-midi.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-06-17 17:15:08 +0900
committerTakashi Iwai <tiwai@suse.de>2019-06-18 08:45:31 +0200
commit8edc56ec8f14a586a55b2ab2fda76e6bf4738ee6 (patch)
treee41c78039331da3eda25e75ba7ad6522d7941b86 /sound/firewire/motu/motu-midi.c
parentec694fba2ac9406cb3fc3c3216db3de9ed3174a7 (diff)
ALSA: firewire-motu: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks
Once allocated, isochronous resources are available for packet streaming, even if the streaming is cancelled. For this reason, current implementation handles allocation of the resources and starting packet streaming at the same time. However, this brings complicated procedure to start packet streaming. This commit separates the allocation and starting. The allocation is done in pcm.hw_params callback and available till pcm.hw_free callback. Even if any XRUN occurs, pcm.prepare callback is done to restart packet streaming without releasing/allocating the resources. There are two points to stop packet streaming; in pcm.hw_params and pcm.prepare callbacks. The former point is a case that packet streaming is already started for any MIDI substream then packet streaming is requested with different sampling transfer frequency for any PCM substream. The latter point is cases of any XRUN or packet queueing error. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/motu/motu-midi.c')
-rw-r--r--sound/firewire/motu/motu-midi.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c
index 3b205386ed24..a463730c72bc 100644
--- a/sound/firewire/motu/motu-midi.c
+++ b/sound/firewire/motu/motu-midi.c
@@ -18,8 +18,11 @@ static int midi_open(struct snd_rawmidi_substream *substream)
mutex_lock(&motu->mutex);
- motu->substreams_counter++;
- err = snd_motu_stream_start_duplex(motu, 0);
+ err = snd_motu_stream_reserve_duplex(motu, 0);
+ if (err >= 0) {
+ ++motu->substreams_counter;
+ err = snd_motu_stream_start_duplex(motu);
+ }
mutex_unlock(&motu->mutex);
@@ -35,8 +38,9 @@ static int midi_close(struct snd_rawmidi_substream *substream)
mutex_lock(&motu->mutex);
- motu->substreams_counter--;
+ --motu->substreams_counter;
snd_motu_stream_stop_duplex(motu);
+ snd_motu_stream_release_duplex(motu);
mutex_unlock(&motu->mutex);