xref: /haiku/src/add-ons/media/media-add-ons/mixer/MixerSettings.h (revision 9e25244c5e9051f6cd333820d6332397361abd6c)
1 /*
2  * Copyright 2007 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _MIXER_SETTINGS_H
6 #define _MIXER_SETTINGS_H
7 
8 
9 #include <Message.h>
10 #include <Path.h>
11 
12 class BLocker;
13 class MixerInput;
14 class MixerOutput;
15 
16 
17 #define MAX_INPUT_SETTINGS	50
18 
19 class MixerSettings {
20 	public:
21 										MixerSettings();
22 										~MixerSettings();
23 
24 		void							SetSettingsFile(const char *file);
25 
26 		bool							AttenuateOutput();
27 		void							SetAttenuateOutput(bool yesno);
28 
29 		bool							UseBalanceControl();
30 		void							SetUseBalanceControl(bool yesno);
31 
32 		bool							AllowOutputChannelRemapping();
33 		void							SetAllowOutputChannelRemapping(bool yesno);
34 
35 		bool							AllowInputChannelRemapping();
36 		void							SetAllowInputChannelRemapping(bool yesno);
37 
38 		int								InputGainControls();
39 		void							SetInputGainControls(int value);
40 
41 		int								ResamplingAlgorithm();
42 		void							SetResamplingAlgorithm(int value);
43 
44 		bool							RefuseOutputFormatChange();
45 		void							SetRefuseOutputFormatChange(bool yesno);
46 
47 		bool							RefuseInputFormatChange();
48 		void							SetRefuseInputFormatChange(bool yesno);
49 
50 		void							SaveConnectionSettings(MixerInput *input);
51 		void							LoadConnectionSettings(MixerInput *input);
52 
53 		void							SaveConnectionSettings(MixerOutput *output);
54 		void							LoadConnectionSettings(MixerOutput *output);
55 
56 	protected:
57 		void							StartDeferredSave();
58 		void							StopDeferredSave();
59 
60 		void							Save();
61 		void							Load();
62 
63 		static int32 					_save_thread_(void *arg);
64 		void 							SaveThread();
65 
66 		BLocker							*fLocker;
67 		BPath							*fSettingsFile;
68 		volatile bool					fSettingsDirty;
69 		volatile bigtime_t				fSettingsLastChange;
70 		volatile thread_id				fSaveThread;
71 		volatile sem_id					fSaveThreadWaitSem;
72 		volatile bool					fSaveThreadRunning;
73 
74 		struct settings {
75 			bool	AttenuateOutput;
76 			bool	UseBalanceControl;
77 			bool	AllowOutputChannelRemapping;
78 			bool	AllowInputChannelRemapping;
79 			int		InputGainControls;
80 			int		ResamplingAlgorithm;
81 			bool	RefuseOutputFormatChange;
82 			bool	RefuseInputFormatChange;
83 		};
84 
85 		volatile settings				fSettings;
86 
87 		BMessage						fOutputSetting;
88 		BMessage						fInputSetting[MAX_INPUT_SETTINGS];
89 };
90 
91 #endif	// _MIXER_SETTINGS_H
92