--- linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.cpp 2012/03/10 16:16:14 2327 +++ linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.cpp 2015/08/23 06:14:00 2837 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005 - 2012 Christian Schoenebeck * + * Copyright (C) 2005 - 2015 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -69,7 +69,7 @@ * instrument ID */ void InstrumentResourceManager::OnInstrumentLoadingProgress(::gig::progress_t* pProgress) { - dmsg(7,("gig::InstrumentResourceManager: progress %f%", pProgress->factor)); + dmsg(7,("gig::InstrumentResourceManager: progress %f%%", pProgress->factor)); progress_callback_arg_t* pArg = static_cast(pProgress->custom); // we randomly schedule 90% for the .gig file loading and the remaining 10% later for sample caching const float localProgress = 0.9f * pProgress->factor; @@ -208,7 +208,7 @@ } } - InstrumentEditor* InstrumentResourceManager::LaunchInstrumentEditor(instrument_id_t ID, void* pUserData) throw (InstrumentManagerException) { + InstrumentEditor* InstrumentResourceManager::LaunchInstrumentEditor(LinuxSampler::EngineChannel* pEngineChannel, instrument_id_t ID, void* pUserData) throw (InstrumentManagerException) { const String sDataType = GetInstrumentDataStructureName(ID); const String sDataVersion = GetInstrumentDataStructureVersion(ID); // find instrument editors capable to handle given instrument @@ -235,7 +235,7 @@ InstrumentEditorProxies.add(pProxy); InstrumentEditorProxiesMutex.Unlock(); // launch the instrument editor for the given instrument - pEditor->Launch(pInstrument, sDataType, sDataVersion, pUserData); + pEditor->Launch(pEngineChannel, pInstrument, sDataType, sDataVersion, pUserData); // register the instrument editor as virtual MIDI device as well ... VirtualMidiDevice* pVirtualMidiDevice = @@ -271,19 +271,20 @@ int iProxyIndex = -1; // first find the editor proxy entry for this editor - InstrumentEditorProxiesMutex.Lock(); - for (int i = 0; i < InstrumentEditorProxies.size(); i++) { - InstrumentEditorProxy* pCurProxy = - dynamic_cast( - InstrumentEditorProxies[i] - ); - if (pCurProxy->pEditor == pSender) { - pProxy = pCurProxy; - iProxyIndex = i; - pInstrument = pCurProxy->pInstrument; + { + LockGuard lock(InstrumentEditorProxiesMutex); + for (int i = 0; i < InstrumentEditorProxies.size(); i++) { + InstrumentEditorProxy* pCurProxy = + dynamic_cast( + InstrumentEditorProxies[i] + ); + if (pCurProxy->pEditor == pSender) { + pProxy = pCurProxy; + iProxyIndex = i; + pInstrument = pCurProxy->pInstrument; + } } } - InstrumentEditorProxiesMutex.Unlock(); if (!pProxy) { std::cerr << "Eeeek, could not find instrument editor proxy, " @@ -311,9 +312,10 @@ // finally delete proxy entry and hand back instrument if (pInstrument) { - InstrumentEditorProxiesMutex.Lock(); - InstrumentEditorProxies.remove(iProxyIndex); - InstrumentEditorProxiesMutex.Unlock(); + { + LockGuard lock(InstrumentEditorProxiesMutex); + InstrumentEditorProxies.remove(iProxyIndex); + } HandBack(pInstrument, pProxy); delete pProxy; @@ -674,9 +676,9 @@ const uint neededSilenceSamples = (maxSamplesPerCycle << CONFIG_MAX_PITCH) + 3; const uint currentlyCachedSilenceSamples = pSample->GetCache().NullExtensionSize / pSample->FrameSize; if (currentlyCachedSilenceSamples < neededSilenceSamples) { - dmsg(3,("Caching whole sample (sample name: \"%s\", sample size: %d)\n", pSample->pInfo->Name.c_str(), pSample->SamplesTotal)); + dmsg(3,("Caching whole sample (sample name: \"%s\", sample size: %lu)\n", pSample->pInfo->Name.c_str(), pSample->SamplesTotal)); ::gig::buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(neededSilenceSamples); - dmsg(4,("Cached %d Bytes, %d silence bytes.\n", buf.Size, buf.NullExtensionSize)); + dmsg(4,("Cached %lu Bytes, %lu silence bytes.\n", buf.Size, buf.NullExtensionSize)); } } else { // we only cache CONFIG_PRELOAD_SAMPLES and stream the other sample points from disk @@ -687,7 +689,7 @@ } void InstrumentResourceManager::UncacheInitialSamples(::gig::Sample* pSample) { - dmsg(1,("Uncaching sample %x\n",pSample)); + dmsg(1,("Uncaching sample %p\n",(void*)pSample)); if (pSample->GetCache().Size) pSample->ReleaseSampleData(); }