本文整理汇总了C++中TrackId::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackId::isValid方法的具体用法?C++ TrackId::isValid怎么用?C++ TrackId::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackId
的用法示例。
在下文中一共展示了TrackId::isValid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTrackId
TrackRef GlobalTrackCache::initTrackId(
const TrackPointer& strongPtr,
TrackRef trackRef,
TrackId trackId) {
DEBUG_ASSERT(strongPtr);
DEBUG_ASSERT(!trackRef.getId().isValid());
DEBUG_ASSERT(trackId.isValid());
TrackRef trackRefWithId(trackRef, trackId);
EvictAndSaveFunctor* pDel = std::get_deleter<EvictAndSaveFunctor>(strongPtr);
DEBUG_ASSERT(pDel);
// Insert item by id
DEBUG_ASSERT(m_tracksById.find(trackId) == m_tracksById.end());
m_tracksById.insert(std::make_pair(
trackId,
pDel->getCacheEntryPointer()));
strongPtr->initId(trackId);
DEBUG_ASSERT(createTrackRef(*strongPtr) == trackRefWithId);
DEBUG_ASSERT(m_tracksById.find(trackId) != m_tracksById.end());
return trackRefWithId;
}
示例2: isDisabledOrLoadStoredSuccess
bool AnalyzerWaveform::isDisabledOrLoadStoredSuccess(TrackPointer tio) const {
ConstWaveformPointer pTrackWaveform = tio->getWaveform();
ConstWaveformPointer pTrackWaveformSummary = tio->getWaveformSummary();
ConstWaveformPointer pLoadedTrackWaveform;
ConstWaveformPointer pLoadedTrackWaveformSummary;
TrackId trackId = tio->getId();
bool missingWaveform = pTrackWaveform.isNull();
bool missingWavesummary = pTrackWaveformSummary.isNull();
if (trackId.isValid() && (missingWaveform || missingWavesummary)) {
QList<AnalysisDao::AnalysisInfo> analyses =
m_pAnalysisDao->getAnalysesForTrack(trackId);
QListIterator<AnalysisDao::AnalysisInfo> it(analyses);
while (it.hasNext()) {
const AnalysisDao::AnalysisInfo& analysis = it.next();
WaveformFactory::VersionClass vc;
if (analysis.type == AnalysisDao::TYPE_WAVEFORM) {
vc = WaveformFactory::waveformVersionToVersionClass(analysis.version);
if (missingWaveform && vc == WaveformFactory::VC_USE) {
pLoadedTrackWaveform = ConstWaveformPointer(
WaveformFactory::loadWaveformFromAnalysis(analysis));
missingWaveform = false;
} else if (vc != WaveformFactory::VC_KEEP) {
// remove all other Analysis except that one we should keep
m_pAnalysisDao->deleteAnalysis(analysis.analysisId);
}
} if (analysis.type == AnalysisDao::TYPE_WAVESUMMARY) {
vc = WaveformFactory::waveformSummaryVersionToVersionClass(analysis.version);
if (missingWavesummary && vc == WaveformFactory::VC_USE) {
pLoadedTrackWaveformSummary = ConstWaveformPointer(
WaveformFactory::loadWaveformFromAnalysis(analysis));
missingWavesummary = false;
} else if (vc != WaveformFactory::VC_KEEP) {
// remove all other Analysis except that one we should keep
m_pAnalysisDao->deleteAnalysis(analysis.analysisId);
}
}
}
}
// If we don't need to calculate the waveform/wavesummary, skip.
if (!missingWaveform && !missingWavesummary) {
kLogger.debug() << "loadStored - Stored waveform loaded";
if (pLoadedTrackWaveform) {
tio->setWaveform(pLoadedTrackWaveform);
}
if (pLoadedTrackWaveformSummary) {
tio->setWaveformSummary(pLoadedTrackWaveformSummary);
}
return true;
}
return false;
}
示例3: pTrack
TEST_F(AutoDJProcessorTest, EnabledSuccess_PlayingDeck2_TrackLoadFailed) {
TrackId testId = addTrackToCollection(kTrackLocationTest);
ASSERT_TRUE(testId.isValid());
// Pretend a track is playing on deck 2.
TrackPointer pTrack(newTestTrack(nextTrackId(testId)));
// Load track and mark it playing.
deck2.slotLoadTrack(pTrack, true);
// Indicate the track loaded successfully.
deck2.fakeTrackLoadedEvent(pTrack);
// Arbitrary to check that it was unchanged.
master.crossfader.set(0.2447);
PlaylistTableModel* pAutoDJTableModel = pProcessor->getTableModel();
// The first track will fail to load and the second will succeed.
pAutoDJTableModel->appendTrack(testId);
pAutoDJTableModel->appendTrack(testId);
EXPECT_CALL(*pProcessor, emitAutoDJStateChanged(AutoDJProcessor::ADJ_IDLE));
EXPECT_CALL(*pProcessor, emitLoadTrackToPlayer(_, QString("[Channel1]"), false));
AutoDJProcessor::AutoDJError err = pProcessor->toggleAutoDJ(true);
EXPECT_EQ(AutoDJProcessor::ADJ_OK, err);
EXPECT_EQ(AutoDJProcessor::ADJ_IDLE, pProcessor->getState());
// No change to the crossfader or play states.
EXPECT_DOUBLE_EQ(1, master.crossfader.get());
EXPECT_DOUBLE_EQ(0.0, deck1.play.get());
EXPECT_DOUBLE_EQ(1.0, deck2.play.get());
// After the load failed signal we will receive another track load signal
// for deck 1.
EXPECT_CALL(*pProcessor, emitLoadTrackToPlayer(_, QString("[Channel1]"), false));
// Pretend the track load fails.
deck1.slotLoadTrack(pTrack, false);
deck1.fakeTrackLoadFailedEvent(pTrack);
// No change to the mode, crossfader, or play states.
EXPECT_EQ(AutoDJProcessor::ADJ_IDLE, pProcessor->getState());
EXPECT_DOUBLE_EQ(1, master.crossfader.get());
EXPECT_DOUBLE_EQ(0.0, deck1.play.get());
EXPECT_DOUBLE_EQ(1.0, deck2.play.get());
// Pretend the track load succeeds.
deck1.slotLoadTrack(pTrack, false);
deck1.fakeTrackLoadedEvent(pTrack);
// No change to the mode, crossfader, or play states.
EXPECT_EQ(AutoDJProcessor::ADJ_IDLE, pProcessor->getState());
EXPECT_DOUBLE_EQ(1.0, master.crossfader.get());
EXPECT_DOUBLE_EQ(0.0, deck1.play.get());
EXPECT_DOUBLE_EQ(1.0, deck2.play.get());
}
示例4: query
QList<AnalysisDao::AnalysisInfo> AnalysisDao::getAnalysesForTrack(TrackId trackId) {
if (!m_db.isOpen() || !trackId.isValid()) {
return QList<AnalysisInfo>();
}
QSqlQuery query(m_db);
query.prepare(QString(
"SELECT id, type, description, version, data_checksum FROM %1 "
"WHERE track_id=:trackId").arg(s_analysisTableName));
query.bindValue(":trackId", trackId.toVariant());
return loadAnalysesFromQuery(trackId, &query);
}
示例5: addTrackToCollection
TEST_F(AutoDJProcessorTest, EnabledSuccess_DecksStopped) {
TrackId testId = addTrackToCollection(kTrackLocationTest);
ASSERT_TRUE(testId.isValid());
PlaylistTableModel* pAutoDJTableModel = pProcessor->getTableModel();
// Need two tracks -- one to be loaded in the left deck and one to load in
// the right deck.
pAutoDJTableModel->appendTrack(testId);
pAutoDJTableModel->appendTrack(testId);
// Expect that we switch into ADJ_ENABLE_P1LOADED first.
EXPECT_CALL(*pProcessor, emitAutoDJStateChanged(AutoDJProcessor::ADJ_ENABLE_P1LOADED));
// Expect that we get a load-and-play signal for [Channel1].
EXPECT_CALL(*pProcessor, emitLoadTrackToPlayer(_, QString("[Channel1]"), true));
AutoDJProcessor::AutoDJError err = pProcessor->toggleAutoDJ(true);
EXPECT_EQ(AutoDJProcessor::ADJ_OK, err);
EXPECT_EQ(AutoDJProcessor::ADJ_ENABLE_P1LOADED, pProcessor->getState());
// Sets crossfader left and deck 1 playing.
EXPECT_DOUBLE_EQ(-1.0, master.crossfader.get());
// ADJ_ENABLE_P1LOADED logic does not set play directly. It waits for the
// engine to load the track and set the deck playing.
EXPECT_DOUBLE_EQ(0.0, deck1.play.get());
EXPECT_DOUBLE_EQ(0.0, deck2.play.get());
// Expect that we transition to ADJ_IDLE.
EXPECT_CALL(*pProcessor, emitAutoDJStateChanged(AutoDJProcessor::ADJ_IDLE));
// Expect that we will receive a load call for [Channel2] after we get the
// first playposition update from deck 1.
EXPECT_CALL(*pProcessor, emitLoadTrackToPlayer(_, QString("[Channel2]"), false));
// Pretend a track loaded successfully and that it is now playing. This
// triggers a call to AutoDJProcessor::playerPlayChanged and
// AutoDJProcessor::playerPlaypositionChanged. We should switch to ADJ_IDLE
// and queue a track to deck 2.
// Load the track and mark it playing (as the loadTrackToPlayer signal would
// have connected to this eventually).
TrackPointer pTrack = collection()->getTrackDAO().getTrack(testId, false);
deck1.slotLoadTrack(pTrack, true);
// Signal that the request to load pTrack succeeded.
deck1.fakeTrackLoadedEvent(pTrack);
// Pretend the engine moved forward on the deck.
deck1.playposition.set(0.1);
// By now we will have transitioned to idle and requested a load to deck 2.
EXPECT_EQ(AutoDJProcessor::ADJ_IDLE, pProcessor->getState());
}
示例6: initTrackIdAndUnlockCache
void GlobalTrackCacheResolver::initTrackIdAndUnlockCache(TrackId trackId) {
DEBUG_ASSERT(m_pInstance);
DEBUG_ASSERT(GlobalTrackCacheLookupResult::NONE != m_lookupResult);
DEBUG_ASSERT(m_strongPtr);
DEBUG_ASSERT(trackId.isValid());
if (m_trackRef.getId().isValid()) {
// Ignore initializing the same id twice
DEBUG_ASSERT(m_trackRef.getId() == trackId);
} else {
m_trackRef = m_pInstance->initTrackId(
m_strongPtr,
m_trackRef,
trackId);
DEBUG_ASSERT(m_trackRef.getId() == trackId);
}
unlockCache();
DEBUG_ASSERT(m_trackRef == createTrackRef(*m_strongPtr));
}
示例7: deleteAnalysesForTrack
bool AnalysisDao::deleteAnalysesForTrack(TrackId trackId) {
if (!trackId.isValid()) {
return false;
}
QSqlQuery query(m_db);
query.prepare(QString(
"SELECT id FROM %1 where track_id = :track_id").arg(s_analysisTableName));
query.bindValue(":track_id", trackId.toVariant());
if (!query.exec()) {
LOG_FAILED_QUERY(query) << "couldn't delete analyses for track" << trackId;
return false;
}
QList<int> analysesToDelete;
const int idColumn = query.record().indexOf("id");
while (query.next()) {
analysesToDelete.append(
query.value(idColumn).toInt());
}
foreach (int analysisId, analysesToDelete) {
deleteAnalysis(analysisId);
}
示例8: resolve
void GlobalTrackCache::resolve(
GlobalTrackCacheResolver* /*in/out*/ pCacheResolver,
QFileInfo /*in*/ fileInfo,
TrackId trackId,
SecurityTokenPointer pSecurityToken) {
DEBUG_ASSERT(pCacheResolver);
// Primary lookup by id (if available)
if (trackId.isValid()) {
if (debugLogEnabled()) {
kLogger.debug()
<< "Resolving track by id"
<< trackId;
}
auto strongPtr = lookupById(trackId);
if (strongPtr) {
if (debugLogEnabled()) {
kLogger.debug()
<< "Cache hit - found track by id"
<< trackId
<< strongPtr.get();
}
TrackRef trackRef = createTrackRef(*strongPtr);
pCacheResolver->initLookupResult(
GlobalTrackCacheLookupResult::HIT,
std::move(strongPtr),
std::move(trackRef));
return;
}
}
// Secondary lookup by canonical location
// The TrackRef is constructed now after the lookup by ID failed to
// avoid calculating the canonical file path if it is not needed.
TrackRef trackRef = TrackRef::fromFileInfo(fileInfo, trackId);
if (trackRef.hasCanonicalLocation()) {
if (debugLogEnabled()) {
kLogger.debug()
<< "Resolving track by canonical location"
<< trackRef.getCanonicalLocation();
}
auto strongPtr = lookupByRef(trackRef);
if (strongPtr) {
// Cache hit
if (debugLogEnabled()) {
kLogger.debug()
<< "Cache hit - found track by canonical location"
<< trackRef.getCanonicalLocation()
<< strongPtr.get();
}
pCacheResolver->initLookupResult(
GlobalTrackCacheLookupResult::HIT,
std::move(strongPtr),
std::move(trackRef));
return;
}
}
if (!m_pSaver) {
// Do not allocate any new tracks once the cache
// has been deactivated
DEBUG_ASSERT(isEmpty());
kLogger.warning()
<< "Cache miss - caching has already been deactivated"
<< trackRef;
return;
}
if (debugLogEnabled()) {
kLogger.debug()
<< "Cache miss - allocating track"
<< trackRef;
}
auto deletingPtr = std::unique_ptr<Track, void (&)(Track*)>(
new Track(
std::move(fileInfo),
std::move(pSecurityToken),
std::move(trackId)),
deleteTrack);
// Track objects live together with the cache on the main thread
// and will be deleted later within the event loop. But this
// function might be called from any thread, even from worker
// threads without an event loop. We need to move the newly
// created object to the target thread.
deletingPtr->moveToThread(QApplication::instance()->thread());
auto cacheEntryPtr = std::make_shared<GlobalTrackCacheEntry>(
std::move(deletingPtr));
auto savingPtr = TrackPointer(
cacheEntryPtr->getPlainPtr(),
EvictAndSaveFunctor(cacheEntryPtr));
cacheEntryPtr->setSavingWeakPtr(savingPtr);
if (debugLogEnabled()) {
kLogger.debug()
<< "Cache miss - inserting new track into cache"
<< trackRef
<< deletingPtr.get();
}
if (trackRef.hasId()) {
// Insert item by id
DEBUG_ASSERT(m_tracksById.find(
trackRef.getId()) == m_tracksById.end());
//.........这里部分代码省略.........