MediaView save message fixed. Sticker pan size updated correctly.

This commit is contained in:
John Preston 2017-01-09 17:12:53 +04:00
parent 143181095f
commit c09dab2b3a
6 changed files with 16 additions and 23 deletions

View File

@ -1604,13 +1604,11 @@ void AudioCaptureInner::onStop(bool needResult) {
d->opened = false;
}
if (d->ioContext) {
av_free(d->ioContext->buffer);
av_free(d->ioContext);
d->ioContext = nullptr;
av_freep(&d->ioContext->buffer);
av_freep(&d->ioContext);
d->ioBuffer = nullptr;
} else if (d->ioBuffer) {
av_free(d->ioBuffer);
d->ioBuffer = nullptr;
av_freep(&d->ioBuffer);
}
if (d->fmtContext) {
avformat_free_context(d->fmtContext);
@ -1746,9 +1744,8 @@ void AudioCaptureInner::processFrame(int32 offset, int32 framesize) {
d->dstSamples = av_rescale_rnd(swr_get_delay(d->swrContext, d->codecContext->sample_rate) + d->srcSamples, d->codecContext->sample_rate, d->codecContext->sample_rate, AV_ROUND_UP);
if (d->dstSamples > d->maxDstSamples) {
d->maxDstSamples = d->dstSamples;
av_free(d->dstSamplesData[0]);
if ((res = av_samples_alloc(d->dstSamplesData, 0, d->codecContext->channels, d->dstSamples, d->codecContext->sample_fmt, 0)) < 0) {
av_freep(&d->dstSamplesData[0]);
if ((res = av_samples_alloc(d->dstSamplesData, 0, d->codecContext->channels, d->dstSamples, d->codecContext->sample_fmt, 1)) < 0) {
LOG(("Audio Error: Unable to av_samples_alloc for capture, error %1, %2").arg(res).arg(av_make_error_string(err, sizeof(err), res)));
onStop(false);
emit error();

View File

@ -80,10 +80,10 @@ AbstractFFMpegLoader::~AbstractFFMpegLoader() {
avformat_close_input(&fmtContext);
}
if (ioContext) {
av_free(ioContext->buffer);
av_free(ioContext);
av_freep(&ioContext->buffer);
av_freep(&ioContext);
} else if (ioBuffer) {
av_free(ioBuffer);
av_freep(&ioBuffer);
}
if (fmtContext) avformat_free_context(fmtContext);
}
@ -294,10 +294,8 @@ AudioPlayerLoader::ReadResult FFMpegLoader::readFromReadyFrame(QByteArray &resul
int64_t dstSamples = av_rescale_rnd(swr_get_delay(swrContext, srcRate) + frame->nb_samples, dstRate, srcRate, AV_ROUND_UP);
if (dstSamples > maxResampleSamples) {
maxResampleSamples = dstSamples;
av_free(dstSamplesData[0]);
av_freep(&dstSamplesData[0]);
if ((res = av_samples_alloc(dstSamplesData, 0, AudioToChannels, maxResampleSamples, AudioToFormat, 1)) < 0) {
dstSamplesData[0] = 0;
char err[AV_ERROR_MAX_STRING_SIZE] = { 0 };
LOG(("Audio Error: Unable to av_samples_alloc for file '%1', data size '%2', error %3, %4").arg(file.name()).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
return ReadResult::Error;

View File

@ -167,10 +167,8 @@ AudioPlayerLoader::ReadResult ChildFFMpegLoader::readFromReadyFrame(QByteArray &
int64_t dstSamples = av_rescale_rnd(swr_get_delay(_swrContext, _srcRate) + _frame->nb_samples, _dstRate, _srcRate, AV_ROUND_UP);
if (dstSamples > _maxResampleSamples) {
_maxResampleSamples = dstSamples;
av_free(_dstSamplesData[0]);
av_freep(&_dstSamplesData[0]);
if ((res = av_samples_alloc(_dstSamplesData, 0, AudioToChannels, _maxResampleSamples, AudioToFormat, 1)) < 0) {
_dstSamplesData[0] = 0;
char err[AV_ERROR_MAX_STRING_SIZE] = { 0 };
LOG(("Audio Error: Unable to av_samples_alloc for file '%1', data size '%2', error %3, %4").arg(file.name()).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
return ReadResult::Error;

View File

@ -468,10 +468,10 @@ FFMpegReaderImplementation::~FFMpegReaderImplementation() {
avformat_close_input(&_fmtContext);
}
if (_ioContext) {
av_free(_ioContext->buffer);
av_free(_ioContext);
av_freep(&_ioContext->buffer);
av_freep(&_ioContext);
} else if (_ioBuffer) {
av_free(_ioBuffer);
av_freep(&_ioBuffer);
}
if (_fmtContext) avformat_free_context(_fmtContext);
av_frame_free(&_frame);

View File

@ -616,7 +616,6 @@ void MediaView::clearData() {
_photo = _additionalChatPhoto = nullptr;
_doc = nullptr;
_fullScreenVideo = false;
_saveMsgText.clear();
_caption.clear();
}

View File

@ -2983,11 +2983,12 @@ int EmojiPan::countBottom() const {
void EmojiPan::moveByBottom() {
if (inlineResultsShown()) {
setOrigin(Ui::PanelAnimation::Origin::BottomLeft);
moveToLeft(0, countBottom() - height());
moveToLeft(0, y());
} else {
setOrigin(Ui::PanelAnimation::Origin::BottomRight);
moveToRight(0, countBottom() - height());
moveToRight(0, y());
}
updateContentHeight();
}
void EmojiPan::enterEvent(QEvent *e) {