diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2019-06-11 22:21:16 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-06-11 16:02:09 +0200 |
commit | 3cd2c2d780a23e8b847c9ec22e8bc9dd6e685cbe (patch) | |
tree | 12f84ce4d581a56b8c6eaca9cd8bc5dd266978cb /sound/firewire/dice/dice-pcm.c | |
parent | c738aed136a74e9fafd90e5c8a0b13bf068a39f7 (diff) | |
download | linux-3cd2c2d780a23e8b847c9ec22e8bc9dd6e685cbe.tar.bz2 |
ALSA: dice: 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/dice/dice-pcm.c')
-rw-r--r-- | sound/firewire/dice/dice-pcm.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index bb3ef5ff3488..6c7a6b7ed743 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -243,12 +243,16 @@ static int capture_hw_params(struct snd_pcm_substream *substream, return err; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { + unsigned int rate = params_rate(hw_params); + mutex_lock(&dice->mutex); - dice->substreams_counter++; + err = snd_dice_stream_reserve_duplex(dice, rate); + if (err >= 0) + ++dice->substreams_counter; mutex_unlock(&dice->mutex); } - return 0; + return err; } static int playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) @@ -262,12 +266,16 @@ static int playback_hw_params(struct snd_pcm_substream *substream, return err; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { + unsigned int rate = params_rate(hw_params); + mutex_lock(&dice->mutex); - dice->substreams_counter++; + err = snd_dice_stream_reserve_duplex(dice, rate); + if (err >= 0) + ++dice->substreams_counter; mutex_unlock(&dice->mutex); } - return 0; + return err; } static int capture_hw_free(struct snd_pcm_substream *substream) @@ -277,9 +285,10 @@ static int capture_hw_free(struct snd_pcm_substream *substream) mutex_lock(&dice->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - dice->substreams_counter--; + --dice->substreams_counter; snd_dice_stream_stop_duplex(dice); + snd_dice_stream_release_duplex(dice); mutex_unlock(&dice->mutex); @@ -293,9 +302,10 @@ static int playback_hw_free(struct snd_pcm_substream *substream) mutex_lock(&dice->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - dice->substreams_counter--; + --dice->substreams_counter; snd_dice_stream_stop_duplex(dice); + snd_dice_stream_release_duplex(dice); mutex_unlock(&dice->mutex); @@ -309,7 +319,7 @@ static int capture_prepare(struct snd_pcm_substream *substream) int err; mutex_lock(&dice->mutex); - err = snd_dice_stream_start_duplex(dice, substream->runtime->rate); + err = snd_dice_stream_start_duplex(dice); mutex_unlock(&dice->mutex); if (err >= 0) amdtp_stream_pcm_prepare(stream); @@ -323,7 +333,7 @@ static int playback_prepare(struct snd_pcm_substream *substream) int err; mutex_lock(&dice->mutex); - err = snd_dice_stream_start_duplex(dice, substream->runtime->rate); + err = snd_dice_stream_start_duplex(dice); mutex_unlock(&dice->mutex); if (err >= 0) amdtp_stream_pcm_prepare(stream); |