Skip to contentSkip to conversation

jack: Replacing jack->channels with jack->num_ports

PATCH Applied [email protected] 2 participants 3 messages Jan 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 jack: Replacing jack->channels with jack->num_ports

From: Laxmi Devi <[email protected]>

As jack->num_ports and jack->channels hold the same values, jack->channels is redundant and hence removed.

Sanity check is added in prepare, to check if io->Channels is same as jack->num_ports.

jack/pcm_jack.c +10 -6
index af2136e..d723b17 100644
@@ -48,7 +48,6 @@ typedef struct {
 	unsigned int sample_bits;
 	snd_pcm_uframes_t min_avail;
 
-	unsigned int channels;
 	snd_pcm_channel_area_t *areas;
 
 	jack_port_t **ports;
@@ -263,6 +262,12 @@ static int snd_pcm_jack_prepare(snd_pcm_ioplug_t *io)
 	snd_pcm_sw_params_t *swparams;
 	int err;
 
+	if (io->channels != jack->num_ports) {
+		SNDERR("Channel count %d not equal to no. of ports %d in JACK",
+		       io->channels, jack->num_ports);
+		return -EINVAL;
+	}
+
 	jack->hw_ptr = 0;
 	jack->xrun_detected = false;
 
@@ -381,7 +386,7 @@ static int jack_set_hw_constraint(snd_pcm_jack_t *jack)
 	unsigned int psize_list[MAX_PERIODS_MULTIPLE];
 	unsigned int nframes = jack_get_buffer_size(jack->client);
 	unsigned int jack_buffer_bytes = (snd_pcm_format_size(format, nframes) *
-					  jack->channels);
+					  jack->num_ports);
 	unsigned int i;
 	int err;
 
@@ -398,7 +403,7 @@ static int jack_set_hw_constraint(snd_pcm_jack_t *jack)
 	    (err = snd_pcm_ioplug_set_param_list(&jack->io, SND_PCM_IOPLUG_HW_FORMAT,
 						 1, &format)) < 0 ||
 	    (err = snd_pcm_ioplug_set_param_minmax(&jack->io, SND_PCM_IOPLUG_HW_CHANNELS,
-						   jack->channels, jack->channels)) < 0 ||
+						   jack->num_ports, jack->num_ports)) < 0 ||
 	    (err = snd_pcm_ioplug_set_param_minmax(&jack->io, SND_PCM_IOPLUG_HW_RATE,
 						   rate, rate)) < 0 ||
 	    (err = snd_pcm_ioplug_set_param_list(&jack->io, SND_PCM_IOPLUG_HW_PERIOD_BYTES,
@@ -485,8 +490,7 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
 		return err;
 	}
 
-	jack->channels = jack->num_ports;
-	if (jack->channels == 0) {
+	if (jack->num_ports == 0) {
 		SNDERR("define the %s_ports section",
 		       stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
 		snd_pcm_jack_free(jack);
@@ -514,7 +518,7 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
 		return -ENOENT;
 	}
 
-	jack->areas = calloc(jack->channels, sizeof(snd_pcm_channel_area_t));
+	jack->areas = calloc(jack->num_ports, sizeof(snd_pcm_channel_area_t));
 	if (! jack->areas) {
 		snd_pcm_jack_free(jack);
 		return -ENOMEM;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 jack: Removing snd_pcm_jack_format_t as it is not used

From: Laxmi Devi <[email protected]>

jack/pcm_jack.c +0 -4
index d723b17..b2bc213 100644
@@ -31,10 +31,6 @@
 
 #define MAX_PERIODS_MULTIPLE 64
 
-typedef enum _jack_format {
-	SND_PCM_JACK_FORMAT_RAW
-} snd_pcm_jack_format_t;
-
 typedef struct {
 	snd_pcm_ioplug_t io;
 
Signature · 1 line
2.7.4
#2 lore raw
In reply to [email protected]

Dne 11.1.2019 v 06:15 [email protected] napsal(a):

Quoted 7 lines

From: Laxmi Devi <[email protected]>

As jack->num_ports and jack->channels hold the same values, jack->channels is redundant and hence removed.

Sanity check is added in prepare, to check if io->Channels is same as jack->num_ports.

I applied both patches to the plugins repo. Thanks.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.