openbsd-ports/audio/jack/patches/patch-drivers_netjack_netjack_packet_c
jakemsr d58e7b8aad * clean up sndio(7) driver
* update README.OpenBSD
* add patches to let it build on gcc2 archs (from Sebastian Reitenbach)
* disable audio(4) driver
2010-06-07 01:44:38 +00:00

130 lines
5.2 KiB
Plaintext

$OpenBSD: patch-drivers_netjack_netjack_packet_c,v 1.1 2010/06/07 01:44:38 jakemsr Exp $
--- drivers/netjack/netjack_packet.c.orig Wed May 19 21:19:11 2010
+++ drivers/netjack/netjack_packet.c Wed May 19 21:32:41 2010
@@ -672,13 +672,15 @@ packet_cache_find_latency( packet_cache *pcache, jack_
int
netjack_recvfrom (int sockfd, char *packet_buf, int pkt_size, int flags, struct sockaddr *addr, socklen_t *addr_size, int mtu)
{
- if (pkt_size <= mtu)
- return recvfrom (sockfd, packet_buf, pkt_size, flags, addr, addr_size);
- char *rx_packet = alloca (mtu);
- jacknet_packet_header *pkthdr = (jacknet_packet_header *) rx_packet;
+ char *rx_packet;
+ jacknet_packet_header *pkthdr;
int rcv_len;
jack_nframes_t framecnt;
cache_packet *cpack;
+ if (pkt_size <= mtu)
+ return recvfrom (sockfd, packet_buf, pkt_size, flags, addr, addr_size);
+ rx_packet = alloca (mtu);
+ pkthdr = (jacknet_packet_header *) rx_packet;
do
{
rcv_len = recvfrom (sockfd, rx_packet, mtu, 0, addr, addr_size);
@@ -696,13 +698,16 @@ netjack_recvfrom (int sockfd, char *packet_buf, int pk
int
netjack_recv (int sockfd, char *packet_buf, int pkt_size, int flags, int mtu)
{
- if (pkt_size <= mtu)
- return recv (sockfd, packet_buf, pkt_size, flags);
- char *rx_packet = alloca (mtu);
- jacknet_packet_header *pkthdr = (jacknet_packet_header *) rx_packet;
+ char *rx_packet;
+ jacknet_packet_header *pkthdr;
int rcv_len;
jack_nframes_t framecnt;
cache_packet *cpack;
+
+ if (pkt_size <= mtu)
+ return recv (sockfd, packet_buf, pkt_size, flags);
+ rx_packet = alloca (mtu);
+ pkthdr = (jacknet_packet_header *) rx_packet;
do
{
rcv_len = recv (sockfd, rx_packet, mtu, flags);
@@ -723,15 +728,18 @@ netjack_sendto (int sockfd, char *packet_buf, int pkt_
int frag_cnt = 0;
char *tx_packet, *dataX;
jacknet_packet_header *pkthdr;
+ int fragment_payload_size;
+ int err;
+ char *packet_bufX;
+ int last_payload_size;
tx_packet = alloca (mtu + 10);
dataX = tx_packet + sizeof (jacknet_packet_header);
pkthdr = (jacknet_packet_header *) tx_packet;
- int fragment_payload_size = mtu - sizeof (jacknet_packet_header);
+ fragment_payload_size = mtu - sizeof (jacknet_packet_header);
if (pkt_size <= mtu) {
- int err;
pkthdr = (jacknet_packet_header *) packet_buf;
pkthdr->fragment_nr = htonl (0);
err = sendto(sockfd, packet_buf, pkt_size, flags, addr, addr_size);
@@ -742,12 +750,11 @@ netjack_sendto (int sockfd, char *packet_buf, int pkt_
}
else
{
- int err;
// Copy the packet header to the tx pack first.
memcpy(tx_packet, packet_buf, sizeof (jacknet_packet_header));
// Now loop and send all
- char *packet_bufX = packet_buf + sizeof (jacknet_packet_header);
+ packet_bufX = packet_buf + sizeof (jacknet_packet_header);
while (packet_bufX < (packet_buf + pkt_size - fragment_payload_size))
{
@@ -757,7 +764,7 @@ netjack_sendto (int sockfd, char *packet_buf, int pkt_
packet_bufX += fragment_payload_size;
}
- int last_payload_size = packet_buf + pkt_size - packet_bufX;
+ last_payload_size = packet_buf + pkt_size - packet_bufX;
memcpy (dataX, packet_bufX, last_payload_size);
pkthdr->fragment_nr = htonl (frag_cnt);
//jack_error("last fragment_count = %d, payload_size = %d\n", fragment_count, last_payload_size);
@@ -779,6 +786,7 @@ decode_midi_buffer (uint32_t *buffer_uint32, unsigned
for (i = 0; i < buffer_size_uint32 - 3;)
{
uint32_t payload_size;
+ unsigned int nb_data_quads;
payload_size = buffer_uint32[i];
payload_size = ntohl (payload_size);
if (payload_size)
@@ -790,7 +798,7 @@ decode_midi_buffer (uint32_t *buffer_uint32, unsigned
jack_midi_event_write (buf, event.time, event.buffer, event.size);
// skip to the next event
- unsigned int nb_data_quads = (((event.size-1) & ~0x3) >> 2)+1;
+ nb_data_quads = (((event.size-1) & ~0x3) >> 2)+1;
i += 3+nb_data_quads;
}
else
@@ -808,9 +816,12 @@ encode_midi_buffer (uint32_t *buffer_uint32, unsigned
for (i = 0; i < nevents; ++i)
{
jack_midi_event_t event;
+ unsigned int nb_data_quads;
+ unsigned int payload_size;
+ jack_midi_data_t* tmpbuff;
jack_midi_event_get (&event, buf, i);
- unsigned int nb_data_quads = (((event.size - 1) & ~0x3) >> 2) + 1;
- unsigned int payload_size = 3 + nb_data_quads;
+ nb_data_quads = (((event.size - 1) & ~0x3) >> 2) + 1;
+ payload_size = 3 + nb_data_quads;
// only write if we have sufficient space for the event
// otherwise drop it
if (written + payload_size < buffer_size_uint32 - 1)
@@ -824,7 +835,7 @@ encode_midi_buffer (uint32_t *buffer_uint32, unsigned
written++;
// write data
- jack_midi_data_t* tmpbuff = (jack_midi_data_t*)(&(buffer_uint32[written]));
+ tmpbuff = (jack_midi_data_t*)(&(buffer_uint32[written]));
memcpy (tmpbuff, event.buffer, event.size);
written += nb_data_quads;
}