@@ -6,11 +6,11 @@ namespace SpotifyAPI.Local
66{
77 internal class VolumeMixerControl
88 {
9- private const String SPOTIFY_PROCESS_NAME = "spotify" ;
9+ private const String SpotifyProcessName = "spotify" ;
1010
1111 internal static float GetSpotifyVolume ( )
1212 {
13- Process [ ] p = Process . GetProcessesByName ( SPOTIFY_PROCESS_NAME ) ;
13+ Process [ ] p = Process . GetProcessesByName ( SpotifyProcessName ) ;
1414 if ( p . Length == 0 )
1515 throw new Exception ( "Spotify process is not running or was not found!" ) ;
1616
@@ -19,7 +19,6 @@ internal static float GetSpotifyVolume()
1919 ISimpleAudioVolume volume = GetVolumeObject ( pid ) ;
2020 if ( volume == null )
2121 {
22- Marshal . ReleaseComObject ( volume ) ;
2322 throw new COMException ( "Volume object creation failed" ) ;
2423 }
2524
@@ -31,7 +30,7 @@ internal static float GetSpotifyVolume()
3130
3231 internal static bool IsSpotifyMuted ( )
3332 {
34- Process [ ] p = Process . GetProcessesByName ( SPOTIFY_PROCESS_NAME ) ;
33+ Process [ ] p = Process . GetProcessesByName ( SpotifyProcessName ) ;
3534 if ( p . Length == 0 )
3635 throw new Exception ( "Spotify process is not running or was not found!" ) ;
3736
@@ -40,7 +39,6 @@ internal static bool IsSpotifyMuted()
4039 ISimpleAudioVolume volume = GetVolumeObject ( pid ) ;
4140 if ( volume == null )
4241 {
43- Marshal . ReleaseComObject ( volume ) ;
4442 throw new COMException ( "Volume object creation failed" ) ;
4543 }
4644
@@ -52,7 +50,7 @@ internal static bool IsSpotifyMuted()
5250
5351 internal static void SetSpotifyVolume ( float level )
5452 {
55- Process [ ] p = Process . GetProcessesByName ( SPOTIFY_PROCESS_NAME ) ;
53+ Process [ ] p = Process . GetProcessesByName ( SpotifyProcessName ) ;
5654 if ( p . Length == 0 )
5755 throw new Exception ( "Spotify process is not running or was not found!" ) ;
5856
@@ -61,7 +59,6 @@ internal static void SetSpotifyVolume(float level)
6159 ISimpleAudioVolume volume = GetVolumeObject ( pid ) ;
6260 if ( volume == null )
6361 {
64- Marshal . ReleaseComObject ( volume ) ;
6562 throw new COMException ( "Volume object creation failed" ) ;
6663 }
6764
@@ -72,7 +69,7 @@ internal static void SetSpotifyVolume(float level)
7269
7370 internal static void MuteSpotify ( bool mute )
7471 {
75- Process [ ] p = Process . GetProcessesByName ( SPOTIFY_PROCESS_NAME ) ;
72+ Process [ ] p = Process . GetProcessesByName ( SpotifyProcessName ) ;
7673 if ( p . Length == 0 )
7774 throw new Exception ( "Spotify process is not running or was not found!" ) ;
7875
@@ -81,7 +78,6 @@ internal static void MuteSpotify(bool mute)
8178 ISimpleAudioVolume volume = GetVolumeObject ( pid ) ;
8279 if ( volume == null )
8380 {
84- Marshal . ReleaseComObject ( volume ) ;
8581 throw new COMException ( "Volume object creation failed" ) ;
8682 }
8783
@@ -93,14 +89,14 @@ internal static void MuteSpotify(bool mute)
9389 private static ISimpleAudioVolume GetVolumeObject ( int pid )
9490 {
9591 // get the speakers (1st render + multimedia) device
96- IMMDeviceEnumerator deviceEnumerator = ( IMMDeviceEnumerator ) ( new MMDeviceEnumerator ( ) ) ;
97- IMMDevice speakers ;
98- deviceEnumerator . GetDefaultAudioEndpoint ( EDataFlow . eRender , ERole . eMultimedia , out speakers ) ;
92+ IMmDeviceEnumerator deviceEnumerator = ( IMmDeviceEnumerator ) ( new MMDeviceEnumerator ( ) ) ;
93+ IMmDevice speakers ;
94+ deviceEnumerator . GetDefaultAudioEndpoint ( EDataFlow . ERender , ERole . EMultimedia , out speakers ) ;
9995
10096 // activate the session manager. we need the enumerator
101- Guid IID_IAudioSessionManager2 = typeof ( IAudioSessionManager2 ) . GUID ;
97+ Guid iidIAudioSessionManager2 = typeof ( IAudioSessionManager2 ) . GUID ;
10298 object o ;
103- speakers . Activate ( ref IID_IAudioSessionManager2 , 0 , IntPtr . Zero , out o ) ;
99+ speakers . Activate ( ref iidIAudioSessionManager2 , 0 , IntPtr . Zero , out o ) ;
104100 IAudioSessionManager2 mgr = ( IAudioSessionManager2 ) o ;
105101
106102 // enumerate sessions for on this device
@@ -121,7 +117,7 @@ private static ISimpleAudioVolume GetVolumeObject(int pid)
121117
122118 if ( cpid == pid )
123119 {
124- volumeControl = ctl as ISimpleAudioVolume ;
120+ volumeControl = ( ISimpleAudioVolume ) ctl ;
125121 break ;
126122 }
127123 Marshal . ReleaseComObject ( ctl ) ;
@@ -142,31 +138,31 @@ private class MMDeviceEnumerator
142138
143139 private enum EDataFlow
144140 {
145- eRender ,
146- eCapture ,
147- eAll ,
148- EDataFlow_enum_count
141+ ERender ,
142+ ECapture ,
143+ EAll ,
144+ EDataFlowEnumCount
149145 }
150146
151147 private enum ERole
152148 {
153- eConsole ,
154- eMultimedia ,
155- eCommunications ,
156- ERole_enum_count
149+ EConsole ,
150+ EMultimedia ,
151+ ECommunications ,
152+ ERoleEnumCount
157153 }
158154
159155 [ Guid ( "A95664D2-9614-4F35-A746-DE8DB63617E6" ) , InterfaceType ( ComInterfaceType . InterfaceIsIUnknown ) ]
160- private interface IMMDeviceEnumerator
156+ private interface IMmDeviceEnumerator
161157 {
162158 int NotImpl1 ( ) ;
163159
164160 [ PreserveSig ]
165- int GetDefaultAudioEndpoint ( EDataFlow dataFlow , ERole role , out IMMDevice ppDevice ) ;
161+ int GetDefaultAudioEndpoint ( EDataFlow dataFlow , ERole role , out IMmDevice ppDevice ) ;
166162 }
167163
168164 [ Guid ( "D666063F-1587-4E43-81F1-B948E807363F" ) , InterfaceType ( ComInterfaceType . InterfaceIsIUnknown ) ]
169- private interface IMMDevice
165+ private interface IMmDevice
170166 {
171167 [ PreserveSig ]
172168 int Activate ( ref Guid iid , int dwClsCtx , IntPtr pActivationParams , [ MarshalAs ( UnmanagedType . IUnknown ) ] out object ppInterface ) ;
@@ -180,30 +176,30 @@ private interface IAudioSessionManager2
180176 int NotImpl2 ( ) ;
181177
182178 [ PreserveSig ]
183- int GetSessionEnumerator ( out IAudioSessionEnumerator SessionEnum ) ;
179+ int GetSessionEnumerator ( out IAudioSessionEnumerator sessionEnum ) ;
184180 }
185181
186182 [ Guid ( "E2F5BB11-0570-40CA-ACDD-3AA01277DEE8" ) , InterfaceType ( ComInterfaceType . InterfaceIsIUnknown ) ]
187183 private interface IAudioSessionEnumerator
188184 {
189185 [ PreserveSig ]
190- int GetCount ( out int SessionCount ) ;
186+ int GetCount ( out int sessionCount ) ;
191187
192188 [ PreserveSig ]
193- int GetSession ( int SessionCount , out IAudioSessionControl2 Session ) ;
189+ int GetSession ( int sessionCount , out IAudioSessionControl2 session ) ;
194190 }
195191
196192 [ Guid ( "87CE5498-68D6-44E5-9215-6DA47EF883D8" ) , InterfaceType ( ComInterfaceType . InterfaceIsIUnknown ) ]
197193 private interface ISimpleAudioVolume
198194 {
199195 [ PreserveSig ]
200- int SetMasterVolume ( float fLevel , ref Guid EventContext ) ;
196+ int SetMasterVolume ( float fLevel , ref Guid eventContext ) ;
201197
202198 [ PreserveSig ]
203199 int GetMasterVolume ( out float pfLevel ) ;
204200
205201 [ PreserveSig ]
206- int SetMute ( bool bMute , ref Guid EventContext ) ;
202+ int SetMute ( bool bMute , ref Guid eventContext ) ;
207203
208204 [ PreserveSig ]
209205 int GetMute ( out bool pbMute ) ;
@@ -219,19 +215,19 @@ private interface IAudioSessionControl2
219215 int GetDisplayName ( [ MarshalAs ( UnmanagedType . LPWStr ) ] out string pRetVal ) ;
220216
221217 [ PreserveSig ]
222- int SetDisplayName ( [ MarshalAs ( UnmanagedType . LPWStr ) ] string Value , [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid EventContext ) ;
218+ int SetDisplayName ( [ MarshalAs ( UnmanagedType . LPWStr ) ] string value , [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid eventContext ) ;
223219
224220 [ PreserveSig ]
225221 int GetIconPath ( [ MarshalAs ( UnmanagedType . LPWStr ) ] out string pRetVal ) ;
226222
227223 [ PreserveSig ]
228- int SetIconPath ( [ MarshalAs ( UnmanagedType . LPWStr ) ] string Value , [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid EventContext ) ;
224+ int SetIconPath ( [ MarshalAs ( UnmanagedType . LPWStr ) ] string value , [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid eventContext ) ;
229225
230226 [ PreserveSig ]
231227 int GetGroupingParam ( out Guid pRetVal ) ;
232228
233229 [ PreserveSig ]
234- int SetGroupingParam ( [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid Override , [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid EventContext ) ;
230+ int SetGroupingParam ( [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid Override , [ MarshalAs ( UnmanagedType . LPStruct ) ] Guid eventContext ) ;
235231
236232 [ PreserveSig ]
237233 int NotImpl1 ( ) ;
0 commit comments