update to 0.12: bug fixes and portability improvements

This commit is contained in:
naddy 2020-07-10 19:44:31 +00:00
parent c41fd2ca4b
commit 66783072cd
5 changed files with 12 additions and 264 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.11 2019/07/12 20:43:37 sthen Exp $
# $OpenBSD: Makefile,v 1.12 2020/07/10 19:44:31 naddy Exp $
COMMENT = high-level decoding and seeking API for Opus files
DISTNAME = opusfile-0.11
DISTNAME = opusfile-0.12
CATEGORIES = audio
SHARED_LIBS += opusfile 1.0 # 4.4
SHARED_LIBS += opusurl 1.0 # 4.4
SHARED_LIBS += opusfile 1.0 # 4.5
SHARED_LIBS += opusurl 1.0 # 4.5
HOMEPAGE = https://opus-codec.org/
MAINTAINER = Christian Weisgerber <naddy@openbsd.org>
@ -15,11 +15,13 @@ PERMIT_PACKAGE = Yes
WANTLIB = crypto m ogg opus ssl
MASTER_SITES = https://archive.mozilla.org/pub/opus/
MASTER_SITES = https://downloads.xiph.org/releases/opus/
LIB_DEPENDS = audio/libogg \
audio/opus
DEBUG_PACKAGES = ${BUILD_PACKAGES}
SEPARATE_BUILD = Yes
CONFIGURE_STYLE = gnu
CONFIGURE_ARGS = --disable-maintainer-mode

View File

@ -1,2 +1,2 @@
SHA256 (opusfile-0.11.tar.gz) = dM6bbPTaEDEz57XJXfgQzrcZVHHhFi7VevQV+r9WA78=
SIZE (opusfile-0.11.tar.gz) = 467420
SHA256 (opusfile-0.12.tar.gz) = EY2GAcEt1qRPUkI+aMqQg8yfK/5y2nqMGssiqArjVQs=
SIZE (opusfile-0.12.tar.gz) = 471354

View File

@ -1,17 +0,0 @@
$OpenBSD: patch-configure,v 1.3 2017/08/14 22:09:51 naddy Exp $
Do not disable HTTP support despite missing ftime() since we replace
it with gettimeofday().
Index: configure
--- configure.orig
+++ configure
@@ -12546,7 +12546,7 @@ if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
else
- enable_http=no
+ : enable_http=no
fi

View File

