LMMS
Loading...
Searching...
No Matches
Lv2Worker.h
Go to the documentation of this file.
1/*
2 * Lv2Worker.h - Lv2Worker class
3 *
4 * Copyright (c) 2022-2022 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LV2WORKER_H
26#define LV2WORKER_H
27
28#include "lmmsconfig.h"
29
30#ifdef LMMS_HAVE_LV2
31
32#include <lv2/worker/worker.h>
33#include <thread>
34#include <vector>
35
36#include "LocklessRingBuffer.h"
37#include "LmmsSemaphore.h"
38
39namespace lmms
40{
41
46{
47public:
48 // CTOR/DTOR/feature access
49 Lv2Worker(Semaphore* commonWorkLock, bool threaded);
50 ~Lv2Worker();
51 void setHandle(LV2_Handle handle);
52 void setInterface(const LV2_Worker_Interface* newInterface);
54
55 // public API
56 void emitResponses();
58 {
59 if(m_interface->end_run) { m_interface->end_run(m_scheduleFeature.handle); }
60 }
61
62 // to be called only by static functions
65
66private:
67 // functions
68 void workerFunc();
69 std::size_t bufferSize() const;
70
71 // parameters
72 const bool m_threaded;
76
77 // threading/synchronization
78 std::thread m_thread;
79 std::vector<char> m_response;
82 std::atomic<bool> m_exit = false;
85};
86
87
88} // namespace lmms
89
90#endif // LMMS_HAVE_LV2
91
92#endif // LV2WORKER_H
93
A convenience layer for a realtime-safe and thread-safe multi-reader ringbuffer.
Definition LocklessRingBuffer.h:41
Wrapper for lockless ringbuffer reader.
Definition LocklessRingBuffer.h:72
LocklessRingBufferReader< char > m_responsesReader
Definition Lv2Worker.h:81
void setHandle(LV2_Handle handle)
Definition Lv2Worker.cpp:88
const LV2_Worker_Interface * m_interface
Definition Lv2Worker.h:73
LocklessRingBuffer< char > m_responses
ringbuffer to queue multiple requests
Definition Lv2Worker.h:80
LV2_Worker_Schedule m_scheduleFeature
Definition Lv2Worker.h:75
Semaphore * m_workLock
Definition Lv2Worker.h:84
void emitResponses()
Definition Lv2Worker.cpp:207
std::size_t bufferSize() const
size of internal buffers
Definition Lv2Worker.cpp:50
std::vector< char > m_response
buffer where single requests from m_requests are unpacked
Definition Lv2Worker.h:79
void notifyPluginThatRunFinished()
Definition Lv2Worker.h:57
LV2_Worker_Schedule * feature()
Definition Lv2Worker.h:53
LocklessRingBufferReader< char > m_requestsReader
Definition Lv2Worker.h:81
std::thread m_thread
Definition Lv2Worker.h:78
void setInterface(const LV2_Worker_Interface *newInterface)
Definition Lv2Worker.cpp:97
Lv2Worker(Semaphore *commonWorkLock, bool threaded)
Definition Lv2Worker.cpp:61
~Lv2Worker()
Definition Lv2Worker.cpp:106
const bool m_threaded
Definition Lv2Worker.h:72
LV2_Worker_Status respond(uint32_t size, const void *data)
Definition Lv2Worker.cpp:119
LocklessRingBuffer< char > m_requests
Definition Lv2Worker.h:80
void workerFunc()
Definition Lv2Worker.cpp:146
std::atomic< bool > m_exit
Whether the worker function should keep looping.
Definition Lv2Worker.h:82
LV2_Handle m_handle
Definition Lv2Worker.h:74
Semaphore m_sem
Definition Lv2Worker.h:83
LV2_Worker_Status scheduleWork(uint32_t size, const void *data)
Definition Lv2Worker.cpp:174
Definition LmmsSemaphore.h:67
void * LV2_Handle
Definition lv2.h:133
LV2_Worker_Status
Definition worker.h:46
JSAMPIMAGE data
Definition jpeglib.h:945
unsigned int uint32_t
Definition mid.cpp:100
Definition AudioAlsa.cpp:35
Definition worker.h:80
Definition worker.h:138
ulg size
Definition extract.c:2350