Skip to content

Bug in SequencerClientBase.create_port() #16

@Hoosier-Beagler

Description

@Hoosier-Beagler

In client.py there is a bug in the create_port function. In the function there are two ways to create a port. The first uses snd_seq_create_simple_port which returns the newly created port_id. The second uses snd_seq_create_port which returns zero upon success and negative otherwise. The code uses this success status code as the newly assigned port_id. That is incorrect as it always returns the port with port_id=0. The info structure must be accessed for the new port_id.

Here's the client.py code starting at line 550.

            port = alsa.snd_seq_create_port(self.handle, info)
        _check_alsa_error(port)
        return Port(self, port)

Notice how the alsa-lib seqmid.c (line 71) implements the snd_seq_create_simple_port using the snd_seq_create_port and pulling the new port_id from the PortInfo structure.

int snd_seq_create_simple_port(snd_seq_t *seq, const char *name,
			       unsigned int caps, unsigned int type)
{
	snd_seq_port_info_t pinfo;
	int result;

	memset(&pinfo, 0, sizeof(pinfo));
	if (name)
		strncpy(pinfo.name, name, sizeof(pinfo.name) - 1);
	pinfo.capability = caps;
	pinfo.type = type;
	pinfo.midi_channels = 16;
	pinfo.midi_voices = 64; /* XXX */
	pinfo.synth_voices = 0; /* XXX */

	result = snd_seq_create_port(seq, &pinfo);
	if (result < 0)
		return result;
	else
		return pinfo.addr.port;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions