ref: 56567fae64db5d2dd9745979fd8acb66de54e2ba
parent: 08c71874219a1085ac6b45ee95aec9f68a2f0ae7
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Fri Dec 29 06:52:44 EST 2017
Avoid symbol collisions (especially with static linking)
--- a/src/opus_header.c
+++ b/src/opus_header.c
@@ -101,7 +101,7 @@
return 1;
}
-int opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len)
+int _ope_opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len)
{
int i;
Packet p;
@@ -184,7 +184,7 @@
buf[base]=(val)&0xff; \
}while(0)
-void comment_init(char **comments, int* length, const char *vendor_string)
+void _ope_comment_init(char **comments, int* length, const char *vendor_string)
{
/*The 'vendor' field should be the actual encoding library used.*/
int vendor_length=strlen(vendor_string);
@@ -200,7 +200,7 @@
*comments=p;
}
-int comment_add(char **comments, int* length, const char *tag, const char *val)
+int _ope_comment_add(char **comments, int* length, const char *tag, const char *val)
{
char* p=*comments;
int vendor_length=readint(p, 8);
@@ -224,7 +224,7 @@
return 0;
}
-void comment_pad(char **comments, int* length, int amount)
+void _ope_comment_pad(char **comments, int* length, int amount)
{
if(amount>0){
int i;
@@ -241,7 +241,7 @@
}
}
-int comment_replace_vendor_string(char **comments, int* length, const char *vendor_string)
+int _ope_comment_replace_vendor_string(char **comments, int* length, const char *vendor_string)
{
char* p=*comments;
int vendor_length;
--- a/src/opus_header.h
+++ b/src/opus_header.h
@@ -44,14 +44,14 @@
unsigned char stream_map[255];
} OpusHeader;
-int opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len);
+int _ope_opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len);
-void comment_init(char **comments, int* length, const char *vendor_string);
+void _ope_comment_init(char **comments, int* length, const char *vendor_string);
-int comment_add(char **comments, int* length, const char *tag, const char *val);
+int _ope_comment_add(char **comments, int* length, const char *tag, const char *val);
-void comment_pad(char **comments, int* length, int amount);
+void _ope_comment_pad(char **comments, int* length, int amount);
-int comment_replace_vendor_string(char **comments, int* length, const char *vendor_string);
+int _ope_comment_replace_vendor_string(char **comments, int* length, const char *vendor_string);
#endif
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -87,7 +87,7 @@
if (c == NULL) return NULL;
libopus_str = opus_get_version_string();
snprintf(vendor_str, sizeof(vendor_str), "%s, %s %s", libopus_str, PACKAGE_NAME, PACKAGE_VERSION);
- comment_init(&c->comment, &c->comment_length, vendor_str);
+ _ope_comment_init(&c->comment, &c->comment_length, vendor_str);
if (c->comment == NULL) {
free(c);
return NULL;
@@ -122,7 +122,7 @@
int ope_comments_add(OggOpusComments *comments, const char *tag, const char *val) {
if (tag == NULL || val == NULL) return OPE_BAD_ARG;
if (strchr(tag, '=')) return OPE_BAD_ARG;
- if (comment_add(&comments->comment, &comments->comment_length, tag, val)) return OPE_ALLOC_FAIL;
+ if (_ope_comment_add(&comments->comment, &comments->comment_length, tag, val)) return OPE_ALLOC_FAIL;
return OPE_OK;
}
@@ -129,7 +129,7 @@
/* Add a comment. */
int ope_comments_add_string(OggOpusComments *comments, const char *tag_and_val) {
if (!strchr(tag_and_val, '=')) return OPE_BAD_ARG;
- if (comment_add(&comments->comment, &comments->comment_length, NULL, tag_and_val)) return OPE_ALLOC_FAIL;
+ if (_ope_comment_add(&comments->comment, &comments->comment_length, NULL, tag_and_val)) return OPE_ALLOC_FAIL;
return OPE_OK;
}
@@ -140,7 +140,7 @@
if (picture_data == NULL || err != OPE_OK){
return err;
}
- comment_add(&comments->comment, &comments->comment_length, "METADATA_BLOCK_PICTURE", picture_data);
+ _ope_comment_add(&comments->comment, &comments->comment_length, "METADATA_BLOCK_PICTURE", picture_data);
free(picture_data);
return OPE_OK;
}
@@ -380,7 +380,7 @@
}
oggp_set_muxing_delay(enc->oggp, enc->max_ogg_delay);
}
- comment_pad(&enc->streams->comment, &enc->streams->comment_length, enc->comment_padding);
+ _ope_comment_pad(&enc->streams->comment, &enc->streams->comment_length, enc->comment_padding);
/* Get preskip at the last minute (when it can no longer change). */
if (enc->global_granule_offset == -1) {
@@ -396,7 +396,7 @@
int packet_size;
unsigned char *p;
p = oggp_get_packet_buffer(enc->oggp, 276);
- packet_size = opus_header_to_packet(&enc->header, p, 276);
+ packet_size = _ope_opus_header_to_packet(&enc->header, p, 276);
if (enc->packet_callback) enc->packet_callback(enc->packet_callback_data, p, packet_size, 0);
oggp_commit_packet(enc->oggp, packet_size, 0, 0);
oe_flush_page(enc);