1de6be214SFrançois Revol /* 2de6be214SFrançois Revol * Copyright (c) 2002-2007, Jerome Duval (jerome.duval@free.fr) 3de6be214SFrançois Revol * Distributed under the terms of the MIT License. 4de6be214SFrançois Revol */ 5de6be214SFrançois Revol 6de6be214SFrançois Revol #ifndef _OPENSOUNDDEVICE_H 7de6be214SFrançois Revol #define _OPENSOUNDDEVICE_H 8de6be214SFrançois Revol 9de6be214SFrançois Revol #include <OS.h> 10de6be214SFrançois Revol #include <List.h> 11de6be214SFrançois Revol #include <MediaFormats.h> 12de6be214SFrançois Revol #include <Locker.h> 13de6be214SFrançois Revol #include "soundcard.h" 14de6be214SFrançois Revol 15de6be214SFrançois Revol // 16de6be214SFrançois Revol //#define OSS_PREFIX "/dev/audio/oss/" 17de6be214SFrançois Revol #define OSS_PREFIX "/dev/oss/" 18de6be214SFrançois Revol // should be fixed later 19de6be214SFrançois Revol #define OSS_MIXER_DEV "/dev/mixer" 20de6be214SFrançois Revol 21de6be214SFrançois Revol #define MAX_CONTROLS 128 22de6be214SFrançois Revol #define MAX_CHANNELS 32 23de6be214SFrançois Revol #define NB_BUFFERS 32 24de6be214SFrançois Revol 25*08c82102SStephan Aßmus #define DEFAULT_BUFFER_SIZE 2048 26de6be214SFrançois Revol 27de6be214SFrançois Revol /* define to support encoded audio (AC3, MPEG, ...) when the card supports it */ 28de6be214SFrançois Revol //#define ENABLE_NON_RAW_SUPPORT 1 29de6be214SFrançois Revol //XXX: make it a BParameter ? 30de6be214SFrançois Revol 31de6be214SFrançois Revol #define ENABLE_REC 1 32de6be214SFrançois Revol 33344b8145SFrançois Revol // timeout in OpenSoundNode::RunThread() 34344b8145SFrançois Revol #define MIN_SNOOZING 2000 35344b8145SFrançois Revol 36344b8145SFrançois Revol // pretend we don't drift 37344b8145SFrançois Revol #define DISABLE_DRIFT 1 38344b8145SFrançois Revol 39344b8145SFrançois Revol 40de6be214SFrançois Revol /* bit mask of supported formats for raw_audio */ 41de6be214SFrançois Revol /* also used to mark the raw_audio node input&outputs */ 42de6be214SFrançois Revol //XXX: _OE ? 43de6be214SFrançois Revol #define AFMT_SUPPORTED_PCM (AFMT_U8|AFMT_S8|\ 44de6be214SFrançois Revol AFMT_S16_NE|\ 45de6be214SFrançois Revol AFMT_S24_NE|AFMT_S32_NE|\ 46de6be214SFrançois Revol AFMT_S16_OE|\ 47de6be214SFrançois Revol AFMT_S24_OE|AFMT_S32_OE|\ 48de6be214SFrançois Revol AFMT_FLOAT) 49de6be214SFrançois Revol 50de6be214SFrançois Revol 51de6be214SFrançois Revol extern const int gSupportedFormats[]; 52de6be214SFrançois Revol extern const char *gSupportedFormatsNames[]; 53de6be214SFrançois Revol 54de6be214SFrançois Revol class OpenSoundDeviceEngine; 55de6be214SFrançois Revol class OpenSoundDeviceMixer; 56de6be214SFrançois Revol 57de6be214SFrançois Revol 58de6be214SFrançois Revol class OpenSoundDevice 59de6be214SFrançois Revol { 60de6be214SFrançois Revol public: 61de6be214SFrançois Revol explicit OpenSoundDevice(oss_card_info *cardinfo); 62de6be214SFrançois Revol virtual ~OpenSoundDevice(void); 63de6be214SFrançois Revol 64de6be214SFrançois Revol status_t InitDriver(); 65de6be214SFrançois Revol virtual status_t InitCheck(void) const; 66de6be214SFrançois Revol 67de6be214SFrançois Revol status_t AddEngine(oss_audioinfo *info); 68de6be214SFrançois Revol status_t AddMixer(oss_mixerinfo *info); 69de6be214SFrançois Revol // status_t AddMidi(); 70de6be214SFrançois Revol 71de6be214SFrançois Revol int32 CountEngines(); 72de6be214SFrançois Revol int32 CountMixers(); 73de6be214SFrançois Revol OpenSoundDeviceEngine *EngineAt(int32 i); 74de6be214SFrançois Revol OpenSoundDeviceMixer *MixerAt(int32 i); 75de6be214SFrançois Revol 76de6be214SFrançois Revol OpenSoundDeviceEngine *NextFreeEngineAt(int32 i, bool rec=false); 77de6be214SFrançois Revol Locker()78de6be214SFrançois Revol BLocker *Locker() { return &fLocker; }; 79de6be214SFrançois Revol 80de6be214SFrançois Revol static float convert_oss_rate_to_media_rate(int rate); 81de6be214SFrançois Revol static int convert_media_rate_to_oss_rate(float rate); 82de6be214SFrançois Revol static uint32 convert_oss_format_to_media_format(int fmt); 83de6be214SFrançois Revol static int convert_oss_format_to_endian(int fmt); 84de6be214SFrançois Revol static int16 convert_oss_format_to_valid_bits(int fmt); 85de6be214SFrançois Revol static int convert_media_format_to_oss_format(uint32 fmt); 86de6be214SFrançois Revol static int select_oss_rate(const oss_audioinfo *info, int rate); 87de6be214SFrançois Revol static int select_oss_format(int fmt); 88de6be214SFrançois Revol 89de6be214SFrançois Revol static status_t get_media_format_description_for(int fmt, media_format_description *desc, int count=1); 90de6be214SFrançois Revol static status_t register_media_formats(); 91de6be214SFrançois Revol static status_t get_media_format_for(int fmt, media_format &format); 92de6be214SFrançois Revol 93de6be214SFrançois Revol public: 94de6be214SFrançois Revol oss_card_info fCardInfo; 95de6be214SFrançois Revol 96de6be214SFrançois Revol private: 97de6be214SFrançois Revol status_t fInitCheckStatus; 98de6be214SFrançois Revol BList fEngines; 99de6be214SFrançois Revol BList fMixers; 100de6be214SFrançois Revol friend class OpenSoundNode; // ugly 101de6be214SFrançois Revol friend class OpenSoundDeviceEngine; // ugly 102de6be214SFrançois Revol audio_buf_info fFragments; 103de6be214SFrançois Revol BLocker fLocker; 104de6be214SFrançois Revol }; 105de6be214SFrançois Revol 106de6be214SFrançois Revol #endif 107