- header.timestamp = htonl((uint32_t)rtp_timestamp);
- int written_bytes;
- do {
- written_bytes = writev(rtp_fd, vec, 2);
- } while(written_bytes < 0 && errno == EINTR);
- if(written_bytes < 0) {
- error(errno, "error transmitting audio data");
- ++rtp_errors;
- if(rtp_errors == 10)
- fatal(0, "too many audio tranmission errors");
- return 0;
+ /* Send stuff to explicitly registerd unicast addresses unconditionally */
+ struct rtp_recipient *r;
+ struct msghdr m;
+ memset(&m, 0, sizeof m);
+ m.msg_iov = vec;
+ m.msg_iovlen = 2;
+ pthread_mutex_lock(&rtp_lock);
+ for(r = rtp_recipient_list; r; r = r->next) {
+ m.msg_name = &r->sa;
+ m.msg_namelen = r->sa.ss_family == AF_INET ?
+ sizeof(struct sockaddr_in) : sizeof (struct sockaddr_in6);
+ sendmsg(r->sa.ss_family == AF_INET ? rtp_fd4 : rtp_fd6,
+ &m, MSG_DONTWAIT|MSG_NOSIGNAL);
+ // TODO similar error handling to other case?
+ }
+ pthread_mutex_unlock(&rtp_lock);
+ if(rtp_mode != RTP_REQUEST) {
+ int written_bytes;
+ do {
+ written_bytes = writev(rtp_fd, vec, 2);
+ } while(written_bytes < 0 && errno == EINTR);
+ if(written_bytes < 0) {
+ disorder_error(errno, "error transmitting audio data");
+ ++rtp_errors;
+ if(rtp_errors == 10)
+ disorder_fatal(0, "too many audio transmission errors");
+ return 0;
+ } else
+ rtp_errors /= 2; /* gradual decay */
+ }
+ /* TODO what can we sensibly do about short writes here? Really that's just
+ * an error and we ought to be using smaller packets. */
+ uaudio_schedule_sent(nsamples);
+ return nsamples;
+}
+
+static void hack_send_buffer_size(int fd, const char *what) {
+ int sndbuf, target_sndbuf = 131072;
+ socklen_t len = sizeof sndbuf;
+
+ if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF,
+ &sndbuf, &len) < 0)
+ disorder_fatal(errno, "error getting SO_SNDBUF on %s socket", what);
+ if(target_sndbuf > sndbuf) {
+ if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF,
+ &target_sndbuf, sizeof target_sndbuf) < 0)
+ disorder_error(errno, "error setting SO_SNDBUF on %s socket to %d",
+ what, target_sndbuf);
+ else
+ disorder_info("changed socket send buffer size on %socket from %d to %d",
+ what, sndbuf, target_sndbuf);