2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using Tizen.Internals.Errors;
20 namespace Tizen.Multimedia
23 /// Enumeration for sound manager's error codes.
25 internal enum AudioManagerError{
27 SoundManagerError = -0x01960000,
31 None = ErrorCode.None,
35 OutOfMemory = ErrorCode.OutOfMemory,
39 InvalidParameter = ErrorCode.InvalidParameter,
43 InvalidOperation = ErrorCode.InvalidOperation,
47 PermissionDenied = ErrorCode.PermissionDenied,
51 NotSupported = ErrorCode.NotSupported,
55 NoData = ErrorCode.NoData,
57 /// Internal error inside the sound system
59 Internal = SoundManagerError | 01,
61 /// Noncompliance with the sound system policy
63 Policy = SoundManagerError | 02,
67 NoPlayingSound = SoundManagerError | 03,
69 /// Invalid state (Since 3.0)
71 InvalidState = SoundManagerError | 04
74 internal static class AudioManagerErrorFactory
76 static internal void CheckAndThrowException(int error, string msg)
78 AudioManagerError e = (AudioManagerError) error;
81 case AudioManagerError.None:
83 case AudioManagerError.OutOfMemory:
84 throw new InvalidOperationException("Out of Memory: " + msg);
85 case AudioManagerError.InvalidParameter:
86 throw new ArgumentException("Invalid Parameter: " + msg);
87 case AudioManagerError.InvalidOperation:
88 throw new InvalidOperationException("Invalid Opertation: " + msg);
89 case AudioManagerError.PermissionDenied:
90 throw new InvalidOperationException("Permission Denied: " + msg);
91 case AudioManagerError.NotSupported:
92 throw new InvalidOperationException("Not Supported: " + msg);
93 case AudioManagerError.NoData:
94 throw new InvalidOperationException("No Data: " + msg);
95 case AudioManagerError.Internal:
96 throw new InvalidOperationException("Internal Error: " + msg);
97 case AudioManagerError.Policy:
98 throw new InvalidOperationException("Noncomplaince with System Sound Policy error: " + msg);
99 case AudioManagerError.NoPlayingSound:
100 throw new InvalidOperationException("No playing sound: " + msg);
101 case AudioManagerError.InvalidState:
102 throw new InvalidOperationException("Invalid State: " + msg);
104 throw new InvalidOperationException("Unknown Error Code: " + msg);
108 static internal void CheckAndThrowException(int error, IntPtr handle, string msg)
110 if (handle == IntPtr.Zero)
112 throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
116 CheckAndThrowException(error, msg);