diff options
author | Jörg Müller <nexyon@gmail.com> | 2017-08-18 09:24:12 +0300 |
---|---|---|
committer | Jörg Müller <nexyon@gmail.com> | 2017-08-18 09:24:12 +0300 |
commit | 986267300ba42a5c99d2802cd701803dd558e389 (patch) | |
tree | 9bf6a84f8e3ebb8d01e5617b1cccfd2693cc1345 /extern/audaspace/plugins/jack | |
parent | d0dad0260434c4420fa9756264c1cc5e745e5ec9 (diff) |
Audaspace: Moving audaspace 1.3 into extern.
Deleting the old internal audaspace.
Major changes from there are:
- The whole library was refactored to use C++11.
- Many stability and performance improvements.
- Major Python API refactor:
- Most requested: Play self generated sounds using numpy arrays.
- For games: Sound list, random sounds and dynamic music.
- Writing sounds to files.
- Sequencing API.
- Opening sound devices, eg. Jack.
- Ability to choose different OpenAL devices in the user settings.
Diffstat (limited to 'extern/audaspace/plugins/jack')
-rw-r--r-- | extern/audaspace/plugins/jack/JackDevice.cpp | 385 | ||||
-rw-r--r-- | extern/audaspace/plugins/jack/JackDevice.h | 204 | ||||
-rw-r--r-- | extern/audaspace/plugins/jack/JackLibrary.cpp | 59 | ||||
-rw-r--r-- | extern/audaspace/plugins/jack/JackLibrary.h | 48 | ||||
-rw-r--r-- | extern/audaspace/plugins/jack/JackSymbols.h | 45 | ||||
-rw-r--r-- | extern/audaspace/plugins/jack/JackSynchronizer.cpp | 58 | ||||
-rw-r--r-- | extern/audaspace/plugins/jack/JackSynchronizer.h | 59 |
7 files changed, 858 insertions, 0 deletions
diff --git a/extern/audaspace/plugins/jack/JackDevice.cpp b/extern/audaspace/plugins/jack/JackDevice.cpp new file mode 100644 index 00000000000..1d238f74c3a --- /dev/null +++ b/extern/audaspace/plugins/jack/JackDevice.cpp @@ -0,0 +1,385 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#include "JackDevice.h" +#include "JackLibrary.h" +#include "devices/DeviceManager.h" +#include "devices/IDeviceFactory.h" +#include "Exception.h" +#include "IReader.h" + +#include <cstring> +#include <algorithm> + +AUD_NAMESPACE_BEGIN + +void JackDevice::updateRingBuffers() +{ + size_t size, temp; + unsigned int samplesize = AUD_SAMPLE_SIZE(m_specs); + unsigned int i, j; + unsigned int channels = m_specs.channels; + sample_t* buffer = m_buffer.getBuffer(); + float* deinterleave = m_deinterleavebuf.getBuffer(); + jack_transport_state_t state; + jack_position_t position; + + std::unique_lock<std::mutex> lock(m_mixingLock); + + while(m_valid) + { + if(m_sync > 1) + { + if(m_syncFunc) + { + state = AUD_jack_transport_query(m_client, &position); + m_syncFunc(m_syncFuncData, state != JackTransportStopped, position.frame / (float) m_specs.rate); + } + + for(i = 0; i < channels; i++) + AUD_jack_ringbuffer_reset(m_ringbuffers[i]); + } + + size = AUD_jack_ringbuffer_write_space(m_ringbuffers[0]); + for(i = 1; i < channels; i++) + if((temp = AUD_jack_ringbuffer_write_space(m_ringbuffers[i])) < size) + size = temp; + + while(size > samplesize) + { + size /= samplesize; + mix((data_t*)buffer, size); + for(i = 0; i < channels; i++) + { + for(j = 0; j < size; j++) + deinterleave[i * size + j] = buffer[i + j * channels]; + AUD_jack_ringbuffer_write(m_ringbuffers[i], (char*)(deinterleave + i * size), size * sizeof(float)); + } + + size = AUD_jack_ringbuffer_write_space(m_ringbuffers[0]); + for(i = 1; i < channels; i++) + if((temp = AUD_jack_ringbuffer_write_space(m_ringbuffers[i])) < size) + size = temp; + } + + if(m_sync > 1) + { + m_sync = 3; + } + + m_mixingCondition.wait(lock); + } +} + +int JackDevice::jack_mix(jack_nframes_t length, void* data) +{ + JackDevice* device = (JackDevice*)data; + unsigned int i; + int count = device->m_specs.channels; + char* buffer; + + if(device->m_sync) + { + // play silence while syncing + for(unsigned int i = 0; i < count; i++) + std::memset(AUD_jack_port_get_buffer(device->m_ports[i], length), 0, length * sizeof(float)); + } + else + { + size_t temp; + size_t readsamples = AUD_jack_ringbuffer_read_space(device->m_ringbuffers[0]); + for(i = 1; i < count; i++) + if((temp = AUD_jack_ringbuffer_read_space(device->m_ringbuffers[i])) < readsamples) + readsamples = temp; + + readsamples = std::min(readsamples / sizeof(float), size_t(length)); + + for(unsigned int i = 0; i < count; i++) + { + buffer = (char*)AUD_jack_port_get_buffer(device->m_ports[i], length); + AUD_jack_ringbuffer_read(device->m_ringbuffers[i], buffer, readsamples * sizeof(float)); + if(readsamples < length) + std::memset(buffer + readsamples * sizeof(float), 0, (length - readsamples) * sizeof(float)); + } + + if(device->m_mixingLock.try_lock()) + { + device->m_mixingCondition.notify_all(); + device->m_mixingLock.unlock(); + } + } + + return 0; +} + +int JackDevice::jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data) +{ + JackDevice* device = (JackDevice*)data; + + if(state == JackTransportStopped) + return 1; + + if(device->m_mixingLock.try_lock()) + { + if(device->m_sync > 2) + { + if(device->m_sync == 3) + { + device->m_sync = 0; + device->m_mixingLock.unlock(); + return 1; + } + } + else + { + device->m_sync = 2; + device->m_mixingCondition.notify_all(); + } + device->m_mixingLock.unlock(); + } + else if(!device->m_sync) + device->m_sync = 1; + + return 0; +} + +void JackDevice::jack_shutdown(void* data) +{ + JackDevice* device = (JackDevice*)data; + device->m_valid = false; +} + +JackDevice::JackDevice(std::string name, DeviceSpecs specs, int buffersize) : + m_synchronizer(this) +{ + if(specs.channels == CHANNELS_INVALID) + specs.channels = CHANNELS_STEREO; + + // jack uses floats + m_specs = specs; + m_specs.format = FORMAT_FLOAT32; + + jack_options_t options = JackNullOption; + jack_status_t status; + + // open client + m_client = AUD_jack_client_open(name.c_str(), options, &status); + if(m_client == nullptr) + AUD_THROW(DeviceException, "Connecting to the JACK server failed."); + + // set callbacks + AUD_jack_set_process_callback(m_client, JackDevice::jack_mix, this); + AUD_jack_on_shutdown(m_client, JackDevice::jack_shutdown, this); + AUD_jack_set_sync_callback(m_client, JackDevice::jack_sync, this); + + // register our output channels which are called ports in jack + m_ports = new jack_port_t*[m_specs.channels]; + + try + { + char portname[64]; + for(int i = 0; i < m_specs.channels; i++) + { + sprintf(portname, "out %d", i+1); + m_ports[i] = AUD_jack_port_register(m_client, portname, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); + if(m_ports[i] == nullptr) + AUD_THROW(DeviceException, "Registering output port with JACK failed."); + } + } + catch(Exception&) + { + AUD_jack_client_close(m_client); + delete[] m_ports; + throw; + } + + m_specs.rate = (SampleRate)AUD_jack_get_sample_rate(m_client); + + buffersize *= sizeof(sample_t); + m_ringbuffers = new jack_ringbuffer_t*[specs.channels]; + for(unsigned int i = 0; i < specs.channels; i++) + m_ringbuffers[i] = AUD_jack_ringbuffer_create(buffersize); + buffersize *= specs.channels; + m_deinterleavebuf.resize(buffersize); + m_buffer.resize(buffersize); + + create(); + + m_valid = true; + m_sync = 0; + m_syncFunc = nullptr; + m_nextState = m_state = AUD_jack_transport_query(m_client, nullptr); + + // activate the client + if(AUD_jack_activate(m_client)) + { + AUD_jack_client_close(m_client); + delete[] m_ports; + for(unsigned int i = 0; i < specs.channels; i++) + AUD_jack_ringbuffer_free(m_ringbuffers[i]); + delete[] m_ringbuffers; + destroy(); + + AUD_THROW(DeviceException, "Client activation with JACK failed."); + } + + const char** ports = AUD_jack_get_ports(m_client, nullptr, nullptr, + JackPortIsPhysical | JackPortIsInput); + if(ports != nullptr) + { + for(int i = 0; i < m_specs.channels && ports[i]; i++) + AUD_jack_connect(m_client, AUD_jack_port_name(m_ports[i]), ports[i]); + + AUD_jack_free(ports); + } + + m_mixingThread = std::thread(&JackDevice::updateRingBuffers, this); +} + +JackDevice::~JackDevice() +{ + if(m_valid) + AUD_jack_client_close(m_client); + m_valid = false; + + delete[] m_ports; + + m_mixingLock.lock(); + m_mixingCondition.notify_all(); + m_mixingLock.unlock(); + + m_mixingThread.join(); + + for(unsigned int i = 0; i < m_specs.channels; i++) + AUD_jack_ringbuffer_free(m_ringbuffers[i]); + delete[] m_ringbuffers; + + destroy(); +} + +ISynchronizer* JackDevice::getSynchronizer() +{ + return &m_synchronizer; +} + +void JackDevice::playing(bool playing) +{ + // Do nothing. +} + +void JackDevice::startPlayback() +{ + AUD_jack_transport_start(m_client); + m_nextState = JackTransportRolling; +} + +void JackDevice::stopPlayback() +{ + AUD_jack_transport_stop(m_client); + m_nextState = JackTransportStopped; +} + +void JackDevice::seekPlayback(float time) +{ + if(time >= 0.0f) + AUD_jack_transport_locate(m_client, time * m_specs.rate); +} + +void JackDevice::setSyncCallback(ISynchronizer::syncFunction sync, void* data) +{ + m_syncFunc = sync; + m_syncFuncData = data; +} + +float JackDevice::getPlaybackPosition() +{ + jack_position_t position; + AUD_jack_transport_query(m_client, &position); + return position.frame / (float) m_specs.rate; +} + +bool JackDevice::doesPlayback() +{ + jack_transport_state_t state = AUD_jack_transport_query(m_client, nullptr); + + if(state != m_state) + m_nextState = m_state = state; + + return m_nextState != JackTransportStopped; +} + +class JackDeviceFactory : public IDeviceFactory +{ +private: + DeviceSpecs m_specs; + int m_buffersize; + std::string m_name; + +public: + JackDeviceFactory() : + m_buffersize(AUD_DEFAULT_BUFFER_SIZE), + m_name("Audaspace") + { + m_specs.format = FORMAT_FLOAT32; + m_specs.channels = CHANNELS_STEREO; + m_specs.rate = RATE_48000; + } + + virtual std::shared_ptr<IDevice> openDevice() + { + return std::shared_ptr<IDevice>(new JackDevice(m_name, m_specs, m_buffersize)); + } + + virtual int getPriority() + { + return 0; + } + + virtual void setSpecs(DeviceSpecs specs) + { + m_specs = specs; + } + + virtual void setBufferSize(int buffersize) + { + m_buffersize = buffersize; + } + + virtual void setName(std::string name) + { + m_name = name; + } +}; + +void JackDevice::registerPlugin() +{ + if(loadJACK()) + DeviceManager::registerDevice("JACK", std::shared_ptr<IDeviceFactory>(new JackDeviceFactory)); +} + +#ifdef JACK_PLUGIN +extern "C" AUD_PLUGIN_API void registerPlugin() +{ + JackDevice::registerPlugin(); +} + +extern "C" AUD_PLUGIN_API const char* getName() +{ + return "JACK"; +} +#endif + +AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/jack/JackDevice.h b/extern/audaspace/plugins/jack/JackDevice.h new file mode 100644 index 00000000000..72143eda149 --- /dev/null +++ b/extern/audaspace/plugins/jack/JackDevice.h @@ -0,0 +1,204 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +#ifdef JACK_PLUGIN +#define AUD_BUILD_PLUGIN +#endif + +/** + * @file JackDevice.h + * @ingroup plugin + * The JackDevice class. + */ + +#include "JackSynchronizer.h" +#include "devices/SoftwareDevice.h" +#include "util/Buffer.h" + +#include <string> +#include <condition_variable> +#include <thread> +#include <jack/jack.h> +#include <jack/ringbuffer.h> + +AUD_NAMESPACE_BEGIN + +/** + * This device plays back through JACK. + */ +class AUD_PLUGIN_API JackDevice : public SoftwareDevice +{ +private: + /** + * The output ports of jack. + */ + jack_port_t** m_ports; + + /** + * The jack client. + */ + jack_client_t* m_client; + + /** + * The output buffer. + */ + Buffer m_buffer; + + /** + * The deinterleaving buffer. + */ + Buffer m_deinterleavebuf; + + jack_ringbuffer_t** m_ringbuffers; + + /** + * Whether the device is valid. + */ + bool m_valid; + + /// Synchronizer. + JackSynchronizer m_synchronizer; + + /** + * Invalidates the jack device. + * \param data The jack device that gets invalidet by jack. + */ + AUD_LOCAL static void jack_shutdown(void* data); + + /** + * Mixes the next bytes into the buffer. + * \param length The length in samples to be filled. + * \param data A pointer to the jack device. + * \return 0 what shows success. + */ + AUD_LOCAL static int jack_mix(jack_nframes_t length, void* data); + + AUD_LOCAL static int jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data); + + /** + * Next JACK Transport state (-1 if not expected to change). + */ + jack_transport_state_t m_nextState; + + /** + * Current jack transport status. + */ + jack_transport_state_t m_state; + + /** + * Syncronisation state. + */ + int m_sync; + + /** + * External syncronisation callback function. + */ + ISynchronizer::syncFunction m_syncFunc; + + /** + * Data for the sync function. + */ + void* m_syncFuncData; + + /** + * The mixing thread. + */ + std::thread m_mixingThread; + + /** + * Mutex for mixing. + */ + std::mutex m_mixingLock; + + /** + * Condition for mixing. + */ + std::condition_variable m_mixingCondition; + + /** + * Updates the ring buffers. + */ + AUD_LOCAL void updateRingBuffers(); + + // delete copy constructor and operator= + JackDevice(const JackDevice&) = delete; + JackDevice& operator=(const JackDevice&) = delete; + +protected: + virtual void playing(bool playing); + +public: + /** + * Creates a JACK client for audio output. + * \param name The client name. + * \param specs The wanted audio specification, where only the channel count + * is important. + * \param buffersize The size of the internal buffer. + * \exception Exception Thrown if the audio device cannot be opened. + */ + JackDevice(std::string name, DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); + + /** + * Closes the JACK client. + */ + virtual ~JackDevice(); + + virtual ISynchronizer* getSynchronizer(); + + /** + * Starts jack transport playback. + */ + void startPlayback(); + + /** + * Stops jack transport playback. + */ + void stopPlayback(); + + /** + * Seeks jack transport playback. + * \param time The time to seek to. + */ + void seekPlayback(float time); + + /** + * Sets the sync callback for jack transport playback. + * \param sync The callback function. + * \param data The data for the function. + */ + void setSyncCallback(ISynchronizer::syncFunction sync, void* data); + + /** + * Retrieves the jack transport playback time. + * \return The current time position. + */ + float getPlaybackPosition(); + + /** + * Returns whether jack transport plays back. + * \return Whether jack transport plays back. + */ + bool doesPlayback(); + + /** + * Registers this plugin. + */ + static void registerPlugin(); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/jack/JackLibrary.cpp b/extern/audaspace/plugins/jack/JackLibrary.cpp new file mode 100644 index 00000000000..92462a34cca --- /dev/null +++ b/extern/audaspace/plugins/jack/JackLibrary.cpp @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#define JACK_LIBRARY_IMPLEMENTATION + +#include <string> +#include <array> + +#include "JackLibrary.h" + +#ifdef DYNLOAD_JACK +#include "plugin/PluginManager.h" +#endif + +AUD_NAMESPACE_BEGIN + +bool loadJACK() +{ +#ifdef DYNLOAD_JACK + std::array<const std::string, 5> names = {"libjack.so", "libjack.so.0", "libjack.so.1", "libjack.so.2", "libjack.dll"}; + + void* handle = nullptr; + + for(auto& name : names) + { + handle = PluginManager::openLibrary(name); + if(handle) + break; + } + + if (!handle) + return false; + +#define JACK_SYMBOL(sym) AUD_##sym = reinterpret_cast<decltype(&sym)>(PluginManager::lookupLibrary(handle, #sym)) +#else +#define JACK_SYMBOL(sym) AUD_##sym = &sym +#endif + +#include "JackSymbols.h" + +#undef JACK_SYMBOL + + return AUD_jack_client_open != nullptr; +} + +AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/jack/JackLibrary.h b/extern/audaspace/plugins/jack/JackLibrary.h new file mode 100644 index 00000000000..4e210852702 --- /dev/null +++ b/extern/audaspace/plugins/jack/JackLibrary.h @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +#ifdef JACK_PLUGIN +#define AUD_BUILD_PLUGIN +#endif + +/** + * @file JackDevice.h + * @ingroup plugin + * The JackDevice class. + */ + +#include "Audaspace.h" + +#include <jack/jack.h> +#include <jack/ringbuffer.h> + +AUD_NAMESPACE_BEGIN + +#ifdef JACK_LIBRARY_IMPLEMENTATION +#define JACK_SYMBOL(sym) decltype(&sym) AUD_##sym +#else +#define JACK_SYMBOL(sym) extern decltype(&sym) AUD_##sym +#endif + +#include "JackSymbols.h" + +#undef JACK_SYMBOL + +bool loadJACK(); + +AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/jack/JackSymbols.h b/extern/audaspace/plugins/jack/JackSymbols.h new file mode 100644 index 00000000000..f8e22a7da34 --- /dev/null +++ b/extern/audaspace/plugins/jack/JackSymbols.h @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +JACK_SYMBOL(jack_transport_query); +JACK_SYMBOL(jack_transport_locate); + +JACK_SYMBOL(jack_transport_start); +JACK_SYMBOL(jack_transport_stop); + +JACK_SYMBOL(jack_ringbuffer_reset); +JACK_SYMBOL(jack_ringbuffer_write); +JACK_SYMBOL(jack_ringbuffer_write_space); +JACK_SYMBOL(jack_ringbuffer_write_advance); +JACK_SYMBOL(jack_ringbuffer_read); +JACK_SYMBOL(jack_ringbuffer_create); +JACK_SYMBOL(jack_ringbuffer_free); +JACK_SYMBOL(jack_ringbuffer_read_space); +JACK_SYMBOL(jack_set_sync_callback); + +JACK_SYMBOL(jack_port_get_buffer); + +JACK_SYMBOL(jack_client_open); +JACK_SYMBOL(jack_set_process_callback); +JACK_SYMBOL(jack_on_shutdown); +JACK_SYMBOL(jack_port_register); +JACK_SYMBOL(jack_client_close); +JACK_SYMBOL(jack_get_sample_rate); +JACK_SYMBOL(jack_activate); +JACK_SYMBOL(jack_get_ports); +JACK_SYMBOL(jack_port_name); +JACK_SYMBOL(jack_connect); +JACK_SYMBOL(jack_free); diff --git a/extern/audaspace/plugins/jack/JackSynchronizer.cpp b/extern/audaspace/plugins/jack/JackSynchronizer.cpp new file mode 100644 index 00000000000..cd4c448786d --- /dev/null +++ b/extern/audaspace/plugins/jack/JackSynchronizer.cpp @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#include "JackSynchronizer.h" + +#include "JackDevice.h" + +AUD_NAMESPACE_BEGIN + +JackSynchronizer::JackSynchronizer(JackDevice* device) : + m_device(device) +{ +} + +void JackSynchronizer::seek(std::shared_ptr<IHandle> handle, float time) +{ + m_device->seekPlayback(time); +} + +float JackSynchronizer::getPosition(std::shared_ptr<IHandle> handle) +{ + return m_device->getPlaybackPosition(); +} + +void JackSynchronizer::play() +{ + m_device->startPlayback(); +} + +void JackSynchronizer::stop() +{ + m_device->stopPlayback(); +} + +void JackSynchronizer::setSyncCallback(ISynchronizer::syncFunction function, void* data) +{ + m_device->setSyncCallback(function, data); +} + +int JackSynchronizer::isPlaying() +{ + return m_device->doesPlayback(); +} + +AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/jack/JackSynchronizer.h b/extern/audaspace/plugins/jack/JackSynchronizer.h new file mode 100644 index 00000000000..5c7341a7872 --- /dev/null +++ b/extern/audaspace/plugins/jack/JackSynchronizer.h @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +#ifdef JACK_PLUGIN +#define AUD_BUILD_PLUGIN +#endif + +/** + * @file JackSynchronizer.h + * @ingroup plugin + * The JackSynchronizer class. + */ + +#include "devices/ISynchronizer.h" + +AUD_NAMESPACE_BEGIN + +class JackDevice; + +/** + * This class is a Synchronizer implementation using JACK Transport. + */ +class AUD_PLUGIN_API JackSynchronizer : public ISynchronizer +{ +private: + /// The device that is being synchronized. + JackDevice* m_device; + +public: + /** + * Creates a new JackSynchronizer. + * @param device The device that should be synchronized. + */ + JackSynchronizer(JackDevice* device); + + virtual void seek(std::shared_ptr<IHandle> handle, float time); + virtual float getPosition(std::shared_ptr<IHandle> handle); + virtual void play(); + virtual void stop(); + virtual void setSyncCallback(syncFunction function, void* data); + virtual int isPlaying(); +}; + +AUD_NAMESPACE_END |