Accept data until next Ogg packet is ready in VorbisEncoder#canWrite

This commit is contained in:
alban.peignier@gmail.com 2013-07-21 18:42:47 +00:00
parent 93cea2772e
commit e0cad73a68
1 changed files with 14 additions and 11 deletions

View File

@ -8,19 +8,19 @@
Version : $Revision$ Version : $Revision$
Author : $Author$ Author : $Author$
Location : $HeadURL$ Location : $HeadURL$
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -211,11 +211,11 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
unsigned int outChannel = 0, unsigned int outChannel = 0,
unsigned int outMaxBitrate = 0 ) unsigned int outMaxBitrate = 0 )
throw ( Exception ) throw ( Exception )
: AudioEncoder ( sink, : AudioEncoder ( sink,
inSampleRate, inSampleRate,
inBitsPerSample, inBitsPerSample,
inChannel, inChannel,
inBigEndian, inBigEndian,
outBitrateMode, outBitrateMode,
outBitrate, outBitrate,
@ -253,7 +253,7 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
unsigned int outChannel = 0, unsigned int outChannel = 0,
unsigned int outMaxBitrate = 0 ) unsigned int outMaxBitrate = 0 )
throw ( Exception ) throw ( Exception )
: AudioEncoder ( sink, : AudioEncoder ( sink,
as, as,
outBitrateMode, outBitrateMode,
@ -402,7 +402,11 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
return false; return false;
} }
return getSink()->canWrite(sec, usec); if ( 1 == vorbis_analysis_blockout( &vorbisDspState, &vorbisBlock) ) {
return getSink()->canWrite(sec, usec);
} else {
return true;
}
} }
/** /**
@ -447,4 +451,3 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
#endif /* VORBIS_LIB_ENCODER_H */ #endif /* VORBIS_LIB_ENCODER_H */