4 * ***** BEGIN LGPL LICENSE BLOCK *****
6 * Copyright 2009 Jörg Hermann Müller
8 * This file is part of AudaSpace.
10 * AudaSpace is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * AudaSpace is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
23 * ***** END LGPL LICENSE BLOCK *****
26 #ifndef AUD_JACKDEVICE
27 #define AUD_JACKDEVICE
30 #include "AUD_SoftwareDevice.h"
34 #include <ringbuffer.h>
37 * This device plays back through Jack.
39 class AUD_JackDevice : public AUD_SoftwareDevice
43 * The output ports of jack.
45 jack_port_t** m_ports;
50 jack_client_t* m_client;
57 AUD_Buffer* m_deinterleavebuf;
60 * Whether the device is valid.
65 * Invalidates the jack device.
66 * \param data The jack device that gets invalidet by jack.
68 static void jack_shutdown(void *data);
71 * Mixes the next bytes into the buffer.
72 * \param length The length in samples to be filled.
73 * \param data A pointer to the jack device.
74 * \return 0 what shows success.
76 static int jack_mix(jack_nframes_t length, void *data);
78 static void* runThread(void* device);
80 void updateRingBuffers();
82 jack_ringbuffer_t** m_ringbuffers;
85 * The streaming thread.
89 pthread_mutex_t m_lock;
91 pthread_cond_t m_condition;
94 virtual void playing(bool playing);
98 * Creates a Jack client for audio output.
99 * \param specs The wanted audio specification, where only the channel count is important.
100 * \exception AUD_Exception Thrown if the audio device cannot be opened.
102 AUD_JackDevice(AUD_DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE);
105 * Closes the Jack client.
107 virtual ~AUD_JackDevice();
110 #endif //AUD_JACKDEVICE