xref: /haiku/src/add-ons/media/media-add-ons/mixer/MixerSettings.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
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							NonLinearGainSlider();
30 		void							SetNonLinearGainSlider(bool yesno);
31 
32 		bool							UseBalanceControl();
33 		void							SetUseBalanceControl(bool yesno);
34 
35 		bool							AllowOutputChannelRemapping();
36 		void							SetAllowOutputChannelRemapping(bool yesno);
37 
38 		bool							AllowInputChannelRemapping();
39 		void							SetAllowInputChannelRemapping(bool yesno);
40 
41 		int								InputGainControls();
42 		void							SetInputGainControls(int value);
43 
44 		int								ResamplingAlgorithm();
45 		void							SetResamplingAlgorithm(int value);
46 
47 		bool							RefuseOutputFormatChange();
48 		void							SetRefuseOutputFormatChange(bool yesno);
49 
50 		bool							RefuseInputFormatChange();
51 		void							SetRefuseInputFormatChange(bool yesno);
52 
53 		void							SaveConnectionSettings(MixerInput *input);
54 		void							LoadConnectionSettings(MixerInput *input);
55 
56 		void							SaveConnectionSettings(MixerOutput *output);
57 		void							LoadConnectionSettings(MixerOutput *output);
58 
59 	protected:
60 		void							StartDeferredSave();
61 		void							StopDeferredSave();
62 
63 		void							Save();
64 		void							Load();
65 
66 		static int32 					_save_thread_(void *arg);
67 		void 							SaveThread();
68 
69 		BLocker							*fLocker;
70 		BPath							*fSettingsFile;
71 		volatile bool					fSettingsDirty;
72 		volatile bigtime_t				fSettingsLastChange;
73 		volatile thread_id				fSaveThread;
74 		volatile sem_id					fSaveThreadWaitSem;
75 		volatile bool					fSaveThreadRunning;
76 
77 		struct settings {
78 			bool	AttenuateOutput;
79 			bool	NonLinearGainSlider;
80 			bool	UseBalanceControl;
81 			bool	AllowOutputChannelRemapping;
82 			bool	AllowInputChannelRemapping;
83 			int		InputGainControls;
84 			int		ResamplingAlgorithm;
85 			bool	RefuseOutputFormatChange;
86 			bool	RefuseInputFormatChange;
87 		};
88 
89 		volatile settings				fSettings;
90 
91 		BMessage						fOutputSetting;
92 		BMessage						fInputSetting[MAX_INPUT_SETTINGS];
93 };
94 
95 #endif	// _MIXER_SETTINGS_H
96