00001 #ifndef INPUT_MOD_H
00002 #define INPUT_MOD_H
00003
00004
00005 #include <mikmod.h>
00006 #include <uniform.h>
00007 #include <mplayer.h>
00008 #include "audiere.h"
00009 #include "types.h"
00010 #include "utility.h"
00011
00012
00013
00014
00015 #ifdef WIN32
00016 #define CRT_CALL __cdecl
00017 #else
00018 #define CRT_CALL
00019 #endif
00020
00021
00022 namespace audiere {
00023
00024 class MODInputStream : public UnseekableSource {
00025 public:
00026 MODInputStream();
00027 ~MODInputStream();
00028
00029 bool initialize(File* file);
00030
00031 void ADR_CALL getFormat(
00032 int& channel_count,
00033 int& sample_rate,
00034 SampleFormat& sample_format);
00035 int ADR_CALL read(int frame_count, void* buffer);
00036 void ADR_CALL reset();
00037
00038 private:
00039
00040 static int CRT_CALL MMRead(
00041 void* buffer, size_t size, size_t count, FILE* stream);
00042 static int CRT_CALL MMWrite(
00043 const void* buffer, size_t size, size_t count, FILE* stream);
00044 static int CRT_CALL MMGetC(FILE* stream);
00045 static int CRT_CALL MMPutC(int c, FILE* stream);
00046 static int CRT_CALL MMSeek(FILE* stream, long offset, int origin);
00047 static int CRT_CALL MMTell(FILE* stream);
00048 static int CRT_CALL MMEof(FILE* stream);
00049
00050
00051 static BOOL ADR_IsThere();
00052 static BOOL ADR_Init(MDRIVER* md, uint latency, void* optstr);
00053 static void ADR_Exit(MDRIVER* md);
00054 static void ADR_Update(MDRIVER* md);
00055 static BOOL ADR_SetSoftVoices(MDRIVER* md, uint voices);
00056 static BOOL ADR_SetMode(MDRIVER* md, uint mixspeed, uint mode,
00057 uint channels, uint cpumode);
00058 static void ADR_GetMode(MDRIVER* md, uint* mixspeed, uint* mode,
00059 uint* channels, uint* cpumode);
00060
00061 private:
00062 enum { SAMPLE_BUFFER_SIZE = 4096 };
00063
00064 RefPtr<File> m_file;
00065
00066
00067 MDRIVER* m_driver;
00068 UNIMOD* m_module;
00069 MPLAYER* m_player;
00070
00071 MMSTREAM m_stream;
00072
00073 u32 m_samples_left;
00074 u32* m_next_sample;
00075 u32 m_sample_buffer[SAMPLE_BUFFER_SIZE];
00076
00077 bool m_at_eof;
00078
00079
00080 static MD_DEVICE drv_audiere;
00081 };
00082
00083 }
00084
00085
00086 #endif