dev version 0.8.39 - Qt 5.5.0, repeat button in audio play

This commit is contained in:
John Preston 2015-07-14 22:07:21 +03:00
parent 8bb376798e
commit 5b9cdbd98a
13 changed files with 62 additions and 38 deletions

View File

@ -1,11 +1,11 @@
@echo OFF @echo OFF
set "AppVersionStrMajor=0.8" set "AppVersionStrMajor=0.8"
set "AppVersion=8038" set "AppVersion=8039"
set "AppVersionStrSmall=0.8.38" set "AppVersionStrSmall=0.8.39"
set "AppVersionStr=0.8.38" set "AppVersionStr=0.8.39"
set "AppVersionStrFull=0.8.38.0" set "AppVersionStrFull=0.8.39.0"
set "DevChannel=0" set "DevChannel=1"
if %DevChannel% neq 0 goto preparedev if %DevChannel% neq 0 goto preparedev

View File

@ -1989,6 +1989,7 @@ playerNext: sprite(374px, 151px, 22px, 14px);
playerPrev: sprite(374px, 165px, 22px, 14px); playerPrev: sprite(374px, 165px, 22px, 14px);
playerClose: sprite(361px, 97px, 12px, 12px); playerClose: sprite(361px, 97px, 12px, 12px);
playerFull: sprite(365px, 109px, 12px, 12px); playerFull: sprite(365px, 109px, 12px, 12px);
playerRepeat: sprite(365px, 121px, 12px, 14px);
playerVolume: sprite(352px, 179px, 44px, 12px); playerVolume: sprite(352px, 179px, 44px, 12px);
playerInactiveOpacity: 0.8; playerInactiveOpacity: 0.8;
playerUnavailableOpacity: 0.3; playerUnavailableOpacity: 0.3;

View File

