#ifndef __FilePlayer_H__ #define __FilePlayer_H__ #include "arplayer.h" #include "VirtualRingBuffer.h" #include #include #include #include #include #include class FilePlayer: public ARPlayer { public: pthread_mutex_t fillMutex; FilePlayer(unsigned long); ~FilePlayer(void); unsigned char load(const char *thePath); void start(void); void stop(void); void volChange(float); void setPosition(float); void setStatus(unsigned long); private: char *path; pthread_mutex_t timeMutex; pthread_cond_t fillSemaphore; pthread_t fillerThread; unsigned char quitFiller; Movie movie; Media media; TimeValue mediaDuration; // in arbitrary 'units' TimeScale mediaTimeScale; // units per second TimeValue currentMediaTime; // in 'units' TimeValue startTime; // Media starting time for the soundconverter double bytesConverted; // number of output bytes the soundconverter has generated from startTime SoundConverter soundConverter; SoundConverterFillBufferDataUPP soundConverterBufferFillerUPP; ExtendedSoundComponentData converterSourceSoundComponentData; Handle converterSourceSampleDataHandle; unsigned long SampleSize; // bytes per sample used in the ring buffer unsigned long ringSize; // ring buffer size in Bytes float sampleRate; // ring buffer sample rate double BufferBytesPerSec; // ring buffer byte rate VirtualRingBuffer *ringBuffer; // status calls void getDuration(void); void bufferTime(void); void playbackPosition(void); // Reading file as a QuickTime movie unsigned char openFileAsMovie(void); unsigned char getMovieSoundFormat(SoundComponentData*, AudioFormatAtomPtr*); // Using the SoundConverter to translate from file samples to the audio output's format unsigned char startSoundConverter(const SoundComponentData*, const SoundComponentData*, AudioFormatAtomPtr); void stopSoundConverter(void); static unsigned char fillSoundConverterBuffer(SoundComponentDataPtr*, void*); // CoreAudio output unsigned char getOutputSoundConverterFormat(SoundComponentData*); unsigned char setUpAudioOutput(void); unsigned char startAudioOutput(void); UnsignedFixed ConvertdoubleToUnsignedFixed(double); // File reading thread static void *fillRingBufferInThread(void *); void convertIntoRingBuffer(void); // Audio playback thread static OSStatus renderCallback(void*, AudioUnitRenderActionFlags*, const AudioTimeStamp*, unsigned long, unsigned long, AudioBufferList*); }; #endif //__FilePlayer_H__