2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License)
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 #include <sound_manager.h>
18 #include <FBaseSysLog.h>
19 #include "FMedia_AudioManagerConvert.h"
27 _AudioManagerConvert::ConvertChannelType(AudioChannelType audioChannelType)
29 switch (audioChannelType)
31 case AUDIO_CHANNEL_TYPE_MONO:
32 return AUDIO_CHANNEL_MONO;
35 case AUDIO_CHANNEL_TYPE_STEREO:
36 return AUDIO_CHANNEL_STEREO;
40 return AUDIO_CHANNEL_STEREO;
47 _AudioManagerConvert::ConvertSampleType(AudioSampleType audioSampleType)
49 switch (audioSampleType)
51 case AUDIO_TYPE_PCM_U8:
52 return AUDIO_SAMPLE_TYPE_U8;
55 case AUDIO_TYPE_PCM_S16_LE:
56 return AUDIO_SAMPLE_TYPE_S16_LE;
60 return AUDIO_SAMPLE_TYPE_S16_LE;
69 _AudioManagerConvert::ConvertChannelTypeAudio(AudioChannelType audioChannelType)
71 switch (audioChannelType)
73 case AUDIO_CHANNEL_TYPE_MONO:
74 return AUDIO_CHANNEL_MONO;
77 case AUDIO_CHANNEL_TYPE_STEREO:
78 return AUDIO_CHANNEL_STEREO;
82 SysLogException(NID_MEDIA, E_UNSUPPORTED_FORMAT, "Audio channel type is invalid.");
83 return AUDIO_CHANNEL_MONO;
89 _AudioManagerConvert::ConvertSampleTypeAudio(AudioSampleType audioSampleType)
91 switch (audioSampleType)
93 case AUDIO_TYPE_PCM_U8:
94 return AUDIO_SAMPLE_TYPE_U8;
97 case AUDIO_TYPE_PCM_S16_LE:
98 return AUDIO_SAMPLE_TYPE_S16_LE;
102 SysLogException(NID_MEDIA, E_UNSUPPORTED_FORMAT, "Audio sample type is invalid.");
103 return AUDIO_SAMPLE_TYPE_S16_LE;
110 _AudioManagerConvert::CovertSoundManagerError2Result(int error)
114 case SOUND_MANAGER_ERROR_NONE:
116 case SOUND_MANAGER_ERROR_OUT_OF_MEMORY:
117 return E_OUT_OF_MEMORY;
118 case SOUND_MANAGER_ERROR_INVALID_PARAMETER:
119 return E_INVALID_ARG;
120 case SOUND_MANAGER_ERROR_INVALID_OPERATION:
122 case SOUND_MANAGER_ERROR_NO_PLAYING_SOUND:
130 _AudioManagerConvert::ConvertAudioStreamType2SoundType(AudioStreamType type)
134 case AUDIO_STREAM_TYPE_NO_SOUND:
135 return SOUND_TYPE_MEDIA;
137 case AUDIO_STREAM_TYPE_SYSTEM:
138 return SOUND_TYPE_SYSTEM;
140 case AUDIO_STREAM_TYPE_NOTIFICATION:
141 return SOUND_TYPE_NOTIFICATION;
143 case AUDIO_STREAM_TYPE_ALARM:
144 return SOUND_TYPE_ALARM;
146 case AUDIO_STREAM_TYPE_RINGTONE:
147 return SOUND_TYPE_RINGTONE;
149 case AUDIO_STREAM_TYPE_MEDIA:
150 return SOUND_TYPE_MEDIA;
152 case AUDIO_STREAM_TYPE_CALL:
153 return SOUND_TYPE_CALL;
156 return SOUND_TYPE_MEDIA;