2 terminatorX - realtime audio scratching software
3 Copyright (C) 1999-2003 Alexander König
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 File: tX_audiodevice.h
21 Description: Header to tX_mastergui.cc
24 #ifndef _h_tx_audiodevice
25 #define _h_tx_audiodevice 1
28 #include "tX_global.h"
34 #define NON_RT_BUFF 12
37 #include <alsa/asoundlib.h>
41 #include <jack/jack.h>
49 int samples_per_buffer;
50 int16_t *sample_buffer[2];
61 int get_buffersize() { return samples_per_buffer; } /* call only valid *after* open() */
62 int get_sample_rate() { return sample_rate; }
65 virtual int close()=0;
67 void fill_buffer(int16_t *target_buffer, int16_t *next_target_buffer);
69 bool get_is_open() { return is_open; }
71 virtual void play(int16_t*)=0; /* play blocked */
77 class tX_audiodevice_oss : public tX_audiodevice
85 virtual void play(int16_t*);
95 class tX_audiodevice_alsa : public tX_audiodevice
97 snd_pcm_t *pcm_handle;
98 snd_pcm_uframes_t period_size;
103 virtual void play(int16_t*);
105 tX_audiodevice_alsa();
112 class tX_jack_client;
114 class tX_audiodevice_jack : public tX_audiodevice
117 tX_jack_client *client;
118 jack_default_audio_sample_t *overrun_buffer;
119 int samples_in_overrun_buffer;
124 virtual void play(int16_t*);
125 virtual void start();
126 void fill_frames(jack_default_audio_sample_t *left, jack_default_audio_sample_t *right, jack_nframes_t nframes);
128 tX_audiodevice_jack();
135 static tX_jack_client *get_instance() { return instance; };
140 static tX_jack_client *instance;
141 static void error(const char *desc);
142 static int srate(jack_nframes_t nframes, void *arg);
143 static void shutdown(void *arg);
144 static int process(jack_nframes_t nframes, void *arg);
146 jack_client_t *client;
147 tX_audiodevice_jack *device;
148 jack_port_t *left_port;
149 jack_port_t *right_port;
150 int play(jack_nframes_t nframes);
153 int get_sample_rate();
154 void set_device(tX_audiodevice_jack *dev) { device=dev; }