From 9ebd9aa0c3429f896e6c41f279b570ba36aec674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Fri, 29 Jan 2016 17:28:32 +0100 Subject: Glocke suggestions --- src/audiocache.cc | 2 +- src/audiocacheeventhandler.cc | 23 +++++++++-------------- src/audiocacheeventhandler.h | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/audiocache.cc b/src/audiocache.cc index 7856f4a..86052c7 100644 --- a/src/audiocache.cc +++ b/src/audiocache.cc @@ -272,7 +272,7 @@ void AudioCache::setAsyncMode(bool async) bool AudioCache::asyncMode() const { - return event_handler.getThreaded(); + return event_handler.isThreaded(); } size_t AudioCache::getNumberOfUnderruns() const diff --git a/src/audiocacheeventhandler.cc b/src/audiocacheeventhandler.cc index 7322785..6ec68b5 100644 --- a/src/audiocacheeventhandler.cc +++ b/src/audiocacheeventhandler.cc @@ -53,9 +53,7 @@ public: }; AudioCacheEventHandler::AudioCacheEventHandler(AudioCacheIDManager& id_manager) - // Hack to be able to forward declare CacheEvent: - : eventqueue(new std::list()) - , id_manager(id_manager) + : id_manager(id_manager) { } @@ -69,9 +67,6 @@ AudioCacheEventHandler::~AudioCacheEventHandler() { handleCloseCache(id); } - - // Hack to be able to forward declare CacheEvent: - delete eventqueue; } void AudioCacheEventHandler::start() @@ -119,7 +114,7 @@ void AudioCacheEventHandler::setThreaded(bool threaded) this->threaded = threaded; } -bool AudioCacheEventHandler::getThreaded() const +bool AudioCacheEventHandler::isThreaded() const { return threaded; } @@ -206,7 +201,7 @@ AudioCacheFile& AudioCacheEventHandler::openFile(const std::string& filename) void AudioCacheEventHandler::clearEvents() { // Iterate all events ignoring load events and handling close events. - for(auto& event : *eventqueue) + for(auto& event : eventqueue) { if(event.eventType == EventType::Close) { @@ -214,7 +209,7 @@ void AudioCacheEventHandler::clearEvents() } } - eventqueue->clear(); + eventqueue.clear(); } void AudioCacheEventHandler::handleLoadNextEvent(CacheEvent& cache_event) @@ -263,14 +258,14 @@ void AudioCacheEventHandler::thread_main() sem.wait(); mutex.lock(); - if(eventqueue->empty()) + if(eventqueue.empty()) { mutex.unlock(); continue; } - CacheEvent cache_event = eventqueue->front(); - eventqueue->pop_front(); + CacheEvent cache_event = eventqueue.front(); + eventqueue.pop_front(); mutex.unlock(); // TODO: Skip event if cache_event.pos < cache.pos @@ -298,7 +293,7 @@ void AudioCacheEventHandler::pushEvent(CacheEvent& cache_event) if(cache_event.eventType == EventType::LoadNext) { - for(auto& queued_event : *eventqueue) + for(auto& queued_event : eventqueue) { if((queued_event.eventType == EventType::LoadNext) && (cache_event.afile->getFilename() == @@ -318,7 +313,7 @@ void AudioCacheEventHandler::pushEvent(CacheEvent& cache_event) if(!found) { // The event was not already on the list, create a new one. - eventqueue->push_back(cache_event); + eventqueue.push_back(cache_event); } } diff --git a/src/audiocacheeventhandler.h b/src/audiocacheeventhandler.h index daf7bb9..473a010 100644 --- a/src/audiocacheeventhandler.h +++ b/src/audiocacheeventhandler.h @@ -59,7 +59,7 @@ public: void setThreaded(bool threaded); //! Get current threaded status. - bool getThreaded() const; + bool isThreaded() const; //! Lock thread mutex. //! This methods are supplied to make this class lockable by std::lock_guard @@ -101,7 +101,7 @@ protected: std::mutex mutex; - std::list* eventqueue; + std::list eventqueue; bool threaded{false}; Semaphore sem; -- cgit v1.2.3