]> git.vomp.tv Git - vompclient.git/commitdiff
Fix playback of mono mpeg audio
authorMarten Richter <marten.richter@freenet.de>
Sat, 8 Dec 2012 11:20:29 +0000 (12:20 +0100)
committerMarten Richter <marten.richter@freenet.de>
Sat, 8 Dec 2012 11:20:29 +0000 (12:20 +0100)
audioomx.cc

index 1d72d2bf9dc9b7a35f3ef23f53d048cbdccabb05..a803c1cfc4bb2fef6742082c4e3ec5b5f370b485 100644 (file)
@@ -2032,6 +2032,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                int dsize = av_samples_get_buffer_size(NULL,
                                                current_context->channels, decode_frame_libav->nb_samples,
                                                current_context->sample_fmt, 1);
+                               if (current_context->channels==1) dsize*=2; // we convert mono to stereo
                                if ((cur_input_buf_omx->nFilledLen + dsize)
                                                > cur_input_buf_omx->nAllocLen ) {
                                        // I doubt that this will ever happen
@@ -2075,8 +2076,22 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                }
 
                                //Log::getInstance()->log("Audio", Log::DEBUG,"memcpy in %d %d %d" ,dsize,current_context->sample_rate,cur_input_buf_omx->nFilledLen);
-                               memcpy(cur_input_buf_omx->pBuffer + cur_input_buf_omx->nFilledLen,
-                                               decode_frame_libav->data[0], dsize);
+                               if (current_context->channels!=1) {
+                                       memcpy(cur_input_buf_omx->pBuffer + cur_input_buf_omx->nFilledLen,
+                                                       decode_frame_libav->data[0], dsize);
+                               } else { //convert to stereo
+                                       unsigned short* startbuffer=(unsigned short* )decode_frame_libav->data[0];
+                                       unsigned short* endbuffer=(unsigned short* )(decode_frame_libav->data[0]+dsize/2);
+                                       unsigned short* destbuffer=(unsigned short* )(cur_input_buf_omx->pBuffer + cur_input_buf_omx->nFilledLen);
+                                       while (startbuffer!=endbuffer) {
+                                           unsigned short temp=*startbuffer;
+                                               *destbuffer=temp;
+                                               destbuffer++;
+                                               *destbuffer=temp;
+                                               destbuffer++;
+                                               startbuffer++;
+                                       }
+                               }
                                //Log::getInstance()->log("Audio", Log::DEBUG,"memcpy out");
                                cur_input_buf_omx->nFilledLen += dsize;
                        } else {