aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-13 22:54:15 +0100
committerMax Kellermann <max@duempel.org>2014-01-13 22:54:15 +0100
commit07a7fde8253384d92fee70f061fc809e9bfa7544 (patch)
tree72e4da1fe1de7aa08892f57fac3c0e7b5bc16c05
parent049abef2d45656197312d040a981238ca9c44dd0 (diff)
parentcd5817b67e89d4f47546809ad0299bdec1823147 (diff)
downloadmpd-07a7fde8253384d92fee70f061fc809e9bfa7544.tar.gz
mpd-07a7fde8253384d92fee70f061fc809e9bfa7544.tar.xz
mpd-07a7fde8253384d92fee70f061fc809e9bfa7544.zip
Merge branch 'shine' of git://github.com/ekroth/mpd
Diffstat (limited to '')
-rw-r--r--src/encoder/ShineEncoderPlugin.cxx22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/encoder/ShineEncoderPlugin.cxx b/src/encoder/ShineEncoderPlugin.cxx
index 3097810b9..39e400a58 100644
--- a/src/encoder/ShineEncoderPlugin.cxx
+++ b/src/encoder/ShineEncoderPlugin.cxx
@@ -57,7 +57,7 @@ struct ShineEncoder {
bool Setup(Error &error);
- bool WriteChunk(bool flush, Error &error);
+ bool WriteChunk(bool flush);
};
static constexpr Domain shine_encoder_domain("shine_encoder");
@@ -142,7 +142,9 @@ shine_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
encoder->stereo[0] = new int16_t[encoder->frame_size];
encoder->stereo[1] = new int16_t[encoder->frame_size];
- encoder->input_pos = 0;
+ /* workaround for bug:
+ https://github.com/savonet/shine/issues/11 */
+ encoder->input_pos = SHINE_MAX_SAMPLES + 1;
encoder->output_buffer.Construct(BUFFER_INIT_SIZE);
@@ -154,6 +156,12 @@ shine_encoder_close(Encoder *_encoder)
{
ShineEncoder *encoder = (ShineEncoder *)_encoder;
+ if (encoder->input_pos > SHINE_MAX_SAMPLES) {
+ /* write zero chunk */
+ encoder->input_pos = 0;
+ encoder->WriteChunk(true);
+ }
+
shine_close(encoder->shine);
delete[] encoder->stereo[0];
delete[] encoder->stereo[1];
@@ -161,7 +169,7 @@ shine_encoder_close(Encoder *_encoder)
}
bool
-ShineEncoder::WriteChunk(bool flush, gcc_unused Error &error)
+ShineEncoder::WriteChunk(bool flush)
{
if (flush || input_pos == frame_size) {
long written;
@@ -195,6 +203,10 @@ shine_encoder_write(Encoder *_encoder,
length /= sizeof(*data) * encoder->audio_format.channels;
size_t written = 0;
+ if (encoder->input_pos > SHINE_MAX_SAMPLES) {
+ encoder->input_pos = 0;
+ }
+
/* write all data to de-interleaved buffers */
while (written < length) {
for (;
@@ -207,7 +219,7 @@ shine_encoder_write(Encoder *_encoder,
encoder->stereo[1][encoder->input_pos] = data[base + 1];
}
/* write if chunk is filled */
- encoder->WriteChunk(false, error);
+ encoder->WriteChunk(false);
}
return true;
@@ -220,7 +232,7 @@ shine_encoder_flush(Encoder *_encoder, gcc_unused Error &error)
long written;
/* flush buffers and flush shine */
- encoder->WriteChunk(true, error);
+ encoder->WriteChunk(true);
const uint8_t *data = shine_flush(encoder->shine, &written);
if (written > 0)