]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix issue where mod_shout does not properly flush buffer on writing mp3 streams,...
authordschreiber <d@d-man.org>
Wed, 31 Aug 2011 20:35:13 +0000 (13:35 -0700)
committerdschreiber <d@d-man.org>
Wed, 31 Aug 2011 20:35:13 +0000 (13:35 -0700)
src/mod/formats/mod_shout/mod_shout.c

index bc72038db551142e30ccaec91fe1b8d284bde81e..ea6912b193f2cacdff5a9befc7caccd3f91b0abb 100644 (file)
@@ -204,6 +204,35 @@ static inline void free_context(shout_context_t *context)
                }
 
                if (context->shout) {
+                       if (context->gfp) {
+                               unsigned char mp3buffer[8192];
+                               int len;
+                               int16_t blank[2048] = { 0 }, *r = NULL;
+
+                               if (context->channels == 2) {
+                                       r = blank;
+                               }
+
+                               len = lame_encode_buffer(context->gfp, blank, r, sizeof(blank) / 2, mp3buffer, sizeof(mp3buffer));
+
+                               if (len) {
+                                       ret = shout_send(context->shout, mp3buffer, len);
+                                       if (ret == SHOUTERR_SUCCESS) {
+                                               shout_sync(context->shout);
+                                       }
+                               }
+
+                               while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) {
+                                       ret = shout_send(context->shout, mp3buffer, len);
+
+                                       if (ret != SHOUTERR_SUCCESS) {
+                                               break;
+                                       } else {
+                                               shout_sync(context->shout);
+                                       }
+                               }
+                       }
+
                        shout_close(context->shout);
                        context->shout = NULL;
                }