| @@ -60,7 +60,7 @@ public: | |||
| } | |||
| protected: | |||
| bool msgReceived(const char* const msg) override | |||
| bool msgReceived(const char* const msg) noexcept override | |||
| { | |||
| if (CarlaExternalUI::msgReceived(msg)) | |||
| return true; | |||
| @@ -77,7 +77,9 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(value), true); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(valueStr), true); | |||
| fEngine->setOption(static_cast<EngineOption>(option), value, valueStr); | |||
| try { | |||
| fEngine->setOption(static_cast<EngineOption>(option), value, valueStr); | |||
| } catch(...) {} | |||
| delete[] valueStr; | |||
| } | |||
| @@ -87,7 +89,9 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename), true); | |||
| ok = fEngine->loadFile(filename); | |||
| try { | |||
| ok = fEngine->loadFile(filename); | |||
| } catch(...) {} | |||
| delete[] filename; | |||
| } | |||
| @@ -97,7 +101,9 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename), true); | |||
| ok = fEngine->loadProject(filename); | |||
| try { | |||
| ok = fEngine->loadProject(filename); | |||
| } catch(...) {} | |||
| delete[] filename; | |||
| } | |||
| @@ -107,7 +113,9 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename), true); | |||
| ok = fEngine->saveProject(filename); | |||
| try { | |||
| ok = fEngine->saveProject(filename); | |||
| } catch(...) {} | |||
| delete[] filename; | |||
| } | |||
| @@ -120,7 +128,9 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(groupB), true); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(portB), true); | |||
| ok = fEngine->patchbayConnect(groupA, portA, groupB, portB); | |||
| try { | |||
| ok = fEngine->patchbayConnect(groupA, portA, groupB, portB); | |||
| } catch(...) {} | |||
| } | |||
| else if (std::strcmp(msg, "patchbay_disconnect") == 0) | |||
| { | |||
| @@ -128,11 +138,15 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(connectionId), true); | |||
| ok = fEngine->patchbayDisconnect(connectionId); | |||
| try { | |||
| ok = fEngine->patchbayDisconnect(connectionId); | |||
| } catch(...) {} | |||
| } | |||
| else if (std::strcmp(msg, "patchbay_refresh") == 0) | |||
| { | |||
| ok = fEngine->patchbayRefresh(); | |||
| try { | |||
| ok = fEngine->patchbayRefresh(); | |||
| } catch(...) {} | |||
| } | |||
| else if (std::strcmp(msg, "transport_play") == 0) | |||
| { | |||
| @@ -66,28 +66,28 @@ protected: | |||
| return pHost->uiName; | |||
| } | |||
| uint32_t getBufferSize() const noexcept | |||
| uint32_t getBufferSize() const | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, 0); | |||
| return pHost->get_buffer_size(pHost->handle); | |||
| } | |||
| double getSampleRate() const noexcept | |||
| double getSampleRate() const | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, 0.0); | |||
| return pHost->get_sample_rate(pHost->handle); | |||
| } | |||
| bool isOffline() const noexcept | |||
| bool isOffline() const | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, false); | |||
| return pHost->is_offline(pHost->handle); | |||
| } | |||
| const NativeTimeInfo* getTimeInfo() const noexcept | |||
| const NativeTimeInfo* getTimeInfo() const | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, nullptr); | |||
| @@ -19,7 +19,6 @@ | |||
| #define CARLA_NATIVE_EXTERNAL_UI_HPP_INCLUDED | |||
| #include "CarlaNative.hpp" | |||
| #include "CarlaExternalUI.hpp" | |||
| /*! | |||
| @@ -126,7 +125,7 @@ protected: | |||
| // ------------------------------------------------------------------- | |||
| // Pipe Server calls | |||
| bool msgReceived(const char* const msg) override | |||
| bool msgReceived(const char* const msg) noexcept override | |||
| { | |||
| if (CarlaExternalUI::msgReceived(msg)) | |||
| return true; | |||
| @@ -139,20 +138,30 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(param), true); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true); | |||
| uiParameterChanged(param, value); | |||
| try { | |||
| uiParameterChanged(param, value); | |||
| } catch(...) {} | |||
| return true; | |||
| } | |||
| else if (std::strcmp(msg, "program") == 0) | |||
| if (std::strcmp(msg, "program") == 0) | |||
| { | |||
| uint32_t channel, bank, program; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true);; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(bank), true); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(program), true); | |||
| CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true); | |||
| uiMidiProgramChanged(channel, bank, program); | |||
| try { | |||
| uiMidiProgramChanged(channel, bank, program); | |||
| } catch(...) {} | |||
| return true; | |||
| } | |||
| else if (std::strcmp(msg, "configure") == 0) | |||
| if (std::strcmp(msg, "configure") == 0) | |||
| { | |||
| const char* key; | |||
| const char* value; | |||
| @@ -160,18 +169,18 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(key), true); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(value), true); | |||
| uiCustomDataChanged(key, value); | |||
| try { | |||
| uiCustomDataChanged(key, value); | |||
| } catch(...) {} | |||
| delete[] key; | |||
| delete[] value; | |||
| } | |||
| else | |||
| { | |||
| carla_stderr("msgReceived : %s", msg); | |||
| return false; | |||
| return true; | |||
| } | |||
| return true; | |||
| carla_stderr("msgReceived : %s", msg); | |||
| return false; | |||
| } | |||
| private: | |||
| @@ -19,7 +19,7 @@ | |||
| #define CARLA_BRIDGE_UTILS_HPP_INCLUDED | |||
| //#include "CarlaBackend.h" | |||
| #include "CarlaEngine.hpp" | |||
| //#include "CarlaEngine.hpp" | |||
| #include "CarlaRingBuffer.hpp" | |||
| // ----------------------------------------------------------------------- | |||
| @@ -56,14 +56,15 @@ public: | |||
| fUiTitle = uiTitle; | |||
| } | |||
| void start() | |||
| void start() noexcept | |||
| { | |||
| CarlaPipeServer::start(fFilename, fSampleRate, fUiTitle); | |||
| writeMsg("show\n", 5); | |||
| } | |||
| protected: | |||
| bool msgReceived(const char* const msg) override | |||
| // returns true if msg was handled | |||
| bool msgReceived(const char* const msg) noexcept override | |||
| { | |||
| if (std::strcmp(msg, "exiting") == 0) | |||
| { | |||
| @@ -63,7 +63,7 @@ public: | |||
| return (fPipeRecv != -1 && fPipeSend != -1 && fPid != -1); | |||
| } | |||
| bool start(const char* const filename, const char* const arg1, const char* const arg2) | |||
| bool start(const char* const filename, const char* const arg1, const char* const arg2) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); | |||
| CARLA_SAFE_ASSERT_RETURN(arg1 != nullptr, false); | |||
| @@ -99,8 +99,10 @@ public: | |||
| if (::pipe(pipe2) != 0) | |||
| { | |||
| ::close(pipe1[0]); | |||
| ::close(pipe1[1]); | |||
| try { | |||
| ::close(pipe1[0]); | |||
| ::close(pipe1[1]); | |||
| } catch (...) {} | |||
| fail("pipe2 creation failed"); | |||
| return false; | |||
| } | |||
| @@ -124,10 +126,14 @@ public: | |||
| if ((! fork_exec(argv, &ret)) || ret == -1) | |||
| { | |||
| ::close(pipe1[0]); | |||
| ::close(pipe1[1]); | |||
| ::close(pipe2[0]); | |||
| ::close(pipe2[1]); | |||
| try { | |||
| ::close(pipe1[0]); | |||
| ::close(pipe1[1]); | |||
| } catch (...) {} | |||
| try { | |||
| ::close(pipe2[0]); | |||
| ::close(pipe2[1]); | |||
| } catch (...) {} | |||
| fail("fork_exec() failed"); | |||
| return false; | |||
| } | |||
| @@ -135,15 +141,19 @@ public: | |||
| fPid = ret; | |||
| // fork duplicated the handles, close pipe ends that are used by the child process | |||
| ::close(pipe1[0]); | |||
| ::close(pipe2[1]); | |||
| try { | |||
| ::close(pipe1[0]); | |||
| } catch(...) {} | |||
| try { | |||
| ::close(pipe2[1]); | |||
| } catch(...) {} | |||
| fPipeSend = pipe1[1]; // [1] means writting end | |||
| fPipeRecv = pipe2[0]; // [0] means reading end | |||
| // set non-block | |||
| try { | |||
| ret = fcntl(fPipeRecv, F_SETFL, fcntl(fPipeRecv, F_GETFL) | O_NONBLOCK); | |||
| ret = ::fcntl(fPipeRecv, F_SETFL, ::fcntl(fPipeRecv, F_GETFL) | O_NONBLOCK); | |||
| } catch (...) { | |||
| ret = -1; | |||
| fail("failed to set pipe as non-block"); | |||
| @@ -199,10 +209,10 @@ public: | |||
| break; | |||
| } | |||
| carla_stderr("force killing misbehaved child %i (start)", int(fPid)); | |||
| } | |||
| carla_stderr("force killing misbehaved child %i (start)", int(fPid)); | |||
| if (kill(fPid, SIGKILL) == -1) | |||
| { | |||
| carla_stderr("kill() failed: %s (start)\n", strerror(errno)); | |||
| @@ -287,7 +297,7 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| bool readNextLineAsBool(bool& value) | |||
| bool readNextLineAsBool(bool& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -301,7 +311,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsInt(int32_t& value) | |||
| bool readNextLineAsInt(int32_t& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -315,7 +325,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsUInt(uint32_t& value) | |||
| bool readNextLineAsUInt(uint32_t& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -334,7 +344,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsLong(int64_t& value) | |||
| bool readNextLineAsLong(int64_t& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -348,7 +358,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsULong(uint64_t& value) | |||
| bool readNextLineAsULong(uint64_t& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -367,7 +377,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsFloat(float& value) | |||
| bool readNextLineAsFloat(float& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -381,7 +391,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsString(const char*& value) | |||
| bool readNextLineAsString(const char*& value) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -416,7 +426,7 @@ public: | |||
| } catch (...) {} | |||
| } | |||
| void writeAndFixMsg(const char* const msg) | |||
| void writeAndFixMsg(const char* const msg) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,); | |||
| @@ -458,7 +468,7 @@ public: | |||
| } catch (...) {} | |||
| } | |||
| void waitChildClose() | |||
| void waitChildClose() noexcept | |||
| { | |||
| if (! wait_child(fPid)) | |||
| { | |||
| @@ -481,7 +491,7 @@ protected: | |||
| } | |||
| // returns true if msg handled | |||
| virtual bool msgReceived(const char* const msg) = 0; | |||
| virtual bool msgReceived(const char* const msg) noexcept = 0; | |||
| // ------------------------------------------------------------------- | |||
| @@ -496,7 +506,7 @@ private: | |||
| // ------------------------------------------------------------------- | |||
| const char* readline() | |||
| const char* readline() noexcept | |||
| { | |||
| char ch; | |||
| char* ptr = fTmpBuf; | |||
| @@ -507,7 +517,7 @@ private: | |||
| for (int i=0; i < 0xff; ++i) | |||
| { | |||
| try { | |||
| ret = read(fPipeRecv, &ch, 1); | |||
| ret = ::read(fPipeRecv, &ch, 1); | |||
| } | |||
| catch (...) { | |||
| break; | |||
| @@ -538,7 +548,12 @@ private: | |||
| fTmpStr += fTmpBuf; | |||
| } | |||
| return fTmpStr.dup(); | |||
| try { | |||
| return fTmpStr.dup(); | |||
| } | |||
| catch(...) { | |||
| return nullptr; | |||
| } | |||
| } | |||
| break; | |||
| @@ -549,13 +564,13 @@ private: | |||
| // ------------------------------------------------------------------- | |||
| static bool fork_exec(const char* const argv[5], int* const retp) | |||
| static bool fork_exec(const char* const argv[5], int* const retp) noexcept | |||
| { | |||
| const pid_t ret = *retp = vfork(); | |||
| switch (ret) | |||
| { | |||
| case 0: /* child process */ | |||
| case 0: // child process | |||
| execlp(argv[0], argv[0], argv[1], argv[2], argv[3], argv[4], | |||
| #ifdef CARLA_OS_MAC // fix warning | |||
| NULL); | |||
| @@ -563,18 +578,19 @@ private: | |||
| nullptr); | |||
| #endif | |||
| carla_stderr2("exec failed: %s", std::strerror(errno)); | |||
| _exit(0); | |||
| _exit(0); // this is not noexcept safe but doesn't matter anyway | |||
| return false; | |||
| case -1: /* error */ | |||
| case -1: // error | |||
| carla_stderr2("fork() failed: %s", std::strerror(errno)); | |||
| _exit(0); | |||
| _exit(0); // this is not noexcept safe but doesn't matter anyway | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| static bool wait_child(const pid_t pid) | |||
| static bool wait_child(const pid_t pid) noexcept | |||
| { | |||
| if (pid == -1) | |||
| { | |||
| @@ -589,7 +605,7 @@ private: | |||
| try { | |||
| ret = ::waitpid(pid, nullptr, WNOHANG); | |||
| } | |||
| catch (...) { | |||
| catch(...) { | |||
| break; | |||
| } | |||
| @@ -65,7 +65,7 @@ public: | |||
| clearContentComponent(); | |||
| } | |||
| bool wasClosedByUser() const | |||
| bool wasClosedByUser() const noexcept | |||
| { | |||
| return fClosed; | |||
| } | |||
| @@ -28,7 +28,7 @@ | |||
| class Lv2AtomRingBufferControl : public RingBufferControl<HeapRingBuffer> | |||
| { | |||
| public: | |||
| Lv2AtomRingBufferControl() | |||
| Lv2AtomRingBufferControl() noexcept | |||
| : RingBufferControl<HeapRingBuffer>(nullptr), | |||
| fIsDummy(false) | |||
| { | |||
| @@ -36,7 +36,7 @@ public: | |||
| fBuffer.buf = nullptr; | |||
| } | |||
| ~Lv2AtomRingBufferControl() | |||
| ~Lv2AtomRingBufferControl() noexcept | |||
| { | |||
| if (fBuffer.buf != nullptr && ! fIsDummy) | |||
| { | |||
| @@ -47,7 +47,7 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| void createBuffer(const uint32_t size) | |||
| void createBuffer(const uint32_t size) noexcept | |||
| { | |||
| if (fBuffer.buf != nullptr) | |||
| { | |||
| @@ -65,7 +65,7 @@ public: | |||
| } | |||
| // used for tmp buffers only | |||
| void copyDump(HeapRingBuffer& rb, char dumpBuf[]) | |||
| void copyDump(HeapRingBuffer& rb, char dumpBuf[]) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fBuffer.size == 0,); | |||
| CARLA_SAFE_ASSERT_RETURN(fBuffer.buf == nullptr,); | |||
| @@ -153,13 +153,11 @@ private: | |||
| class Lv2AtomQueue | |||
| { | |||
| public: | |||
| Lv2AtomQueue() | |||
| { | |||
| } | |||
| Lv2AtomQueue() noexcept {} | |||
| // ------------------------------------------------------------------- | |||
| void createBuffer(const uint32_t size) | |||
| void createBuffer(const uint32_t size) noexcept | |||
| { | |||
| fRingBufferCtrl.createBuffer(size); | |||
| } | |||
| @@ -177,7 +175,7 @@ public: | |||
| } | |||
| // must have been locked before | |||
| bool get(const LV2_Atom** const atom, uint32_t* const portIndex) | |||
| bool get(const LV2_Atom** const atom, uint32_t* const portIndex) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(atom != nullptr && portIndex != nullptr, false); | |||
| @@ -194,7 +192,7 @@ public: | |||
| } | |||
| // must NOT been locked, we do that here | |||
| bool put(const LV2_Atom* const atom, const uint32_t portIndex) | |||
| bool put(const LV2_Atom* const atom, const uint32_t portIndex) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(atom != nullptr && atom->size > 0, false); | |||
| @@ -204,7 +202,7 @@ public: | |||
| } | |||
| // must NOT been locked, we do that here | |||
| bool putChunk(const LV2_Atom* const atom, const void* const data, const uint32_t portIndex) | |||
| bool putChunk(const LV2_Atom* const atom, const void* const data, const uint32_t portIndex) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(atom != nullptr && atom->size > 0, false); | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr, false); | |||
| @@ -233,14 +231,14 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| void copyDataFromQueue(Lv2AtomQueue& queue) | |||
| void copyDataFromQueue(Lv2AtomQueue& queue) noexcept | |||
| { | |||
| // lock source | |||
| const CarlaMutexLocker qsl(queue.fMutex); | |||
| const CarlaMutexLocker cml1(queue.fMutex); | |||
| { | |||
| // copy data from source | |||
| const CarlaMutexLocker cml(fMutex); | |||
| const CarlaMutexLocker cml2(fMutex); | |||
| fRingBufferCtrl.fBuffer = queue.fRingBufferCtrl.fBuffer; | |||
| } | |||
| @@ -248,7 +246,7 @@ public: | |||
| queue.fRingBufferCtrl.clear(); | |||
| } | |||
| void copyAndDumpDataFromQueue(Lv2AtomQueue& queue, char dumpBuf[]) | |||
| void copyAndDumpDataFromQueue(Lv2AtomQueue& queue, char dumpBuf[]) noexcept | |||
| { | |||
| // lock source | |||
| const CarlaMutexLocker cml1(queue.fMutex); | |||