xref: /haiku/src/add-ons/media/media-add-ons/multi_audio/MultiAudioDevice.h (revision 5115ca085884f7b604a3d607688f0ca20fb7cf57)
1 /*
2  * Copyright (c) 2002-2007, Jerome Duval (jerome.duval@free.fr)
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef _MULTIAUDIODEVICE_H
7 #define _MULTIAUDIODEVICE_H
8 
9 #include "multi_audio.h"
10 
11 #define MAX_CONTROLS	128
12 #define MAX_CHANNELS	32
13 #define NB_BUFFERS		32
14 
15 class MultiAudioDevice
16 {
17 	public:
18 		explicit MultiAudioDevice(const char *name, const char* path);
19 		virtual ~MultiAudioDevice(void);
20 
21 		virtual status_t InitCheck(void) const;
22 
23 		static float convert_multiaudio_rate_to_media_rate(uint32 rate);
24 		static uint32 convert_media_rate_to_multiaudio_rate(float rate);
25 		static uint32 convert_multiaudio_format_to_media_format(uint32 fmt);
26 		static int16 convert_multiaudio_format_to_valid_bits(uint32 fmt);
27 		static uint32 convert_media_format_to_multiaudio_format(uint32 fmt);
28 		static uint32 select_multiaudio_rate(uint32 rate);
29 		static uint32 select_multiaudio_format(uint32 fmt);
30 
31 		int DoBufferExchange(multi_buffer_info *MBI);
32 		int DoSetMix(multi_mix_value_info *MMVI);
33 		int DoGetMix(multi_mix_value_info *MMVI);
34 
35 	private:
36 		status_t			InitDriver();
37 
38 		int						fd; 			//file descriptor for hw driver
39 		char					fDevice_name[32];
40 		char					fDevice_path[32];
41 
42 	public:
43 		multi_description		MD;
44 		multi_channel_info		MCI[MAX_CHANNELS];
45 		multi_format_info 		MFI;
46 		multi_buffer_list 		MBL;
47 
48 		multi_mix_control_info 	MMCI;
49 		multi_mix_control		MMC[MAX_CONTROLS];
50 
51 		buffer_desc		play_buffer_list[NB_BUFFERS * MAX_CHANNELS];
52 		buffer_desc		record_buffer_list[NB_BUFFERS * MAX_CHANNELS];
53 		buffer_desc 	*play_buffer_desc[NB_BUFFERS];
54 		buffer_desc 	*record_buffer_desc[NB_BUFFERS];
55 
56 	private:
57 		status_t 				fInitCheckStatus;
58 };
59 
60 #endif
61