output/httpd: copy from returned encoder buffer
This fixes a regression from commitsc266fb7758
and00b8ced09f
, but really caused by API change in commit7e14f8f830
, and this plugin's failure to adapt to this API change. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1585
This commit is contained in:
parent
4c08c0b8b1
commit
2afe427ab3
|
@ -161,12 +161,21 @@ HttpdOutput::ReadPage() noexcept
|
||||||
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
do {
|
do {
|
||||||
const auto r = encoder->Read(std::span{buffer}.subspan(size));
|
const auto b = std::span{buffer}.subspan(size);
|
||||||
|
const auto r = encoder->Read(b);
|
||||||
if (r.empty())
|
if (r.empty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
unflushed_input = 0;
|
unflushed_input = 0;
|
||||||
|
|
||||||
|
if (r.data() != b.data()) {
|
||||||
|
/* if the encoder did not write to the given
|
||||||
|
buffer but instead returned its own buffer,
|
||||||
|
we need to copy it so we have a contiguous
|
||||||
|
buffer */
|
||||||
|
std::copy(r.begin(), r.end(), b.begin());
|
||||||
|
}
|
||||||
|
|
||||||
size += r.size();
|
size += r.size();
|
||||||
} while (size < sizeof(buffer));
|
} while (size < sizeof(buffer));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue