本文整理汇总了C++中AudioPlayer::dataForType方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioPlayer::dataForType方法的具体用法?C++ AudioPlayer::dataForType怎么用?C++ AudioPlayer::dataForType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioPlayer
的用法示例。
在下文中一共展示了AudioPlayer::dataForType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onStart
void AudioPlayerLoaders::onStart(const AudioMsgId &audio, qint64 position) {
auto type = audio.type();
clear(type);
{
QMutexLocker lock(internal::audioPlayerMutex());
AudioPlayer *voice = audioPlayer();
if (!voice) return;
auto data = voice->dataForType(type);
if (!data) return;
data->loading = true;
}
loadData(audio, position);
}
示例2: onCancel
void AudioPlayerLoaders::onCancel(const AudioMsgId &audio) {
switch (audio.type()) {
case AudioMsgId::Type::Voice: if (_audio == audio) clear(audio.type()); break;
case AudioMsgId::Type::Song: if (_song == audio) clear(audio.type()); break;
case AudioMsgId::Type::Video: if (_video == audio) clear(audio.type()); break;
}
QMutexLocker lock(internal::audioPlayerMutex());
AudioPlayer *voice = audioPlayer();
if (!voice) return;
for (int i = 0; i < AudioSimultaneousLimit; ++i) {
auto data = voice->dataForType(audio.type(), i);
if (data->audio == audio) {
data->loading = false;
}
}
}
示例3: audioPlayer
AudioPlayer::AudioMsg *AudioPlayerLoaders::checkLoader(AudioMsgId::Type type) {
AudioPlayer *voice = audioPlayer();
if (!voice) return 0;
auto data = voice->dataForType(type);
bool isGoodId = false;
AudioPlayerLoader *l = nullptr;
switch (type) {
case AudioMsgId::Type::Voice: l = _audioLoader.get(); isGoodId = (data->audio == _audio); break;
case AudioMsgId::Type::Song: l = _songLoader.get(); isGoodId = (data->audio == _song); break;
case AudioMsgId::Type::Video: l = _videoLoader.get(); isGoodId = (data->audio == _video); break;
}
if (!l || !data) return nullptr;
if (!isGoodId || !data->loading || !l->check(data->file, data->data)) {
LOG(("Audio Error: playing changed while loading"));
return nullptr;
}
return data;
}
示例4: lock
AudioPlayerLoader *AudioPlayerLoaders::setupLoader(const AudioMsgId &audio, SetupError &err, qint64 &position) {
err = SetupErrorAtStart;
QMutexLocker lock(internal::audioPlayerMutex());
AudioPlayer *voice = audioPlayer();
if (!voice) return nullptr;
auto data = voice->dataForType(audio.type());
if (!data || data->audio != audio || !data->loading) {
emit error(audio);
LOG(("Audio Error: trying to load part of audio, that is not current at the moment"));
err = SetupErrorNotPlaying;
return nullptr;
}
bool isGoodId = false;
AudioPlayerLoader *l = nullptr;
switch (audio.type()) {
case AudioMsgId::Type::Voice: l = _audioLoader.get(); isGoodId = (_audio == audio); break;
case AudioMsgId::Type::Song: l = _songLoader.get(); isGoodId = (_song == audio); break;
case AudioMsgId::Type::Video: l = _videoLoader.get(); isGoodId = (_video == audio); break;
}
if (l && (!isGoodId || !l->check(data->file, data->data))) {
clear(audio.type());
l = nullptr;
}
if (!l) {
std_::unique_ptr<AudioPlayerLoader> *loader = nullptr;
switch (audio.type()) {
case AudioMsgId::Type::Voice: _audio = audio; loader = &_audioLoader; break;
case AudioMsgId::Type::Song: _song = audio; loader = &_songLoader; break;
case AudioMsgId::Type::Video: _video = audio; break;
}
if (audio.type() == AudioMsgId::Type::Video) {
if (!data->videoData) {
data->playbackState.state = AudioPlayerStoppedAtError;
emit error(audio);
LOG(("Audio Error: video sound data not ready"));
return nullptr;
}
_videoLoader = std_::make_unique<ChildFFMpegLoader>(data->videoPlayId, std_::move(data->videoData));
l = _videoLoader.get();
} else {
*loader = std_::make_unique<FFMpegLoader>(data->file, data->data);
l = loader->get();
}
if (!l->open(position)) {
data->playbackState.state = AudioPlayerStoppedAtStart;
return nullptr;
}
int64 duration = l->duration();
if (duration <= 0) {
data->playbackState.state = AudioPlayerStoppedAtStart;
return nullptr;
}
data->playbackState.duration = duration;
data->playbackState.frequency = l->frequency();
if (!data->playbackState.frequency) data->playbackState.frequency = AudioVoiceMsgFrequency;
err = SetupNoErrorStarted;
} else {
if (!data->skipEnd) {
err = SetupErrorLoadedFull;
LOG(("Audio Error: trying to load part of audio, that is already loaded to the end"));
return nullptr;
}
}
return l;
}