00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00032 #ifndef __INCHANNELS_H__
00033 #define __INCHANNELS_H__
00034
00035 #define MP3CHAN 1
00036 #define OGGCHAN 2
00037
00038 #include <pthread.h>
00039
00040
00041 #include <generic.h>
00042 #include <decoder.h>
00043 #include <playlist.h>
00044 #include <pipe.h>
00045
00046 struct timecode {
00047 int h;
00048 int m;
00049 int s;
00050 float f;
00051 };
00052
00053
00054
00055 typedef int (Resampler )(IN_DATATYPE*, IN_DATATYPE*, IN_DATATYPE*, unsigned num, float volume);
00056
00057
00058
00059
00060
00061
00062
00063 class Channel {
00064
00065 private:
00066
00067 IN_DATATYPE *resample(IN_DATATYPE *audio);
00068
00069 IN_DATATYPE buffo[IN_CHUNK*32];
00070
00071 IN_DATATYPE prev_smp[4];
00072
00073 Resampler *munch;
00074
00075
00076 bool idle;
00077
00078
00079 void _thread_init();
00080 void _thread_destroy();
00081 pthread_t _thread;
00082 pthread_attr_t _attr;
00083 pthread_mutex_t _mutex;
00084 pthread_cond_t _cond;
00085
00086
00087
00088 int secs;
00089
00090 public:
00091 Channel();
00092 virtual ~Channel();
00093
00094
00095 bool play();
00096 bool stop();
00097
00098
00099
00100
00101
00102
00103
00104 MuseDec *dec;
00105
00106
00107
00108
00109
00110
00111
00112
00113 virtual int load(char *file);
00114
00115
00116 virtual bool pos(float pos);
00117
00118
00119
00120 virtual void clean();
00121
00122
00123
00124
00125 void skip();
00126 float upd_time();
00127 void upd_eos();
00128 void upd_err();
00129
00130 bool set_resampler(MuseDec *ndec);
00131
00132 void report();
00133
00134 Playlist *playlist;
00135
00136 Pipe *erbapipa;
00137
00138 float volume;
00139 float position;
00140 int speed;
00141 struct timecode time;
00142
00143 char lcd[64];
00144
00145
00146 float state;
00147
00148
00149
00150
00151
00152
00153 int frames;
00154
00155 uint8_t playmode;
00156
00157 bool opened;
00158 bool on;
00159 bool update;
00160 bool seekable;
00161 bool running;
00162 bool quit;
00163 bool fill_prev_smp;
00164
00165
00166
00167
00168 void start() {
00169 pthread_create(&_thread, &_attr, &kickoff, this); };
00170 void run();
00171 void lock() { pthread_mutex_lock(&_mutex); };
00172 void unlock() { pthread_mutex_unlock(&_mutex); };
00173 void wait() { pthread_cond_wait(&_cond,&_mutex); };
00174 void signal() { pthread_cond_signal(&_cond); };
00175
00176
00177 protected:
00178 static void* kickoff(void *arg) { ((Channel *) arg)->run(); return NULL; };
00179
00180 };
00181
00182
00183
00184 class LiveIn {
00185 private:
00186 int *dsp;
00187 unsigned int num_samples;
00188 int sample_rate;
00189 int opt;
00190
00191 int get_audio();
00192
00193 public:
00194 LiveIn();
00195 ~LiveIn();
00196
00197 void init(int smpr, int chans, int *thedsp);
00198 int mix(int *mixpcm);
00199
00200 IN_DATATYPE *gotin;
00201 int channels;
00202 int rate;
00203 bool on;
00204 };
00205
00206 #endif