comparison mplayer.c @ 24892:80180dc13565

Change decode_audio() interface Rewrite decode_audio to better deal with filters that handle input in large blocks. It now always places output in sh_audio->a_out_buffer (which was always given as a parameter before) and reallocates the buffer if needed. After the changes filters can return arbitrarily large blocks of data without some of it being lost. The new version also allows simplifying some code.
author uau
date Thu, 01 Nov 2007 06:52:19 +0000
parents fefb019faa90
children 2bfc75674b71
comparison
equal deleted inserted replaced
24891:fefb019faa90 24892:80180dc13565
1777 bytes_to_write -= playsize; 1777 bytes_to_write -= playsize;
1778 1778
1779 // Fill buffer if needed: 1779 // Fill buffer if needed:
1780 current_module="decode_audio"; 1780 current_module="decode_audio";
1781 t = GetTimer(); 1781 t = GetTimer();
1782 while (sh_audio->a_out_buffer_len < playsize) { 1782 if (decode_audio(sh_audio, playsize) < 0) // EOF or error
1783 int buflen = sh_audio->a_out_buffer_len; 1783 if (mpctx->d_audio->eof) {
1784 int ret = decode_audio(sh_audio, &sh_audio->a_out_buffer[buflen], 1784 audio_eof = 1;
1785 playsize - buflen, // min bytes 1785 if (sh_audio->a_out_buffer_len == 0)
1786 sh_audio->a_out_buffer_size - buflen // max 1786 return 0;
1787 );
1788 if (ret <= 0) { // EOF?
1789 if (mpctx->d_audio->eof) {
1790 audio_eof = 1;
1791 if (sh_audio->a_out_buffer_len == 0)
1792 return 0;
1793 }
1794 break;
1795 } 1787 }
1796 sh_audio->a_out_buffer_len += ret;
1797 }
1798 t = GetTimer() - t; 1788 t = GetTimer() - t;
1799 tt = t*0.000001f; audio_time_usage+=tt; 1789 tt = t*0.000001f; audio_time_usage+=tt;
1800 if (playsize > sh_audio->a_out_buffer_len) { 1790 if (playsize > sh_audio->a_out_buffer_len) {
1801 playsize = sh_audio->a_out_buffer_len; 1791 playsize = sh_audio->a_out_buffer_len;
1802 if (audio_eof) 1792 if (audio_eof)