shithub: libopusenc

Download patch

ref: 469caffa2d29496deaa481f182d42f1fd0826ca9
parent: bd594ec19d9787e2cef0fc021cd02e57fef9f550
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Sun May 14 10:50:43 EDT 2017

Remove const on OggOpusComments

Will make it possible to do reference counting and copy-on-write

--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -230,7 +230,7 @@
     \param[out] error Error code (NULL if no error is to be returned)
     \return Newly-created encoder.
     */
-OPE_EXPORT OggOpusEnc *ope_encoder_create_file(const char *path, const OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
+OPE_EXPORT OggOpusEnc *ope_encoder_create_file(const char *path, OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
 
 /** Create a new OggOpus stream to be handled using callbacks
     \param callbacks  Callback functions
@@ -243,7 +243,7 @@
     \return Newly-created encoder.
     */
 OPE_EXPORT OggOpusEnc *ope_encoder_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
-    const OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
+    OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
 
 /** Create a new OggOpus stream to be used along with.ope_encoder_get_page().
   This is mostly useful for muxing with other streams.
@@ -254,7 +254,7 @@
     \param[out] error Error code (NULL if no error is to be returned)
     \return Newly-created encoder.
     */
-OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(const OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
+OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
 
 /** Add/encode any number of float samples to the stream.
     \param[in,out] enc         Encoder
@@ -294,7 +294,7 @@
     \param comments   Comments associated with the stream
     \return Error code
  */
-OPE_EXPORT int ope_encoder_chain_current(OggOpusEnc *enc, const OggOpusComments *comments);
+OPE_EXPORT int ope_encoder_chain_current(OggOpusEnc *enc, OggOpusComments *comments);
 
 /** Ends the stream and create a new file.
     \param[in,out] enc Encoder
@@ -302,7 +302,7 @@
     \param comments    Comments associated with the stream
     \return Error code
  */
-OPE_EXPORT int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, const OggOpusComments *comments);
+OPE_EXPORT int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, OggOpusComments *comments);
 
 /** Ends the stream and create a new file (callback-based).
     \param[in,out] enc Encoder
@@ -310,7 +310,7 @@
     \param comments    Comments associated with the stream
     \return Error code
  */
-OPE_EXPORT int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, const OggOpusComments *comments);
+OPE_EXPORT int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, OggOpusComments *comments);
 
 /** Write out the header now rather than wait for audio to begin.
     \param[in,out] enc Encoder
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -222,7 +222,7 @@
 };
 
 /* Create a new OggOpus file. */
-OggOpusEnc *ope_encoder_create_file(const char *path, const OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error) {
+OggOpusEnc *ope_encoder_create_file(const char *path, OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error) {
   OggOpusEnc *enc;
   struct StdioObject *obj;
   obj = malloc(sizeof(*obj));
@@ -239,7 +239,7 @@
   return enc;
 }
 
-EncStream *stream_create(const OggOpusComments *comments) {
+EncStream *stream_create(OggOpusComments *comments) {
   EncStream *stream;
   stream = malloc(sizeof(*stream));
   if (!stream) return NULL;
@@ -268,7 +268,7 @@
 
 /* Create a new OggOpus file (callback-based). */
 OggOpusEnc *ope_encoder_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
-    const OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error) {
+    OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error) {
   OpusMSEncoder *st=NULL;
   OggOpusEnc *enc=NULL;
   int ret;
@@ -352,7 +352,7 @@
 }
 
 /* Create a new OggOpus stream, pulling one page at a time. */
-OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(const OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error) {
+OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error) {
   OggOpusEnc *enc = ope_encoder_create_callbacks(NULL, NULL, comments, rate, channels, family, error);
   enc->pull_api = 1;
   return enc;
@@ -612,13 +612,13 @@
 }
 
 /* Ends the stream and create a new stream within the same file. */
-int ope_encoder_chain_current(OggOpusEnc *enc, const OggOpusComments *comments) {
+int ope_encoder_chain_current(OggOpusEnc *enc, OggOpusComments *comments) {
   enc->last_stream->close_at_end = 0;
   return ope_encoder_continue_new_callbacks(enc, enc->last_stream->user_data, comments);
 }
 
 /* Ends the stream and create a new file. */
-int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, const OggOpusComments *comments) {
+int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, OggOpusComments *comments) {
   int ret;
   struct StdioObject *obj;
   if (!(obj = malloc(sizeof(*obj)))) return OPE_ALLOC_FAIL;
@@ -636,7 +636,7 @@
 }
 
 /* Ends the stream and create a new file (callback-based). */
-int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, const OggOpusComments *comments) {
+int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, OggOpusComments *comments) {
   if (enc->unrecoverable) return OPE_UNRECOVERABLE;
   EncStream *new_stream;
   assert(enc->streams);