00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00029 #ifndef __JMIXER_H
00030 #define __JMIXER_H
00031
00032 #include <math.h>
00033 #include <pthread.h>
00034
00035 #include <inchannels.h>
00036 #include <outchannels.h>
00037 #include <gui.h>
00038
00039 #include <generic.h>
00040
00041 #ifdef HAVE_SCHEDULER
00042 #include "radiosched.h"
00043 #endif
00044
00045 class SoundDevice;
00046
00063 class Stream_mixer {
00064
00065 public:
00066 Stream_mixer();
00068 ~Stream_mixer();
00070
00074
00075
00076
00077
00105 bool create_channel(int ch);
00106
00107 bool delete_channel(int ch);
00108
00126 bool add_to_playlist(int ch, const char *file);
00128
00129 void rem_from_playlist(int ch, int pos);
00131
00132 bool set_channel(int ch, int playlist_pos);
00134
00142 int play_channel(int ch);
00144
00145 bool stop_channel(int ch);
00147
00148 bool pause_channel(int ch);
00150
00151 bool pause_channel(int ch, bool stat);
00153
00154 bool set_volume(int ch, float vol);
00156
00157 void set_all_volumes(float *vol);
00159
00160 void crossfade(int ch1, float vol1, int ch2, float vol2);
00162
00163 bool set_playmode(int ch, int mode);
00165
00166 void set_speed(int ch, int speed);
00168
00169 bool set_position(int ch, float pos);
00171
00172 bool move_song(int ch, int pos, int nch, int npos);
00174
00175 bool set_live(bool stat);
00177
00178 void set_mic_volume(int vol);
00180
00181 bool set_lineout(bool stat);
00183
00185
00186
00187
00200
00221 int create_enc(enum codec enc);
00222
00227 void delete_enc(int id);
00228
00229
00239 OutChannel *get_enc(int id);
00240
00241
00249 bool apply_enc(int id);
00251
00253
00254
00255
00256
00257
00266 void register_gui(GUI *reg_gui);
00267
00268
00269 SoundDevice *snddev;
00270 bool open_soundcard(bool in, bool out);
00271 void close_soundcard();
00272
00274
00275
00289 void cafudda();
00290
00291
00296 bool dsp_ok() { if(dsp>0) return true; else return false; };
00297
00298
00300 Channel *chan[MAX_CHANNELS];
00301
00303 IN_DATATYPE linein_buf[PROCBUF_SIZE];
00304 int linein_samples;
00305 int linein_vol;
00306
00307 LiveIn livein;
00308
00310 Linklist outchans;
00311
00312
00313
00314
00315
00316 OutChannel *lame;
00317 OutChannel *ogg;
00318
00319
00320 bool cli_vumeter;
00321 void cli_vumeter_set(int val);
00322
00323 bool dspout;
00324 bool linein;
00325 bool fileout;
00326 bool quit;
00327
00328
00329
00330
00331
00335 private:
00336
00337 GUI *gui;
00339 bool have_gui;
00341 int dsp;
00342 bool fullduplex;
00343 int max;
00344 int peak[8];
00345 int cpeak;
00346 int idseed;
00347
00348 void updchan(int ch);
00349
00357 void clip_audio(int samples);
00358
00359 OutChannel *out;
00360
00361
00362 int32_t process_buffer[PROCBUF_SIZE];
00363 int16_t audio_buffer[PROCBUF_SIZE];
00364
00365
00367 void lock() { pthread_mutex_lock(&_mutex); };
00368 void unlock() { pthread_mutex_unlock(&_mutex); };
00369 void wait() { pthread_cond_wait(&_cond,&_mutex); };
00370 void signal() { pthread_cond_signal(&_cond); };
00371 pthread_mutex_t _mutex;
00372 pthread_cond_t _cond;
00373
00374 #ifdef HAVE_SCHEDULER
00375 Basic_scheduler *rsched;
00376 public: void register_sched(Basic_scheduler *s) {rsched=s;};
00377 #endif
00378 };
00379
00380 #endif