/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using Tizen.Internals.Errors;
namespace Tizen.Multimedia
{
internal enum AudioManagerError
{
SoundManagerError = -0x01960000,
///
/// Successful
///
None = ErrorCode.None,
///
/// Out of memory
///
OutOfMemory = ErrorCode.OutOfMemory,
///
/// Invalid parameter
///
InvalidParameter = ErrorCode.InvalidParameter,
///
/// Invalid operation
///
InvalidOperation = ErrorCode.InvalidOperation,
///
/// Permission denied
///
PermissionDenied = ErrorCode.PermissionDenied,
///
/// Not supported
///
NotSupported = ErrorCode.NotSupported,
///
/// No data
///
NoData = ErrorCode.NoData,
///
/// Internal error inside the sound system
///
Internal = SoundManagerError | 01,
///
/// Noncompliance with the sound system policy
///
Policy = SoundManagerError | 02,
///
/// No playing sound
///
NoPlayingSound = SoundManagerError | 03,
///
/// Invalid state (Since 3.0)
///
InvalidState = SoundManagerError | 04
}
internal static class AudioManagerErrorExtensions
{
internal static void Validate(this AudioManagerError err, string msg)
{
if (err == AudioManagerError.None)
{
return;
}
msg = msg ?? "";
msg += $" : {err}.";
switch (err)
{
case AudioManagerError.OutOfMemory:
throw new OutOfMemoryException(msg);
case AudioManagerError.InvalidParameter:
throw new ArgumentException(msg);
case AudioManagerError.PermissionDenied:
throw new UnauthorizedAccessException(msg);
case AudioManagerError.NotSupported:
throw new NotSupportedException(msg);
case AudioManagerError.Policy:
throw new AudioPolicyException(msg);
case AudioManagerError.NoData:
// TODO check when it is thrown
throw new InvalidOperationException(msg);
case AudioManagerError.Internal:
case AudioManagerError.InvalidOperation:
case AudioManagerError.NoPlayingSound:
case AudioManagerError.InvalidState:
throw new InvalidOperationException(msg);
default:
throw new InvalidOperationException("Unknown Error : " + msg);
}
}
}
}