ALSA: firewire-motu: unify the count of subscriber for packet streaming
Two counters are used to maintain isochronous packet streaming for both directions. However, like the other drivers, they can be replaced with one counter. This commit unifies them. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
7bc93821a7
commit
18f26034be
|
@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
|
|||
|
||||
mutex_lock(&motu->mutex);
|
||||
|
||||
motu->capture_substreams++;
|
||||
motu->substreams_counter++;
|
||||
err = snd_motu_stream_start_duplex(motu, 0);
|
||||
|
||||
mutex_unlock(&motu->mutex);
|
||||
|
@ -40,7 +40,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
|
|||
|
||||
mutex_lock(&motu->mutex);
|
||||
|
||||
motu->playback_substreams++;
|
||||
motu->substreams_counter++;
|
||||
err = snd_motu_stream_start_duplex(motu, 0);
|
||||
|
||||
mutex_unlock(&motu->mutex);
|
||||
|
@ -57,7 +57,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream)
|
|||
|
||||
mutex_lock(&motu->mutex);
|
||||
|
||||
motu->capture_substreams--;
|
||||
motu->substreams_counter--;
|
||||
snd_motu_stream_stop_duplex(motu);
|
||||
|
||||
mutex_unlock(&motu->mutex);
|
||||
|
@ -72,7 +72,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream)
|
|||
|
||||
mutex_lock(&motu->mutex);
|
||||
|
||||
motu->playback_substreams--;
|
||||
motu->substreams_counter--;
|
||||
snd_motu_stream_stop_duplex(motu);
|
||||
|
||||
mutex_unlock(&motu->mutex);
|
||||
|
|
|
@ -203,7 +203,7 @@ static int capture_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
|
||||
mutex_lock(&motu->mutex);
|
||||
motu->capture_substreams++;
|
||||
motu->substreams_counter++;
|
||||
mutex_unlock(&motu->mutex);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ static int playback_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
|
||||
mutex_lock(&motu->mutex);
|
||||
motu->playback_substreams++;
|
||||
motu->substreams_counter++;
|
||||
mutex_unlock(&motu->mutex);
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ static int capture_hw_free(struct snd_pcm_substream *substream)
|
|||
mutex_lock(&motu->mutex);
|
||||
|
||||
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
|
||||
motu->capture_substreams--;
|
||||
motu->substreams_counter--;
|
||||
|
||||
snd_motu_stream_stop_duplex(motu);
|
||||
|
||||
|
@ -252,7 +252,7 @@ static int playback_hw_free(struct snd_pcm_substream *substream)
|
|||
mutex_lock(&motu->mutex);
|
||||
|
||||
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
|
||||
motu->playback_substreams--;
|
||||
motu->substreams_counter--;
|
||||
|
||||
snd_motu_stream_stop_duplex(motu);
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
|
|||
unsigned int curr_rate;
|
||||
int err = 0;
|
||||
|
||||
if (motu->capture_substreams == 0 && motu->playback_substreams == 0)
|
||||
if (motu->substreams_counter == 0)
|
||||
return 0;
|
||||
|
||||
/* Some packet queueing errors. */
|
||||
|
@ -271,8 +271,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
|
|||
}
|
||||
}
|
||||
|
||||
if (!amdtp_stream_running(&motu->tx_stream) &&
|
||||
motu->capture_substreams > 0) {
|
||||
if (!amdtp_stream_running(&motu->tx_stream)) {
|
||||
err = start_isoc_ctx(motu, &motu->tx_stream);
|
||||
if (err < 0) {
|
||||
dev_err(&motu->unit->device,
|
||||
|
@ -291,15 +290,12 @@ stop_streams:
|
|||
|
||||
void snd_motu_stream_stop_duplex(struct snd_motu *motu)
|
||||
{
|
||||
if (motu->capture_substreams == 0) {
|
||||
if (motu->substreams_counter == 0) {
|
||||
if (amdtp_stream_running(&motu->tx_stream))
|
||||
stop_isoc_ctx(motu, &motu->tx_stream);
|
||||
|
||||
if (motu->playback_substreams == 0) {
|
||||
if (amdtp_stream_running(&motu->rx_stream))
|
||||
stop_isoc_ctx(motu, &motu->rx_stream);
|
||||
stop_both_streams(motu);
|
||||
}
|
||||
if (amdtp_stream_running(&motu->rx_stream))
|
||||
stop_isoc_ctx(motu, &motu->rx_stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,8 +368,7 @@ void snd_motu_stream_destroy_duplex(struct snd_motu *motu)
|
|||
destroy_stream(motu, AMDTP_IN_STREAM);
|
||||
destroy_stream(motu, AMDTP_OUT_STREAM);
|
||||
|
||||
motu->playback_substreams = 0;
|
||||
motu->capture_substreams = 0;
|
||||
motu->substreams_counter = 0;
|
||||
}
|
||||
|
||||
static void motu_lock_changed(struct snd_motu *motu)
|
||||
|
|
|
@ -60,8 +60,7 @@ struct snd_motu {
|
|||
struct amdtp_stream rx_stream;
|
||||
struct fw_iso_resources tx_resources;
|
||||
struct fw_iso_resources rx_resources;
|
||||
unsigned int capture_substreams;
|
||||
unsigned int playback_substreams;
|
||||
unsigned int substreams_counter;
|
||||
|
||||
/* For notification. */
|
||||
struct fw_address_handler async_handler;
|
||||
|
|
Loading…
Reference in New Issue