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 Intels 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:mixacpmp3 11 * @short_description: Audio configuration parameters for MP3 audio. 12 * @include: mixacpmp3.h 13 * 14 * A data object which stores audio specific parameters for MP3 audio. 15 * 16 * Additional parameters must be set in the parent object #MixAudioConfigParams 17 */ 18 19 #include "mixacpmp3.h" 20 21 static GType _mix_acp_mp3_type = 0; 22 static MixAudioConfigParamsClass *parent_class = NULL; 23 24 #define _do_init { _mix_acp_mp3_type = g_define_type_id; } 25 26 gboolean mix_acp_mp3_copy(MixParams* target, const MixParams *src); 27 MixParams* mix_acp_mp3_dup(const MixParams *obj); 28 gboolean mix_acp_mp3_equal(MixParams* first, MixParams *second); 29 static void mix_acp_mp3_finalize(MixParams *obj); 30 31 G_DEFINE_TYPE_WITH_CODE(MixAudioConfigParamsMP3, mix_acp_mp3, MIX_TYPE_AUDIOCONFIGPARAMS, _do_init); 32 33 static void mix_acp_mp3_init (MixAudioConfigParamsMP3 *self) 34 { 35 self->CRC=FALSE; 36 self->MPEG_format=0; 37 self->MPEG_layer=0; 38 } 39 40 static void mix_acp_mp3_class_init(MixAudioConfigParamsMP3Class *klass) 41 { 42 MixParamsClass *mixparams_class = MIX_PARAMS_CLASS(klass); 43 44 /* setup static parent class */ 45 parent_class = (MixAudioConfigParamsClass *) g_type_class_peek_parent (klass); 46 47 mixparams_class->finalize = mix_acp_mp3_finalize; 48 mixparams_class->copy = (MixParamsCopyFunction)mix_acp_mp3_copy; 49 mixparams_class->dup = (MixParamsDupFunction)mix_acp_mp3_dup; 50 mixparams_class->equal = (MixParamsEqualFunction)mix_acp_mp3_equal; 51 } 52 53 MixAudioConfigParamsMP3 *mix_acp_mp3_new(void) 54 { 55 MixAudioConfigParamsMP3 *ret = (MixAudioConfigParamsMP3 *)g_type_create_instance (MIX_TYPE_AUDIOCONFIGPARAMSMP3); 56 57 return ret; 58 } 59 60 void mix_acp_mp3_finalize(MixParams *obj) 61 { 62 /* clean up here. */ 63 64 /* Chain up parent */ 65 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class); 66 if (klass->finalize) 67 klass->finalize(obj); 68 } 69 70 MixAudioConfigParamsMP3 *mix_acp_mp3_ref(MixAudioConfigParamsMP3 *mix) 71 { 72 if (G_UNLIKELY(!mix)) return NULL; 73 return (MixAudioConfigParamsMP3*)mix_params_ref(MIX_PARAMS(mix)); 74 } 75 76 /** 77 * mix_acp_mp3_dup: 78 * @obj: a #MixAudioConfigParamsMP3 object 79 * @returns: a newly allocated duplicate of the object. 80 * 81 * Copy duplicate of the object. 82 */ 83 MixParams* mix_acp_mp3_dup(const MixParams *obj) 84 { 85 MixParams *ret = NULL; 86 87 if (MIX_IS_AUDIOCONFIGPARAMSMP3(obj)) 88 { 89 MixAudioConfigParamsMP3 *duplicate = mix_acp_mp3_new(); 90 if (mix_acp_mp3_copy(MIX_PARAMS(duplicate), MIX_PARAMS(obj))) 91 { 92 ret = MIX_PARAMS(duplicate); 93 } 94 else 95 { 96 mix_acp_mp3_unref(duplicate); 97 } 98 } 99 100 return ret; 101 } 102 103 /** 104 * mix_acp_mp3_copy: 105 * @target: copy to target 106 * @src: copy from src 107 * @returns: boolean indicates if copy is successful. 108 * 109 * Copy instance data from @src to @target. 110 */ 111 gboolean mix_acp_mp3_copy(MixParams* target, const MixParams *src) 112 { 113 if (MIX_IS_AUDIOCONFIGPARAMSMP3(target) && MIX_IS_AUDIOCONFIGPARAMSMP3(src)) 114 { 115 MixAudioConfigParamsMP3 *t = MIX_AUDIOCONFIGPARAMSMP3(target); 116 MixAudioConfigParamsMP3 *s = MIX_AUDIOCONFIGPARAMSMP3(src); 117 118 t->CRC = s->CRC; 119 t->MPEG_format = s->MPEG_format; 120 t->MPEG_layer = s->MPEG_layer; 121 122 // Now chainup base class 123 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class); 124 if (klass->copy) 125 { 126 return klass->copy(MIX_PARAMS_CAST(target), MIX_PARAMS_CAST(src)); 127 } 128 else 129 return TRUE; 130 } 131 return FALSE; 132 } 133 134 /** 135 * mix_acp_mp3_equal: 136 * @first: first object to compare 137 * @second: seond object to compare 138 * @returns: boolean indicates if instance are equal. 139 * 140 * Copy instance data from @src to @target. 141 */ 142 gboolean mix_acp_mp3_equal(MixParams* first, MixParams *second) 143 { 144 gboolean ret = FALSE; 145 146 if (first && second) 147 { 148 if (first == second) return TRUE; 149 } 150 else 151 { 152 return FALSE; 153 } 154 155 // members within this scope equal. chaining up. 156 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class); 157 if (klass->equal) 158 ret = klass->equal(first, second); 159 else 160 ret = TRUE; 161 162 if (ret && MIX_IS_AUDIOCONFIGPARAMSMP3(first) && MIX_IS_AUDIOCONFIGPARAMSMP3(second)) 163 { 164 MixAudioConfigParamsMP3 *acp1 = MIX_AUDIOCONFIGPARAMSMP3(first); 165 MixAudioConfigParamsMP3 *acp2 = MIX_AUDIOCONFIGPARAMSMP3(second); 166 167 ret = (acp1->CRC == acp2->CRC) && 168 (acp1->MPEG_format == acp2->MPEG_format) && 169 (acp1->MPEG_layer == acp2->MPEG_layer); 170 } 171 172 return ret; 173 } 174 175 176