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
|
@ -1341,6 +1341,15 @@ void AudioPlayerLoaders::onStart(const AudioMsgId &audio, qint64 position) {
|
||||||
_audio = AudioMsgId();
|
_audio = AudioMsgId();
|
||||||
delete _audioLoader;
|
delete _audioLoader;
|
||||||
_audioLoader = 0;
|
_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);
|
loadData(OverviewAudios, static_cast<const void*>(&audio), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1348,6 +1357,15 @@ void AudioPlayerLoaders::onStart(const SongMsgId &song, qint64 position) {
|
||||||
_song = SongMsgId();
|
_song = SongMsgId();
|
||||||
delete _songLoader;
|
delete _songLoader;
|
||||||
_songLoader = 0;
|
_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);
|
loadData(OverviewDocuments, static_cast<const void*>(&song), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1404,15 +1422,25 @@ void AudioPlayerLoaders::loadData(MediaOverviewType type, const void *objId, qin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool started = (err == SetupNoErrorStarted), finished = false;
|
bool started = (err == SetupNoErrorStarted), finished = false, errAtStart = started;
|
||||||
|
|
||||||
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)) {
|
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;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
errAtStart = false;
|
||||||
|
|
||||||
QMutexLocker lock(&playerMutex);
|
QMutexLocker lock(&playerMutex);
|
||||||
if (!checkLoader(type)) {
|
if (!checkLoader(type)) {
|
||||||
|
|
|
@ -1575,6 +1575,7 @@ void MainWidget::audioLoadRetry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
||||||
|
bool songPlayActivated = false;
|
||||||
DocumentData *document = App::document(loader->objId());
|
DocumentData *document = App::document(loader->objId());
|
||||||
if (document->loader) {
|
if (document->loader) {
|
||||||
if (document->loader->done()) {
|
if (document->loader->done()) {
|
||||||
|
@ -1595,6 +1596,8 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
||||||
audioPlayer()->play(song);
|
audioPlayer()->play(song);
|
||||||
if (App::main()) App::main()->documentPlayProgress(song);
|
if (App::main()) App::main()->documentPlayProgress(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
songPlayActivated = true;
|
||||||
} else if(document->openOnSave > 0 && document->size < MediaViewImageSizeLimit) {
|
} else if(document->openOnSave > 0 && document->size < MediaViewImageSizeLimit) {
|
||||||
QImageReader reader(already);
|
QImageReader reader(already);
|
||||||
if (reader.canRead()) {
|
if (reader.canRead()) {
|
||||||
|
@ -1628,7 +1631,7 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
||||||
}
|
}
|
||||||
App::wnd()->documentUpdated(document);
|
App::wnd()->documentUpdated(document);
|
||||||
|
|
||||||
if (audioPlayer()) {
|
if (!songPlayActivated && audioPlayer()) {
|
||||||
SongMsgId playing;
|
SongMsgId playing;
|
||||||
AudioPlayerState playingState = AudioPlayerStopped;
|
AudioPlayerState playingState = AudioPlayerStopped;
|
||||||
int64 playingPosition = 0, playingDuration = 0;
|
int64 playingPosition = 0, playingDuration = 0;
|
||||||
|
|
Loading…
Reference in New Issue