Merge tag 'asoc-v5.3' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-2.6-block.git] / sound / firewire / oxfw / oxfw-midi.c
index cbce01308bd1c5261e444ef396d18050fb49af08..9bdec08cb8eac0de6605c7832cb067043342c362 100644 (file)
@@ -18,8 +18,13 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->capture_substreams++;
-       err = snd_oxfw_stream_start_simplex(oxfw, &oxfw->tx_stream, 0, 0);
+       err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream, 0, 0);
+       if (err >= 0) {
+               ++oxfw->substreams_count;
+               err = snd_oxfw_stream_start_duplex(oxfw);
+               if (err < 0)
+                       --oxfw->substreams_count;
+       }
 
        mutex_unlock(&oxfw->mutex);
 
@@ -40,8 +45,11 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->playback_substreams++;
-       err = snd_oxfw_stream_start_simplex(oxfw, &oxfw->rx_stream, 0, 0);
+       err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->rx_stream, 0, 0);
+       if (err >= 0) {
+               ++oxfw->substreams_count;
+               err = snd_oxfw_stream_start_duplex(oxfw);
+       }
 
        mutex_unlock(&oxfw->mutex);
 
@@ -57,8 +65,8 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->capture_substreams--;
-       snd_oxfw_stream_stop_simplex(oxfw, &oxfw->tx_stream);
+       --oxfw->substreams_count;
+       snd_oxfw_stream_stop_duplex(oxfw);
 
        mutex_unlock(&oxfw->mutex);
 
@@ -72,8 +80,8 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->playback_substreams--;
-       snd_oxfw_stream_stop_simplex(oxfw, &oxfw->rx_stream);
+       --oxfw->substreams_count;
+       snd_oxfw_stream_stop_duplex(oxfw);
 
        mutex_unlock(&oxfw->mutex);