@ -1,237 +0,0 @@
$OpenBSD: patch-src_http_c,v 1.3 2017/08/14 22:09:51 naddy Exp $
No struct timeb / ftime(3) support; libcompat is gone.
Replace with struct timeval / gettimeofday(2).
Index: src/http.c
--- src/http.c.orig
+++ src/http.c
@@ -355,7 +355,7 @@ typedef int op_sock;
# define op_reset_errno() (errno=0)
# endif
-# include <sys/timeb.h>
+# include <sys/time.h>
# include <openssl/x509v3.h>
/*The maximum number of simultaneous connections.
@@ -799,7 +799,7 @@ struct OpusHTTPConn{
/*The next connection in either the LRU or free list.*/
OpusHTTPConn *next;
/*The last time we blocked for reading from this connection.*/
- struct timeb read_time;
+ struct timeval read_time;
/*The number of bytes we've read since the last time we blocked.*/
opus_int64 read_bytes;
/*The estimated throughput of this connection, in bytes/s.*/
@@ -849,7 +849,7 @@ struct OpusHTTPStream{
struct sockaddr_in6 v6;
} addr;
/*The last time we re-resolved the host.*/
- struct timeb resolve_time;
+ struct timeval resolve_time;
/*A buffer used to build HTTP requests.*/
OpusStringBuf request;
/*A buffer used to build proxy CONNECT requests.*/
@@ -1004,26 +1004,25 @@ static int op_http_conn_estimate_available(OpusHTTPCon
return available;
}
-static opus_int32 op_time_diff_ms(const struct timeb *_end,
- const struct timeb *_start){
+static opus_int32 op_time_diff_ms(const struct timeval *_end,
+ const struct timeval *_start){
opus_int64 dtime;
- dtime=_end->time-(opus_int64)_start->time;
- OP_ASSERT(_end->millitm<1000);
- OP_ASSERT(_start->millitm<1000);
- if(OP_UNLIKELY(dtime>(OP_INT32_MAX-1000)/1000))return OP_INT32_MAX;
- if(OP_UNLIKELY(dtime<(OP_INT32_MIN+1000)/1000))return OP_INT32_MIN;
- return (opus_int32)dtime*1000+_end->millitm-_start->millitm;
+ dtime=_end->tv_sec-_start->tv_sec;
+ dtime=dtime*1000+(_end->tv_usec-_start->tv_usec)/1000;
+ if(OP_UNLIKELY(dtime>OP_INT32_MAX))return OP_INT32_MAX;
+ if(OP_UNLIKELY(dtime<OP_INT32_MIN))return OP_INT32_MIN;
+ return (opus_int32)dtime;
}
/*Update the read rate estimate for this connection.*/
static void op_http_conn_read_rate_update(OpusHTTPConn *_conn){
- struct timeb read_time;
+ struct timeval read_time;
opus_int32 read_delta_ms;
opus_int64 read_delta_bytes;
opus_int64 read_rate;
read_delta_bytes=_conn->read_bytes;
if(read_delta_bytes<=0)return;
- ftime(&read_time);
+ gettimeofday(&read_time,NULL);
read_delta_ms=op_time_diff_ms(&read_time,&_conn->read_time);
read_rate=_conn->read_rate;
read_delta_ms=OP_MAX(read_delta_ms,1);
@@ -1530,7 +1529,7 @@ static long op_bio_retry_ctrl(BIO *_b,int _cmd,long _n
return ret;
}
-# if OPENSSL_VERSION_NUMBER<0x10100000L
+# if OPENSSL_VERSION_NUMBER<0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
# define BIO_set_data(_b,_ptr) ((_b)->ptr=(_ptr))
# define BIO_set_init(_b,_init) ((_b)->init=(_init))
# define ASN1_STRING_get0_data ASN1_STRING_data
@@ -1538,7 +1537,7 @@ static long op_bio_retry_ctrl(BIO *_b,int _cmd,long _n
static int op_bio_retry_new(BIO *_b){
BIO_set_init(_b,1);
-# if OPENSSL_VERSION_NUMBER<0x10100000L
+# if OPENSSL_VERSION_NUMBER<0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
_b->num=0;
# endif
BIO_set_data(_b,NULL);
@@ -1549,7 +1548,7 @@ static int op_bio_retry_free(BIO *_b){
return _b!=NULL;
}
-# if OPENSSL_VERSION_NUMBER<0x10100000L
+# if OPENSSL_VERSION_NUMBER<0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
/*This is not const because OpenSSL doesn't allow it, even though it won't
write to it.*/
static BIO_METHOD op_bio_retry_method={
@@ -1570,7 +1569,7 @@ static BIO_METHOD op_bio_retry_method={
proxying https URL requests.*/
static int op_http_conn_establish_tunnel(OpusHTTPStream *_stream,
OpusHTTPConn *_conn,op_sock _fd,SSL *_ssl_conn,BIO *_ssl_bio){
-# if OPENSSL_VERSION_NUMBER>=0x10100000L
+# if OPENSSL_VERSION_NUMBER>=0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
BIO_METHOD *bio_retry_method;
# endif
BIO *retry_bio;
@@ -1583,7 +1582,7 @@ static int op_http_conn_establish_tunnel(OpusHTTPStrea
ret=op_http_conn_write_fully(_conn,
_stream->proxy_connect.buf,_stream->proxy_connect.nbuf);
if(OP_UNLIKELY(ret<0))return ret;
-# if OPENSSL_VERSION_NUMBER>=0x10100000L
+# if OPENSSL_VERSION_NUMBER>=0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
bio_retry_method=BIO_meth_new(BIO_TYPE_NULL,"retry");
if(bio_retry_method==NULL)return OP_EFAULT;
BIO_meth_set_write(bio_retry_method,op_bio_retry_write);
@@ -1606,7 +1605,7 @@ static int op_http_conn_establish_tunnel(OpusHTTPStrea
/*This shouldn't succeed, since we can't read yet.*/
OP_ALWAYS_TRUE(SSL_connect(_ssl_conn)<0);
SSL_set_bio(_ssl_conn,_ssl_bio,_ssl_bio);
-# if OPENSSL_VERSION_NUMBER>=0x10100000L
+# if OPENSSL_VERSION_NUMBER>=0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
BIO_meth_free(bio_retry_method);
# endif
/*Only now do we disable write coalescing, to allow the CONNECT
@@ -1893,7 +1892,7 @@ static int op_http_conn_start_tls(OpusHTTPStream *_str
SSL_set_tlsext_host_name(_ssl_conn,_stream->url.host);
# endif
skip_certificate_check=_stream->skip_certificate_check;
-# if OPENSSL_VERSION_NUMBER>=0x10002000L
+# if OPENSSL_VERSION_NUMBER>=0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
/*As of version 1.0.2, OpenSSL can finally do hostname checks automatically.
Of course, they make it much more complicated than it needs to be.*/
if(!skip_certificate_check){
@@ -2015,7 +2014,7 @@ static int op_sock_connect_next(op_sock _fd,
# define OP_NPROTOS (2)
static int op_http_connect_impl(OpusHTTPStream *_stream,OpusHTTPConn *_conn,
- struct addrinfo *_addrs,struct timeb *_start_time){
+ struct addrinfo *_addrs,struct timeval *_start_time){
struct addrinfo *addr;
struct addrinfo *addrs[OP_NPROTOS];
struct pollfd fds[OP_NPROTOS];
@@ -2045,7 +2044,7 @@ static int op_http_connect_impl(OpusHTTPStream *_strea
_stream->free_head=_conn->next;
_conn->next=_stream->lru_head;
_stream->lru_head=_conn;
- ftime(_start_time);
+ gettimeofday(_start_time,NULL);
*&_conn->read_time=*_start_time;
_conn->read_bytes=0;
_conn->read_rate=0;
@@ -2147,14 +2146,14 @@ static int op_http_connect_impl(OpusHTTPStream *_strea
}
static int op_http_connect(OpusHTTPStream *_stream,OpusHTTPConn *_conn,
- struct addrinfo *_addrs,struct timeb *_start_time){
- struct timeb resolve_time;
+ struct addrinfo *_addrs,struct timeval *_start_time){
+ struct timeval resolve_time;
struct addrinfo *new_addrs;
int ret;
/*Re-resolve the host if we need to (RFC 6555 says we MUST do so
occasionally).*/
new_addrs=NULL;
- ftime(&resolve_time);
+ gettimeofday(&resolve_time,NULL);
if(_addrs!=&_stream->addr_info||op_time_diff_ms(&resolve_time,
&_stream->resolve_time)>=OP_RESOLVE_CACHE_TIMEOUT_MS){
new_addrs=op_resolve(_stream->connect_host,_stream->connect_port);
@@ -2305,8 +2304,8 @@ static int op_http_stream_open(OpusHTTPStream *_stream
addrs=NULL;
for(nredirs=0;nredirs<OP_REDIRECT_LIMIT;nredirs++){
OpusParsedURL next_url;
- struct timeb start_time;
- struct timeb end_time;
+ struct timeval start_time;
+ struct timeval end_time;
char *next;
char *status_code;
int minor_version_pos;
@@ -2314,7 +2313,7 @@ static int op_http_stream_open(OpusHTTPStream *_stream
/*Initialize the SSL library if necessary.*/
if(OP_URL_IS_SSL(&_stream->url)&&_stream->ssl_ctx==NULL){
SSL_CTX *ssl_ctx;
-# if OPENSSL_VERSION_NUMBER<0x10100000L
+# if OPENSSL_VERSION_NUMBER<0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
# if !defined(OPENSSL_NO_LOCKING)
/*The documentation says SSL_library_init() is not reentrant.
We don't want to add our own depenencies on a threading library, and it
@@ -2440,7 +2439,7 @@ static int op_http_stream_open(OpusHTTPStream *_stream
if(OP_UNLIKELY(ret<0))return ret;
ret=op_http_conn_read_response(_stream->conns+0,&_stream->response);
if(OP_UNLIKELY(ret<0))return ret;
- ftime(&end_time);
+ gettimeofday(&end_time,NULL);
next=op_http_parse_status_line(&v1_1_compat,&status_code,
_stream->response.buf);
if(OP_UNLIKELY(next==NULL))return OP_FALSE;
@@ -2852,8 +2851,8 @@ static int op_http_conn_handle_response(OpusHTTPStream
converted into a request for the rest.*/
static int op_http_conn_open_pos(OpusHTTPStream *_stream,
OpusHTTPConn *_conn,opus_int64 _pos,opus_int32 _chunk_size){
- struct timeb start_time;
- struct timeb end_time;
+ struct timeval start_time;
+ struct timeval end_time;
opus_int32 connect_rate;
opus_int32 connect_time;
int ret;
@@ -2863,7 +2862,7 @@ static int op_http_conn_open_pos(OpusHTTPStream *_stre
if(OP_UNLIKELY(ret<0))return ret;
ret=op_http_conn_handle_response(_stream,_conn);
if(OP_UNLIKELY(ret!=0))return OP_FALSE;
- ftime(&end_time);
+ gettimeofday(&end_time,NULL);
_stream->cur_conni=(int)(_conn-_stream->conns);
OP_ASSERT(_stream->cur_conni>=0&&_stream->cur_conni<OP_NCONNS_MAX);
/*The connection has been successfully opened.
@@ -3115,7 +3114,7 @@ static int op_http_conn_read_ahead(OpusHTTPStream *_st
}
static int op_http_stream_seek(void *_stream,opus_int64 _offset,int _whence){
- struct timeb seek_time;
+ struct timeval seek_time;
OpusHTTPStream *stream;
OpusHTTPConn *conn;
OpusHTTPConn **pnext;
@@ -3156,7 +3155,7 @@ static int op_http_stream_seek(void *_stream,opus_int6
op_http_conn_read_rate_update(stream->conns+ci);
*&seek_time=*&stream->conns[ci].read_time;
}
- else ftime(&seek_time);
+ else gettimeofday(&seek_time,NULL);
/*If we seeked past the end of the stream, just disable the active
connection.*/
if(pos>=content_length){

View File

@ -1,9 +1,9 @@
@comment $OpenBSD: PLIST,v 1.4 2017/08/14 22:09:51 naddy Exp $
@comment $OpenBSD: PLIST,v 1.5 2020/07/10 19:44:31 naddy Exp $
include/opus/opusfile.h
lib/libopusfile.a
@static-lib lib/libopusfile.a
lib/libopusfile.la
@lib lib/libopusfile.so.${LIBopusfile_VERSION}
lib/libopusurl.a
@static-lib lib/libopusurl.a
lib/libopusurl.la
@lib lib/libopusurl.so.${LIBopusurl_VERSION}
lib/pkgconfig/opusfile.pc