mirror of https://github.com/procxx/kepka.git
fixed double play of audio after download complete
This commit is contained in:
parent
5595570dfe
commit
4f7f569ddd
Telegram/SourceFiles
|
@ -1341,6 +1341,15 @@ void AudioPlayerLoaders::onStart(const AudioMsgId &audio, qint64 position) {
|
|||
_audio = AudioMsgId();
|
||||
delete _audioLoader;
|
||||
_audioLoader = 0;
|
||||
|
||||
{
|
||||
QMutexLocker lock(&playerMutex);
|
||||
AudioPlayer *voice = audioPlayer();
|
||||
if (!voice) return;
|
||||
|
||||
voice->_audioData[voice->_audioCurrent].loading = true;
|
||||
}
|
||||
|
||||
loadData(OverviewAudios, static_cast<const void*>(&audio), position);
|
||||
}
|
||||
|
||||
|
@ -1348,6 +1357,15 @@ void AudioPlayerLoaders::onStart(const SongMsgId &song, qint64 position) {
|
|||
_song = SongMsgId();
|
||||
delete _songLoader;
|
||||
_songLoader = 0;
|
||||
|
||||
{
|
||||
QMutexLocker lock(&playerMutex);
|
||||
AudioPlayer *voice = audioPlayer();
|
||||
if (!voice) return;
|
||||
|
||||
voice->_songData[voice->_songCurrent].loading = true;
|
||||
}
|
||||
|
||||
loadData(OverviewDocuments, static_cast<const void*>(&song), position);
|
||||
}
|
||||
|
||||
|
@ -1404,15 +1422,25 @@ void AudioPlayerLoaders::loadData(MediaOverviewType type, const void *objId, qin
|
|||
return;
|
||||
}
|
||||
|
||||
bool started = (err == SetupNoErrorStarted), finished = false;
|
||||
bool started = (err == SetupNoErrorStarted), finished = false, errAtStart = started;
|
||||
|
||||
QByteArray result;
|
||||
int64 samplesAdded = 0, frequency = l->frequency(), format = l->format();
|
||||
while (result.size() < AudioVoiceMsgBufferSize) {
|
||||
if (!l->readMore(result, samplesAdded)) {
|
||||
if (errAtStart) {
|
||||
{
|
||||
QMutexLocker lock(&playerMutex);
|
||||
AudioPlayer::Msg *m = checkLoader(type);
|
||||
if (m) m->state = AudioPlayerStoppedAtStart;
|
||||
}
|
||||
emitError(type);
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
errAtStart = false;
|
||||
|
||||
QMutexLocker lock(&playerMutex);
|
||||
if (!checkLoader(type)) {
|
||||
|
|
|
@ -1575,6 +1575,7 @@ void MainWidget::audioLoadRetry() {
|
|||
}
|
||||
|
||||
void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
||||
bool songPlayActivated = false;
|
||||
DocumentData *document = App::document(loader->objId());
|
||||
if (document->loader) {
|
||||
if (document->loader->done()) {
|
||||
|
@ -1595,6 +1596,8 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
|||
audioPlayer()->play(song);
|
||||
if (App::main()) App::main()->documentPlayProgress(song);
|
||||
}
|
||||
|
||||
songPlayActivated = true;
|
||||
} else if(document->openOnSave > 0 && document->size < MediaViewImageSizeLimit) {
|
||||
QImageReader reader(already);
|
||||
if (reader.canRead()) {
|
||||
|
@ -1628,7 +1631,7 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
|||
}
|
||||
App::wnd()->documentUpdated(document);
|
||||
|
||||
if (audioPlayer()) {
|
||||
if (!songPlayActivated && audioPlayer()) {
|
||||
SongMsgId playing;
|
||||
AudioPlayerState playingState = AudioPlayerStopped;
|
||||
int64 playingPosition = 0, playingDuration = 0;
|
||||
|
|
Loading…
Reference in New Issue