当前位置: 首页>>代码示例>>C++>>正文


C++ AudioPlayer::dataForType方法代码示例

本文整理汇总了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);
}
开发者ID:AlexR1712,项目名称:tdesktop,代码行数:16,代码来源:media_audio_loaders.cpp

示例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;
		}
	}
}
开发者ID:AlexR1712,项目名称:tdesktop,代码行数:18,代码来源:media_audio_loaders.cpp

示例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;
}
开发者ID:AlexR1712,项目名称:tdesktop,代码行数:21,代码来源:media_audio_loaders.cpp

示例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;
}
开发者ID:AlexR1712,项目名称:tdesktop,代码行数:71,代码来源:media_audio_loaders.cpp


注:本文中的AudioPlayer::dataForType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。