1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* avsystem
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
*
* 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.
*
*/
#include "avsys-audio-shm.h"
#include "avsys-common.h"
#include "avsys-error.h"
#include "avsys-audio-handle.h"
#include "avsys-audio-path.h"
#include "avsys-audio-logical-volume.h"
#define SHM_KEY_PATH "/tmp"
typedef struct {
avsys_shm_param_t param;
void *pdst;
} _avsys_audio_shm_control_t;
static _avsys_audio_shm_control_t g_presettings[AVSYS_AUDIO_SHM_IDEN_CNT] = {
{{SHM_KEY_PATH, AVSYS_KEY_PREFIX_GEN(AVSYS_KEY_PREFIX_AUDIO,AVSYS_AUDIO_SHM_IDEN_HANDLE) + 0x10,sizeof(avsys_audio_handle_info_t)}, NULL},
{{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},
{{SHM_KEY_PATH, AVSYS_KEY_PREFIX_GEN(AVSYS_KEY_PREFIX_AUDIO,AVSYS_AUDIO_SHM_IDEN_LVOLUME) + 0x10,sizeof(avsys_logical_gain_t) * AVSYS_AUDIO_LVOL_GAIN_TYPE_MAX}, NULL},
};
int avsys_audio_create_shm(const avsys_audio_shm_iden_t iden)
{
if (iden >= AVSYS_AUDIO_SHM_IDEN_CNT || 0 > iden)
return AVSYS_STATE_ERR_INVALID_PARAMETER;
return avsys_create_shm(&g_presettings[iden].param);
}
int avsys_audio_remove_shm(const avsys_audio_shm_iden_t iden)
{
if (iden >= AVSYS_AUDIO_SHM_IDEN_CNT || 0 > iden)
return AVSYS_STATE_ERR_INVALID_PARAMETER;
g_presettings[iden].pdst = NULL;
return avsys_remove_shm(&g_presettings[iden].param);
}
int avsys_audio_get_shm(const avsys_audio_shm_iden_t iden, void **ptr)
{
if (iden >= AVSYS_AUDIO_SHM_IDEN_CNT || 0 > iden)
return AVSYS_STATE_ERR_INVALID_PARAMETER;
if (!ptr)
return AVSYS_STATE_ERR_NULL_POINTER;
if (!g_presettings[iden].pdst) {
g_presettings[iden].pdst = avsys_get_shm(&g_presettings[iden].param);
if (!g_presettings[iden].pdst)
return AVSYS_STATE_ERR_INTERNAL;
}
*ptr = (void *)g_presettings[iden].pdst;
return AVSYS_STATE_SUCCESS;
}
|