ALSA: oxfw: unify substreams counter
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 12 Jun 2019 08:44:20 +0000 (17:44 +0900)
committerTakashi Iwai <tiwai@suse.de>
Wed, 12 Jun 2019 13:26:58 +0000 (15:26 +0200)
In former commits, two isochronous contexts are handles at the same
time. This commit unifies stream counters to obsolete them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/oxfw/oxfw-midi.c
sound/firewire/oxfw/oxfw-pcm.c
sound/firewire/oxfw/oxfw-stream.c
sound/firewire/oxfw/oxfw.h

index 31352cebdfe9fd89f3a94a20c560c3444cefbb71..092493497f1abc26c8dcd745ea8ba6a423cf9b7e 100644 (file)
@@ -19,7 +19,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->capture_substreams++;
+       ++oxfw->substreams_count;
        err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->tx_stream, 0, 0);
 
        mutex_unlock(&oxfw->mutex);
@@ -41,7 +41,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->playback_substreams++;
+       ++oxfw->substreams_count;
        err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->rx_stream, 0, 0);
 
        mutex_unlock(&oxfw->mutex);
@@ -58,7 +58,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->capture_substreams--;
+       --oxfw->substreams_count;
        snd_oxfw_stream_stop_duplex(oxfw);
 
        mutex_unlock(&oxfw->mutex);
@@ -73,7 +73,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       oxfw->playback_substreams--;
+       --oxfw->substreams_count;
        snd_oxfw_stream_stop_duplex(oxfw);
 
        mutex_unlock(&oxfw->mutex);
index 253d79607bdf1ad88a39ca3baf124cafe2009a1b..79c8e514bed93b38ad856dc64dfb549a8130ce41 100644 (file)
@@ -220,7 +220,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream,
 
        if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                mutex_lock(&oxfw->mutex);
-               oxfw->capture_substreams++;
+               ++oxfw->substreams_count;
                mutex_unlock(&oxfw->mutex);
        }
 
@@ -239,7 +239,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
 
        if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                mutex_lock(&oxfw->mutex);
-               oxfw->playback_substreams++;
+               ++oxfw->substreams_count;
                mutex_unlock(&oxfw->mutex);
        }
 
@@ -253,7 +253,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
        mutex_lock(&oxfw->mutex);
 
        if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
-               oxfw->capture_substreams--;
+               --oxfw->substreams_count;
 
        snd_oxfw_stream_stop_duplex(oxfw);
 
@@ -268,7 +268,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
        mutex_lock(&oxfw->mutex);
 
        if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
-               oxfw->playback_substreams--;
+               --oxfw->substreams_count;
 
        snd_oxfw_stream_stop_duplex(oxfw);
 
index 52cf815c27f7bc5d2c6cdb853be005e700bd44b2..ebfe0777773b676be0c8a880e1cf20978307440d 100644 (file)
@@ -244,7 +244,7 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw,
        enum avc_general_plug_dir dir;
        int err = 0;
 
-       if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0)
+       if (oxfw->substreams_count == 0)
                return -EIO;
 
        // Considering JACK/FFADO streaming:
@@ -323,7 +323,7 @@ error:
 
 void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw)
 {
-       if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) {
+       if (oxfw->substreams_count == 0) {
                amdtp_stream_stop(&oxfw->rx_stream);
                cmp_connection_break(&oxfw->in_conn);
 
index 911a452f94db2674d97b181904c05625dd2357be..e0c825288a240f054363c0e0d917f968b7a1dd98 100644 (file)
@@ -52,8 +52,7 @@ struct snd_oxfw {
        struct cmp_connection in_conn;
        struct amdtp_stream tx_stream;
        struct amdtp_stream rx_stream;
-       unsigned int capture_substreams;
-       unsigned int playback_substreams;
+       unsigned int substreams_count;
 
        unsigned int midi_input_ports;
        unsigned int midi_output_ports;