@ -654,8 +654,8 @@ void Application::checkMapVersion() {
psRegisterCustomScheme(); psRegisterCustomScheme();
if (Local::oldMapVersion()) { if (Local::oldMapVersion()) {
QString versionFeatures; QString versionFeatures;
if (DevChannel && Local::oldMapVersion() < 8037) { if (DevChannel && Local::oldMapVersion() < 8039) {
versionFeatures = lang(lng_new_version_text);// QString::fromUtf8("\xe2\x80\x94 Forward photos, media and stickers with drag-n-drop\n\xe2\x80\x94 Drag-n-drop text messages by timestamp to forward them\n\xe2\x80\x94 Larger stickers panel");// .replace('@', qsl("@") + QChar(0x200D)); versionFeatures = QString::fromUtf8("\xe2\x80\x94 Moved to Qt 5.5\n\xe2\x80\x94 Some bugfixes and optimizations\n\xe2\x80\x94 In OS X 10.10.3 location marks sent from mobile should be displayed now");// .replace('@', qsl("@") + QChar(0x200D));
} else if (!DevChannel && Local::oldMapVersion() < 8038) { } else if (!DevChannel && Local::oldMapVersion() < 8038) {
versionFeatures = lang(lng_new_version_text).trimmed(); versionFeatures = lang(lng_new_version_text).trimmed();
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

View File

@ -1010,7 +1010,7 @@ public:
virtual int64 duration() = 0; virtual int64 duration() = 0;
virtual int32 frequency() = 0; virtual int32 frequency() = 0;
virtual int32 format() = 0; virtual int32 format() = 0;
virtual bool readMore(QByteArray &result, int64 &samplesAdded) = 0; virtual int readMore(QByteArray &result, int64 &samplesAdded) = 0; // < 0 - error, 0 - nothing read, > 0 - read something
protected: protected:
@ -1189,14 +1189,14 @@ public:
return fmt; return fmt;
} }
bool readMore(QByteArray &result, int64 &samplesAdded) { int readMore(QByteArray &result, int64 &samplesAdded) {
int res; int res;
if ((res = av_read_frame(fmtContext, &avpkt)) < 0) { if ((res = av_read_frame(fmtContext, &avpkt)) < 0) {
if (res != AVERROR_EOF) { if (res != AVERROR_EOF) {
char err[AV_ERROR_MAX_STRING_SIZE] = { 0 }; char err[AV_ERROR_MAX_STRING_SIZE] = { 0 };
LOG(("Audio Error: Unable to av_read_frame() file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res))); LOG(("Audio Error: Unable to av_read_frame() file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
} }
return false; return -1;
} }
if (avpkt.stream_index == streamId) { if (avpkt.stream_index == streamId) {
av_frame_unref(frame); av_frame_unref(frame);
@ -1204,7 +1204,10 @@ public:
if ((res = avcodec_decode_audio4(codecContext, frame, &got_frame, &avpkt)) < 0) { if ((res = avcodec_decode_audio4(codecContext, frame, &got_frame, &avpkt)) < 0) {
char err[AV_ERROR_MAX_STRING_SIZE] = { 0 }; char err[AV_ERROR_MAX_STRING_SIZE] = { 0 };
LOG(("Audio Error: Unable to avcodec_decode_audio4() file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res))); LOG(("Audio Error: Unable to avcodec_decode_audio4() file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
return false;
av_free_packet(&avpkt);
if (res == AVERROR_INVALIDDATA) return 0; // try to skip bad packet
return -1;
} }
if (got_frame) { if (got_frame) {
@ -1218,13 +1221,17 @@ public:
dstSamplesData[0] = 0; dstSamplesData[0] = 0;
char err[AV_ERROR_MAX_STRING_SIZE] = { 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(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res))); LOG(("Audio Error: Unable to av_samples_alloc for file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
return false;
av_free_packet(&avpkt);
return -1;
} }
} }
if ((res = swr_convert(swrContext, dstSamplesData, dstSamples, (const uint8_t**)frame->extended_data, frame->nb_samples)) < 0) { if ((res = swr_convert(swrContext, dstSamplesData, dstSamples, (const uint8_t**)frame->extended_data, frame->nb_samples)) < 0) {
char err[AV_ERROR_MAX_STRING_SIZE] = { 0 }; char err[AV_ERROR_MAX_STRING_SIZE] = { 0 };
LOG(("Audio Error: Unable to swr_convert for file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res))); LOG(("Audio Error: Unable to swr_convert for file '%1', data size '%2', error %3, %4").arg(fname).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
return false;
av_free_packet(&avpkt);
return -1;
} }
int32 resultLen = av_samples_get_buffer_size(0, _toChannels, res, _toFormat, 1); int32 resultLen = av_samples_get_buffer_size(0, _toChannels, res, _toFormat, 1);
result.append((const char*)dstSamplesData[0], resultLen); result.append((const char*)dstSamplesData[0], resultLen);
@ -1236,7 +1243,7 @@ public:
} }
} }
av_free_packet(&avpkt); av_free_packet(&avpkt);
return true; return 1;
} }
~FFMpegLoader() { ~FFMpegLoader() {
@ -1427,7 +1434,8 @@ void AudioPlayerLoaders::loadData(MediaOverviewType type, const void *objId, qin
QByteArray result; QByteArray result;
int64 samplesAdded = 0, frequency = l->frequency(), format = l->format(); int64 samplesAdded = 0, frequency = l->frequency(), format = l->format();
while (result.size() < AudioVoiceMsgBufferSize) { while (result.size() < AudioVoiceMsgBufferSize) {
if (!l->readMore(result, samplesAdded)) { int res = l->readMore(result, samplesAdded);
if (res < 0) {
if (errAtStart) { if (errAtStart) {
{ {
QMutexLocker lock(&playerMutex); QMutexLocker lock(&playerMutex);
@ -1440,7 +1448,7 @@ void AudioPlayerLoaders::loadData(MediaOverviewType type, const void *objId, qin
finished = true; finished = true;
break; break;
} }
errAtStart = false; if (res > 0) errAtStart = false;
QMutexLocker lock(&playerMutex); QMutexLocker lock(&playerMutex);
if (!checkLoader(type)) { if (!checkLoader(type)) {
@ -2309,9 +2317,9 @@ public:
return _coverFormat; return _coverFormat;
} }
bool readMore(QByteArray &result, int64 &samplesAdded) { int readMore(QByteArray &result, int64 &samplesAdded) {
DEBUG_LOG(("Audio Read Error: should not call this")); DEBUG_LOG(("Audio Read Error: should not call this"));
return false; return -1;
} }
~FFMpegAttributesReader() { ~FFMpegAttributesReader() {

View File

@ -17,9 +17,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
*/ */
#pragma once #pragma once
static const int32 AppVersion = 8038; static const int32 AppVersion = 8039;
static const wchar_t *AppVersionStr = L"0.8.38"; static const wchar_t *AppVersionStr = L"0.8.39";
static const bool DevChannel = false; static const bool DevChannel = true;
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
static const wchar_t *AppName = L"Telegram Desktop"; static const wchar_t *AppName = L"Telegram Desktop";

View File

@ -33,7 +33,7 @@ PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent),
_prevAvailable(false), _nextAvailable(false), _fullAvailable(false), _prevAvailable(false), _nextAvailable(false), _fullAvailable(false),
_over(OverNone), _down(OverNone), _downCoord(0), _downFrequency(AudioVoiceMsgFrequency), _downProgress(0.), _over(OverNone), _down(OverNone), _downCoord(0), _downFrequency(AudioVoiceMsgFrequency), _downProgress(0.),
_stateAnim(animFunc(this, &PlayerWidget::stateStep)), _stateAnim(animFunc(this, &PlayerWidget::stateStep)),
_index(-1), _history(0), _showPause(false), _position(0), _duration(0), _loaded(0), _index(-1), _history(0), _timeWidth(0), _repeat(false), _showPause(false), _position(0), _duration(0), _loaded(0),
a_progress(0., 0.), a_loadProgress(0., 0.), _progressAnim(animFunc(this, &PlayerWidget::progressStep)) { a_progress(0., 0.), a_loadProgress(0., 0.), _progressAnim(animFunc(this, &PlayerWidget::progressStep)) {
resize(st::wndMinWidth, st::playerHeight); resize(st::wndMinWidth, st::playerHeight);
setMouseTracking(true); setMouseTracking(true);
@ -108,6 +108,11 @@ void PlayerWidget::paintEvent(QPaintEvent *e) {
p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity); p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
p.drawSpriteCenterLeft(_fullRect, width(), st::playerFull); p.drawSpriteCenterLeft(_fullRect, width(), st::playerFull);
} }
if (checkr.intersects(_repeatRect)) {
float64 o = _stateHovers[OverRepeat];
p.setOpacity(_repeat ? 1. : (o * st::playerInactiveOpacity + (1. - o) * st::playerUnavailableOpacity));
p.drawSpriteCenterLeft(_repeatRect, width(), st::playerRepeat);
}
p.setOpacity(1.); p.setOpacity(1.);
p.setPen(st::playerTimeFg->p); p.setPen(st::playerTimeFg->p);
@ -185,6 +190,9 @@ void PlayerWidget::mousePressEvent(QMouseEvent *e) {
if (HistoryItem *item = App::histItemById(_song.msgId)) { if (HistoryItem *item = App::histItemById(_song.msgId)) {
App::main()->showMediaOverview(item->history()->peer, OverviewAudioDocuments); App::main()->showMediaOverview(item->history()->peer, OverviewAudioDocuments);
} }
} else if (_over == OverRepeat) {
_repeat = !_repeat;
updateOverRect(OverRepeat);
} }
} }
} }
@ -230,6 +238,7 @@ void PlayerWidget::updateOverRect(OverState state) {
case OverClose: rtlupdate(_closeRect); break; case OverClose: rtlupdate(_closeRect); break;
case OverVolume: rtlupdate(_volumeRect); break; case OverVolume: rtlupdate(_volumeRect); break;
case OverFull: rtlupdate(_fullRect); break; case OverFull: rtlupdate(_fullRect); break;
case OverRepeat: rtlupdate(_repeatRect); break;
case OverPlayback: rtlupdate(_playbackRect); break; case OverPlayback: rtlupdate(_playbackRect); break;
} }
} }
@ -365,6 +374,8 @@ void PlayerWidget::updateSelected() {
updateOverState(OverClose); updateOverState(OverClose);
} else if (_volumeRect.contains(pos)) { } else if (_volumeRect.contains(pos)) {
updateOverState(OverVolume); updateOverState(OverVolume);
} else if (_repeatRect.contains(pos)) {
updateOverState(OverRepeat);
} else if (_duration && _playbackRect.contains(pos)) { } else if (_duration && _playbackRect.contains(pos)) {
updateOverState(OverPlayback); updateOverState(OverPlayback);
} else if (_fullAvailable && inInfo) { } else if (_fullAvailable && inInfo) {
@ -446,7 +457,7 @@ void PlayerWidget::playPausePressed() {
} }
void PlayerWidget::prevPressed() { void PlayerWidget::prevPressed() {
if (isHidden() || !_prevAvailable) return; if (isHidden()) return;
const History::MediaOverview *o = _history ? &_history->_overview[OverviewAudioDocuments] : 0; const History::MediaOverview *o = _history ? &_history->_overview[OverviewAudioDocuments] : 0;
if (audioPlayer() && o && _index > 0 && _index <= o->size() && !o->isEmpty()) { if (audioPlayer() && o && _index > 0 && _index <= o->size() && !o->isEmpty()) {
@ -455,7 +466,7 @@ void PlayerWidget::prevPressed() {
} }
void PlayerWidget::nextPressed() { void PlayerWidget::nextPressed() {
if (isHidden() || !_nextAvailable) return; if (isHidden()) return;
const History::MediaOverview *o = _history ? &_history->_overview[OverviewAudioDocuments] : 0; const History::MediaOverview *o = _history ? &_history->_overview[OverviewAudioDocuments] : 0;
if (audioPlayer() && o && _index >= 0 && _index < o->size() - 1) { if (audioPlayer() && o && _index >= 0 && _index < o->size() - 1) {
@ -480,10 +491,11 @@ void PlayerWidget::resizeEvent(QResizeEvent *e) {
_closeRect = QRect(width() - st::playerSkip / 2 - st::playerClose.pxWidth() - st::playerSkip, ct, st::playerClose.pxWidth() + st::playerSkip, ch); _closeRect = QRect(width() - st::playerSkip / 2 - st::playerClose.pxWidth() - st::playerSkip, ct, st::playerClose.pxWidth() + st::playerSkip, ch);
_volumeRect = QRect(_closeRect.x() - st::playerVolume.pxWidth() - st::playerSkip, ct, st::playerVolume.pxWidth() + st::playerSkip, ch); _volumeRect = QRect(_closeRect.x() - st::playerVolume.pxWidth() - st::playerSkip, ct, st::playerVolume.pxWidth() + st::playerSkip, ch);
_fullRect = _fullAvailable ? QRect(_volumeRect.x() - st::playerFull.pxWidth() - st::playerSkip, ct, st::playerFull.pxWidth() + st::playerSkip, ch) : QRect(); _repeatRect = QRect(_volumeRect.x() - st::playerRepeat.pxWidth() - st::playerSkip, ct, st::playerRepeat.pxWidth() + st::playerSkip, ch);
_fullRect = _fullAvailable ? QRect(_repeatRect.x() - st::playerFull.pxWidth() - st::playerSkip, ct, st::playerFull.pxWidth() + st::playerSkip, ch) : QRect();
int32 infoLeft = (_fullAvailable ? (_nextRect.x() + _nextRect.width()) : (_playRect.x() + _playRect.width())); int32 infoLeft = (_fullAvailable ? (_nextRect.x() + _nextRect.width()) : (_playRect.x() + _playRect.width()));
_infoRect = QRect(infoLeft + st::playerSkip / 2, 0, (_fullAvailable ? _fullRect.x() : _volumeRect.x()) - infoLeft - st::playerSkip, availh); _infoRect = QRect(infoLeft + st::playerSkip / 2, 0, (_fullAvailable ? _fullRect.x() : _repeatRect.x()) - infoLeft - st::playerSkip, availh);
update(); update();
} }
@ -600,9 +612,10 @@ void PlayerWidget::updateState(SongMsgId playing, AudioPlayerState playingState,
} }
if (wasPlaying && playingState == AudioPlayerStoppedAtEnd) { if (wasPlaying && playingState == AudioPlayerStoppedAtEnd) {
const History::MediaOverview *o = _history ? &_history->_overview[OverviewAudioDocuments] : 0; if (_repeat) {
if (audioPlayer() && o && _index >= 0 && _index < o->size() - 1) { startPlay(_song.msgId);
startPlay(o->at(_index + 1)); } else {
nextPressed();
} }
} }

View File

@ -65,6 +65,7 @@ private:
OverClose, OverClose,
OverVolume, OverVolume,
OverFull, OverFull,
OverRepeat,
OverPlayback, OverPlayback,
OverStateCount OverStateCount
@ -97,8 +98,9 @@ private:
int32 _index; int32 _index;
History *_history; History *_history;
QRect _playRect, _prevRect, _nextRect, _playbackRect; QRect _playRect, _prevRect, _nextRect, _playbackRect;
QRect _closeRect, _volumeRect, _fullRect, _infoRect; QRect _closeRect, _volumeRect, _fullRect, _repeatRect, _infoRect;
int32 _timeWidth; int32 _timeWidth;
bool _repeat;
QString _time; QString _time;
Text _name; Text _name;
bool _showPause; bool _showPause;

View File

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.8.38</string> <string>0.8.39</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

Binary file not shown.

View File

@ -1711,7 +1711,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.8.38; CURRENT_PROJECT_VERSION = 0.8.39;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -1729,7 +1729,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.8.38; CURRENT_PROJECT_VERSION = 0.8.39;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = fast; GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
@ -1755,10 +1755,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.8.38; CURRENT_PROJECT_VERSION = 0.8.39;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 0.8; DYLIB_COMPATIBILITY_VERSION = 0.8;
DYLIB_CURRENT_VERSION = 0.8.38; DYLIB_CURRENT_VERSION = 0.8.39;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -1898,10 +1898,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.8.38; CURRENT_PROJECT_VERSION = 0.8.39;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 0.8; DYLIB_COMPATIBILITY_VERSION = 0.8;
DYLIB_CURRENT_VERSION = 0.8.38; DYLIB_CURRENT_VERSION = 0.8.39;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;

View File

@ -1,2 +1,2 @@
echo 0.8 8038 0.8.38 0 echo 0.8 8039 0.8.39 1
# AppVersionStrMajor AppVersion AppVersionStr DevChannel # AppVersionStrMajor AppVersion AppVersionStr DevChannel