diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-30 10:56:11 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-30 10:56:11 +0100 |
commit | ac1d5566d30b107fdea934ac704720242ef59a7c (patch) | |
tree | ed46cdc2ebc66612ade9bbac5f41097698cef042 /src/audiocacheeventhandler.cc | |
parent | aa635eb8da9804488513d1f3d422e4810e611bb8 (diff) | |
parent | 22715c84cc861ba6ce7e9caa5d214bb3f006679d (diff) |
Merge branch 'diskstreaming_review_chaot' into diskstreaming
Diffstat (limited to 'src/audiocacheeventhandler.cc')
-rw-r--r-- | src/audiocacheeventhandler.cc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/audiocacheeventhandler.cc b/src/audiocacheeventhandler.cc index 6ec68b5..788cac6 100644 --- a/src/audiocacheeventhandler.cc +++ b/src/audiocacheeventhandler.cc @@ -41,7 +41,7 @@ enum class EventType { class CacheEvent { public: - EventType eventType; + EventType event_type; // For close event: cacheid_t id; @@ -105,8 +105,7 @@ void AudioCacheEventHandler::setThreaded(bool threaded) { start(); } - - if(!threaded && running) + else if(!threaded && running) { stop(); } @@ -135,7 +134,7 @@ void AudioCacheEventHandler::pushLoadNextEvent(AudioCacheFile* afile, volatile bool* ready) { CacheEvent cache_event; - cache_event.eventType = EventType::LoadNext; + cache_event.event_type = EventType::LoadNext; cache_event.pos = pos; cache_event.afile = afile; @@ -154,7 +153,7 @@ void AudioCacheEventHandler::pushLoadNextEvent(AudioCacheFile* afile, void AudioCacheEventHandler::pushCloseEvent(cacheid_t id) { CacheEvent cache_event; - cache_event.eventType = EventType::Close; + cache_event.event_type = EventType::Close; cache_event.id = id; pushEvent(cache_event); @@ -172,17 +171,17 @@ void AudioCacheEventHandler::setChunkSize(size_t chunksize) return; } - DEBUG(cache, "1)\n"); + DEBUG(cache, "setChunkSize 1\n"); // Remove all events from event queue. clearEvents(); - DEBUG(cache, "2)\n"); + DEBUG(cache, "setChunkSize 2\n"); // Skip all active cacheids and make their buffers point at nodata. id_manager.disableActive(); - DEBUG(cache, "3)\n"); + DEBUG(cache, "setChunkSize 3\n"); this->chunksize = chunksize; } @@ -203,7 +202,7 @@ void AudioCacheEventHandler::clearEvents() // Iterate all events ignoring load events and handling close events. for(auto& event : eventqueue) { - if(event.eventType == EventType::Close) + if(event.event_type == EventType::Close) { handleCloseCache(event.id); // This method does not lock. } @@ -224,21 +223,21 @@ void AudioCacheEventHandler::handleCloseEvent(CacheEvent& cache_event) handleCloseCache(cache_event.id); } -void AudioCacheEventHandler::handleCloseCache(cacheid_t cacheid) +void AudioCacheEventHandler::handleCloseCache(cacheid_t id) { - auto& cache = id_manager.getCache(cacheid); + auto& cache = id_manager.getCache(id); files.releaseFile(cache.afile->getFilename()); delete[] cache.front; delete[] cache.back; - id_manager.releaseID(cacheid); + id_manager.releaseID(id); } void AudioCacheEventHandler::handleEvent(CacheEvent& cache_event) { - switch(cache_event.eventType) + switch(cache_event.event_type) { case EventType::LoadNext: handleLoadNextEvent(cache_event); @@ -291,11 +290,11 @@ void AudioCacheEventHandler::pushEvent(CacheEvent& cache_event) bool found = false; - if(cache_event.eventType == EventType::LoadNext) + if(cache_event.event_type == EventType::LoadNext) { for(auto& queued_event : eventqueue) { - if((queued_event.eventType == EventType::LoadNext) && + if((queued_event.event_type == EventType::LoadNext) && (cache_event.afile->getFilename() == queued_event.afile->getFilename()) && (cache_event.pos == queued_event.pos)) |