summaryrefslogtreecommitdiff
path: root/sound/firewire/oxfw
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-06-15 18:11:01 +0900
committerTakashi Iwai <tiwai@suse.de>2019-06-17 08:18:36 +0200
commit7bc93821a70adc621df443c8b7a4745023c36e7c (patch)
tree0474e9b97389716fb9e1320d6ceeba6b61be03d2 /sound/firewire/oxfw
parentc6b84ffbd5e78d6cf4aaafe5502e1bc99eb9657c (diff)
ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection
In current implementation, establishment connection corresponds to allocation of isochronous resources. Although this is an ideal implementation of CMP described in IEC 61883-1, it's not enough efficient to recover PCM substream multiplexed in packet streaming. The packet streaming can always restart on the same allocated isochronous resources even if the previous packet streaming corrupted. This commit splits allocation of isochronous resources from establishment of connection so that CMP runs with allocated isochronous resources. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/oxfw')
-rw-r--r--sound/firewire/oxfw/oxfw-stream.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
index 837733f10736..a8bc798731ff 100644
--- a/sound/firewire/oxfw/oxfw-stream.c
+++ b/sound/firewire/oxfw/oxfw-stream.c
@@ -111,8 +111,7 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
else
conn = &oxfw->out_conn;
- err = cmp_connection_establish(conn,
- amdtp_stream_get_max_payload(stream));
+ err = cmp_connection_establish(conn);
if (err < 0)
return err;
@@ -203,15 +202,18 @@ static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
enum avc_general_plug_dir dir;
u8 **formats;
struct snd_oxfw_stream_formation formation;
+ struct cmp_connection *conn;
int i;
int err;
if (stream == &oxfw->rx_stream) {
dir = AVC_GENERAL_PLUG_DIR_IN;
formats = oxfw->rx_stream_formats;
+ conn = &oxfw->in_conn;
} else {
dir = AVC_GENERAL_PLUG_DIR_OUT;
formats = oxfw->tx_stream_formats;
+ conn = &oxfw->out_conn;
}
err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation);
@@ -239,8 +241,12 @@ static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
if (formation.pcm == 0)
return -EINVAL;
- return amdtp_am824_set_parameters(stream, formation.rate, formation.pcm,
+ err = amdtp_am824_set_parameters(stream, formation.rate, formation.pcm,
formation.midi * 8, false);
+ if (err < 0)
+ return err;
+
+ return cmp_connection_reserve(conn, amdtp_stream_get_max_payload(stream));
}
int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
@@ -299,8 +305,10 @@ int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
if (oxfw->has_output) {
err = keep_resources(oxfw, &oxfw->tx_stream);
- if (err < 0)
+ if (err < 0) {
+ cmp_connection_release(&oxfw->in_conn);
return err;
+ }
}
}
@@ -361,10 +369,12 @@ void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw)
if (oxfw->substreams_count == 0) {
amdtp_stream_stop(&oxfw->rx_stream);
cmp_connection_break(&oxfw->in_conn);
+ cmp_connection_release(&oxfw->in_conn);
if (oxfw->has_output) {
amdtp_stream_stop(&oxfw->tx_stream);
cmp_connection_break(&oxfw->out_conn);
+ cmp_connection_release(&oxfw->out_conn);
}
}
}