1 /*
2 INTEL CONFIDENTIAL
3 Copyright 2009 Intel Corporation All Rights Reserved.
4 The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets and proprietary and confidential information of Intel or its suppliers and licensors. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intel’s prior express written permission.
5
6 No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing.
7 */
8
9 /**
10 * SECTION:mixacpwma
11 * @short_description: Audio parameters for WMA audio.
12 * @include: mixacpwma.h
13 *
14 * A data object which stores audio specific parameters for WMA.
15 *
16 * In Moorestown, only WMA2 is supported.
17 *
18 * Additional parameters must be set in the parent object #MixAudioConfigParams
19 */
20
21 #include "mixacpwma.h"
22
23 static GType _mix_acp_wma_type = 0;
24 static MixAudioConfigParamsClass *parent_class = NULL;
25
26 #define _do_init { _mix_acp_wma_type = g_define_type_id; }
27
28 gboolean mix_acp_wma_copy(MixParams* target, const MixParams *src);
29 MixParams* mix_acp_wma_dup(const MixParams *obj);
30 gboolean mix_acp_wma_equal(MixParams* first, MixParams *second);
31 static void mix_acp_wma_finalize(MixParams *obj);
32
33 G_DEFINE_TYPE_WITH_CODE(MixAudioConfigParamsWMA, mix_acp_wma, MIX_TYPE_AUDIOCONFIGPARAMS, _do_init);
34
mix_acp_wma_init(MixAudioConfigParamsWMA * self)35 static void mix_acp_wma_init (MixAudioConfigParamsWMA *self)
36 {
37 self->channel_mask = 0;
38 self->format_tag = 0;
39 self->block_align = 0;
40 self->wma_encode_opt = 0;
41 self->pcm_bit_width = 0; /* source pcm bit width */
42 self->wma_version = MIX_AUDIO_WMA_VUNKNOWN;
43 }
44
mix_acp_wma_class_init(MixAudioConfigParamsWMAClass * klass)45 static void mix_acp_wma_class_init(MixAudioConfigParamsWMAClass *klass)
46 {
47 MixParamsClass *mixparams_class = MIX_PARAMS_CLASS(klass);
48
49 /* setup static parent class */
50 parent_class = (MixAudioConfigParamsClass *) g_type_class_peek_parent (klass);
51
52 mixparams_class->finalize = mix_acp_wma_finalize;
53 mixparams_class->copy = (MixParamsCopyFunction)mix_acp_wma_copy;
54 mixparams_class->dup = (MixParamsDupFunction)mix_acp_wma_dup;
55 mixparams_class->equal = (MixParamsEqualFunction)mix_acp_wma_equal;
56 }
57
mix_acp_wma_new(void)58 MixAudioConfigParamsWMA *mix_acp_wma_new(void)
59 {
60 MixAudioConfigParamsWMA *ret = (MixAudioConfigParamsWMA *)g_type_create_instance (MIX_TYPE_AUDIOCONFIGPARAMSWMA);
61
62 return ret;
63 }
64
mix_acp_wma_finalize(MixParams * obj)65 void mix_acp_wma_finalize(MixParams *obj)
66 {
67 /* clean up here. */
68
69 /* Chain up parent */
70 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class);
71 if (klass->finalize)
72 klass->finalize(obj);
73 }
74
mix_acp_wma_ref(MixAudioConfigParamsWMA * obj)75 MixAudioConfigParamsWMA *mix_acp_wma_ref(MixAudioConfigParamsWMA *obj)
76 {
77 return (MixAudioConfigParamsWMA*)mix_params_ref(MIX_PARAMS(obj));
78 }
79
80 /**
81 * mix_acp_wma_dup:
82 * @obj: a #MixAudioConfigParamsWMA object
83 * @returns: a newly allocated duplicate of the object.
84 *
85 * Copy duplicate of the object.
86 */
mix_acp_wma_dup(const MixParams * obj)87 MixParams* mix_acp_wma_dup(const MixParams *obj)
88 {
89 MixParams *ret = NULL;
90
91 if (MIX_IS_AUDIOCONFIGPARAMSWMA(obj))
92 {
93 MixAudioConfigParamsWMA *duplicate = mix_acp_wma_new();
94 if (mix_acp_wma_copy(MIX_PARAMS(duplicate), MIX_PARAMS(obj)))
95 {
96 ret = MIX_PARAMS(duplicate);
97 }
98 else
99 {
100 mix_acp_wma_unref(duplicate);
101 }
102 }
103
104 return ret;
105 }
106
107 /**
108 * mix_acp_wma_copy:
109 * @target: copy to target
110 * @src: copy from src
111 * @returns: boolean indicates if copy is successful.
112 *
113 * Copy instance data from @src to @target.
114 */
mix_acp_wma_copy(MixParams * target,const MixParams * src)115 gboolean mix_acp_wma_copy(MixParams* target, const MixParams *src)
116 {
117 if (MIX_IS_AUDIOCONFIGPARAMSWMA(target) && MIX_IS_AUDIOCONFIGPARAMSWMA(src))
118 {
119 MixAudioConfigParamsWMA *t = MIX_AUDIOCONFIGPARAMSWMA(target);
120 MixAudioConfigParamsWMA *s = MIX_AUDIOCONFIGPARAMSWMA(src);
121
122 t->channel_mask = s->channel_mask;
123 t->format_tag = s->format_tag;
124 t->block_align = s->block_align;
125 t->wma_encode_opt = s->wma_encode_opt;
126 t->wma_version = s->wma_version;
127 t->pcm_bit_width = s->pcm_bit_width;
128
129 // Now chainup base class
130 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class);
131 if (klass->copy)
132 {
133 return klass->copy(MIX_PARAMS_CAST(target), MIX_PARAMS_CAST(src));
134 }
135 else
136 return TRUE;
137 }
138 return FALSE;
139 }
140
141 /**
142 * mix_acp_wma_equal:
143 * @first: first object to compare
144 * @second: seond object to compare
145 * @returns: boolean indicates if instance are equal.
146 *
147 * Copy instance data from @src to @target.
148 */
mix_acp_wma_equal(MixParams * first,MixParams * second)149 gboolean mix_acp_wma_equal(MixParams* first, MixParams *second)
150 {
151 gboolean ret = FALSE;
152
153 if (first && second)
154 {
155 if (first == second) return TRUE;
156 }
157 else
158 {
159 return FALSE;
160 }
161
162 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class);
163 if (klass->equal)
164 ret = klass->equal(first, second);
165 else
166 ret = TRUE;
167
168 if (ret && MIX_IS_AUDIOCONFIGPARAMSWMA(first) && MIX_IS_AUDIOCONFIGPARAMSWMA(second))
169 {
170 MixAudioConfigParamsWMA *acp1 = MIX_AUDIOCONFIGPARAMSWMA(first);
171 MixAudioConfigParamsWMA *acp2 = MIX_AUDIOCONFIGPARAMSWMA(second);
172
173 ret = (acp1->channel_mask == acp2->channel_mask) &&
174 (acp1->format_tag == acp2->format_tag) &&
175 (acp1->block_align == acp2->block_align) &&
176 (acp1->wma_encode_opt == acp2->wma_encode_opt) &&
177 (acp1->pcm_bit_width == acp2->pcm_bit_width) &&
178 (acp1->wma_version == acp2->wma_version);
179 }
180
181 return ret;
182 }
183
mix_acp_wma_get_version(MixAudioConfigParamsWMA * obj)184 MixAudioWMAVersion mix_acp_wma_get_version(MixAudioConfigParamsWMA *obj)
185 {
186 if (obj)
187 return (obj->wma_version);
188 else
189 return MIX_AUDIO_WMA_VUNKNOWN;
190 }
191
mix_acp_wma_set_version(MixAudioConfigParamsWMA * obj,MixAudioWMAVersion ver)192 MIX_RESULT mix_acp_wma_set_version(MixAudioConfigParamsWMA *obj, MixAudioWMAVersion ver)
193 {
194 MIX_RESULT ret = MIX_RESULT_SUCCESS;
195
196 if (!obj) return MIX_RESULT_NULL_PTR;
197
198 if ((ver > MIX_AUDIO_WMA_VUNKNOWN) && (ver < MIX_AUDIO_WMA_LAST))
199 obj->wma_version = ver;
200 else
201 ret=MIX_RESULT_INVALID_PARAM;
202
203 return ret;
204 }
205
206