aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/firewire/digi00x/digi00x-midi.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-06-11 22:21:11 +0900
committerTakashi Iwai <tiwai@suse.de>2019-06-11 16:02:05 +0200
commitae8ffbb26512bbfd3f929e34c85880f620ecb6eb (patch)
treeb8184e703654e1fa10a782893f696e0bd0bb4bf3 /sound/firewire/digi00x/digi00x-midi.c
parentALSA: firewire-digi00x: code refactoring to keep isochronous resources (diff)
downloadwireguard-linux-ae8ffbb26512bbfd3f929e34c85880f620ecb6eb.tar.xz
wireguard-linux-ae8ffbb26512bbfd3f929e34c85880f620ecb6eb.zip
ALSA: firewire-digi00x: 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/digi00x/digi00x-midi.c')
-rw-r--r--sound/firewire/digi00x/digi00x-midi.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sound/firewire/digi00x/digi00x-midi.c b/sound/firewire/digi00x/digi00x-midi.c
index 7ab3d0810f6b..cca888cce0d3 100644
--- a/sound/firewire/digi00x/digi00x-midi.c
+++ b/sound/firewire/digi00x/digi00x-midi.c
@@ -18,8 +18,11 @@ static int midi_open(struct snd_rawmidi_substream *substream)
return err;
mutex_lock(&dg00x->mutex);
- dg00x->substreams_counter++;
- err = snd_dg00x_stream_start_duplex(dg00x, 0);
+ err = snd_dg00x_stream_reserve_duplex(dg00x, 0);
+ if (err >= 0) {
+ ++dg00x->substreams_counter;
+ err = snd_dg00x_stream_start_duplex(dg00x);
+ }
mutex_unlock(&dg00x->mutex);
if (err < 0)
snd_dg00x_stream_lock_release(dg00x);
@@ -32,8 +35,9 @@ static int midi_close(struct snd_rawmidi_substream *substream)
struct snd_dg00x *dg00x = substream->rmidi->private_data;
mutex_lock(&dg00x->mutex);
- dg00x->substreams_counter--;
+ --dg00x->substreams_counter;
snd_dg00x_stream_stop_duplex(dg00x);
+ snd_dg00x_stream_release_duplex(dg00x);
mutex_unlock(&dg00x->mutex);
snd_dg00x_stream_lock_release(dg00x);