4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include "avsys-audio-shm.h"
23 #include "avsys-common.h"
24 #include "avsys-error.h"
25 #include "avsys-audio-handle.h"
26 #include "avsys-audio-path.h"
27 #include "avsys-audio-logical-volume.h"
29 #define SHM_KEY_PATH "/tmp"
32 avsys_shm_param_t param;
34 } _avsys_audio_shm_control_t;
36 static _avsys_audio_shm_control_t g_presettings[AVSYS_AUDIO_SHM_IDEN_CNT] = {
37 {{SHM_KEY_PATH, AVSYS_KEY_PREFIX_GEN(AVSYS_KEY_PREFIX_AUDIO,AVSYS_AUDIO_SHM_IDEN_HANDLE) + 0x10,sizeof(avsys_audio_handle_info_t)}, NULL},
38 {{SHM_KEY_PATH, AVSYS_KEY_PREFIX_GEN(AVSYS_KEY_PREFIX_AUDIO,AVSYS_AUDIO_SHM_IDEN_PATH) + 0x10,sizeof(avsys_audio_path_ex_info_t)}, NULL},
39 {{SHM_KEY_PATH, AVSYS_KEY_PREFIX_GEN(AVSYS_KEY_PREFIX_AUDIO,AVSYS_AUDIO_SHM_IDEN_LVOLUME) + 0x10,sizeof(avsys_audio_lvol_info_t)}, NULL},
42 int avsys_audio_create_shm(const avsys_audio_shm_iden_t iden)
44 if (iden >= AVSYS_AUDIO_SHM_IDEN_CNT || 0 > iden)
45 return AVSYS_STATE_ERR_INVALID_PARAMETER;
46 return avsys_create_shm(&g_presettings[iden].param);
49 int avsys_audio_remove_shm(const avsys_audio_shm_iden_t iden)
51 if (iden >= AVSYS_AUDIO_SHM_IDEN_CNT || 0 > iden)
52 return AVSYS_STATE_ERR_INVALID_PARAMETER;
53 g_presettings[iden].pdst = NULL;
54 return avsys_remove_shm(&g_presettings[iden].param);
57 int avsys_audio_get_shm(const avsys_audio_shm_iden_t iden, void **ptr)
59 if (iden >= AVSYS_AUDIO_SHM_IDEN_CNT || 0 > iden)
60 return AVSYS_STATE_ERR_INVALID_PARAMETER;
63 return AVSYS_STATE_ERR_NULL_POINTER;
65 if (!g_presettings[iden].pdst) {
66 g_presettings[iden].pdst = avsys_get_shm(&g_presettings[iden].param);
67 if (!g_presettings[iden].pdst)
68 return AVSYS_STATE_ERR_INTERNAL;
70 *ptr = (void *)g_presettings[iden].pdst;
71 return AVSYS_STATE_SUCCESS;