2 * Copyright (c) 2002-2007, Jerome Duval (jerome.duval@free.fr)
3 * Distributed under the terms of the MIT License.
6 #ifndef _OPENSOUNDDEVICE_H
7 #define _OPENSOUNDDEVICE_H
11 #include <MediaFormats.h>
13 #include "soundcard.h"
16 //#define OSS_PREFIX "/dev/audio/oss/"
17 #define OSS_PREFIX "/dev/oss/"
18 // should be fixed later
19 #define OSS_MIXER_DEV "/dev/mixer"
21 #define MAX_CONTROLS 128
22 #define MAX_CHANNELS 32
25 #define DEFAULT_BUFFER_SIZE 2048
27 /* define to support encoded audio (AC3, MPEG, ...) when the card supports it */
28 //#define ENABLE_NON_RAW_SUPPORT 1
29 //XXX: make it a BParameter ?
33 // timeout in OpenSoundNode::RunThread()
34 #define MIN_SNOOZING 2000
36 // pretend we don't drift
37 #define DISABLE_DRIFT 1
40 /* bit mask of supported formats for raw_audio */
41 /* also used to mark the raw_audio node input&outputs */
43 #define AFMT_SUPPORTED_PCM (AFMT_U8|AFMT_S8|\
45 AFMT_S24_NE|AFMT_S32_NE|\
47 AFMT_S24_OE|AFMT_S32_OE|\
51 extern const int gSupportedFormats
[];
52 extern const char *gSupportedFormatsNames
[];
54 class OpenSoundDeviceEngine
;
55 class OpenSoundDeviceMixer
;
61 explicit OpenSoundDevice(oss_card_info
*cardinfo
);
62 virtual ~OpenSoundDevice(void);
64 status_t
InitDriver();
65 virtual status_t
InitCheck(void) const;
67 status_t
AddEngine(oss_audioinfo
*info
);
68 status_t
AddMixer(oss_mixerinfo
*info
);
69 // status_t AddMidi();
73 OpenSoundDeviceEngine
*EngineAt(int32 i
);
74 OpenSoundDeviceMixer
*MixerAt(int32 i
);
76 OpenSoundDeviceEngine
*NextFreeEngineAt(int32 i
, bool rec
=false);
78 BLocker
*Locker() { return &fLocker
; };
80 static float convert_oss_rate_to_media_rate(int rate
);
81 static int convert_media_rate_to_oss_rate(float rate
);
82 static uint32
convert_oss_format_to_media_format(int fmt
);
83 static int convert_oss_format_to_endian(int fmt
);
84 static int16
convert_oss_format_to_valid_bits(int fmt
);
85 static int convert_media_format_to_oss_format(uint32 fmt
);
86 static int select_oss_rate(const oss_audioinfo
*info
, int rate
);
87 static int select_oss_format(int fmt
);
89 static status_t
get_media_format_description_for(int fmt
, media_format_description
*desc
, int count
=1);
90 static status_t
register_media_formats();
91 static status_t
get_media_format_for(int fmt
, media_format
&format
);
94 oss_card_info fCardInfo
;
97 status_t fInitCheckStatus
;
100 friend class OpenSoundNode
; // ugly
101 friend class OpenSoundDeviceEngine
; // ugly
102 audio_buf_info fFragments
;