577c02d76077 — Chris Cannam 14 days ago
Comments object is necessary even if empty (otherwise the library crashes)
1 files changed, 5 insertions(+), 1 deletions(-)

M src/OpusWriteStream.cpp
M src/OpusWriteStream.cpp +5 -1
@@ 66,6 66,7 @@ class OpusWriteStream::D
 public:
     D() : encoder(0) { }
 
+    OggOpusComments *comments;
     OggOpusEnc *encoder;
 };
 

          
@@ 77,8 78,10 @@ OpusWriteStream::OpusWriteStream(Target 
 
     //!!! +windows file encoding?
 
+    m_d->comments = ope_comments_create();
+    
     int err = 0;
-    m_d->encoder = ope_encoder_create_file(getPath().c_str(), 0,
+    m_d->encoder = ope_encoder_create_file(getPath().c_str(), comments,
                                            getSampleRate(), getChannelCount(),
                                            getChannelCount() > 2 ? 1 : 0,
                                            &err);

          
@@ 104,6 107,7 @@ OpusWriteStream::~OpusWriteStream()
                  << err << ")" << endl;
         }
         ope_encoder_destroy(m_d->encoder);
+        ope_comments_destroy(m_d->comments);
     }
 }