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:mixaip 11 * @short_description: Initialization parameters object. 12 * @include: mixacp.h 13 * 14 * A data object which stores initialization specific parameters. 15 * 16 * Not Implemented in Moorestown. 17 */ 18 19 #include "mixaip.h" 20 21 //static GType _mix_aip_type = 0; 22 static MixParamsClass *parent_class = NULL; 23 24 // #define _do_init { _mix_aip_type = g_define_type_id; }; 25 #define _do_init 26 27 gboolean mix_aip_copy(MixParams* target, const MixParams *src); 28 MixParams* mix_aip_dup(const MixParams *obj); 29 gboolean mix_aip_equal(MixParams* first, MixParams *second); 30 static void mix_aip_finalize(MixParams *obj); 31 32 G_DEFINE_TYPE_WITH_CODE(MixAudioInitParams, mix_aip, MIX_TYPE_PARAMS, _do_init ); 33 34 #if 0 35 void _mix_aip_initialize (void) 36 { 37 /* the MixParams types need to be class_ref'd once before it can be 38 * done from multiple threads; 39 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */ 40 g_type_class_ref (mix_aip_get_type ()); 41 } 42 #endif 43 44 static void mix_aip_init (MixAudioInitParams *self) 45 { 46 self->reserved1 = self->reserved2 = self->reserved3 = self->reserved4 = NULL; 47 } 48 49 static void mix_aip_class_init(MixAudioInitParamsClass *klass) 50 { 51 MixParamsClass *mixparams_class = MIX_PARAMS_CLASS(klass); 52 53 /* setup static parent class */ 54 parent_class = (MixParamsClass *) g_type_class_peek_parent (klass); 55 56 mixparams_class->finalize = mix_aip_finalize; 57 mixparams_class->copy = (MixParamsCopyFunction)mix_aip_copy; 58 mixparams_class->dup = (MixParamsDupFunction)mix_aip_dup; 59 mixparams_class->equal = (MixParamsEqualFunction)mix_aip_equal; 60 } 61 62 MixAudioInitParams *mix_aip_new(void) 63 { 64 MixAudioInitParams *ret = (MixAudioInitParams *)g_type_create_instance (MIX_TYPE_AUDIOINITPARAMS); 65 66 return ret; 67 } 68 69 void mix_aip_finalize(MixParams *obj) 70 { 71 /* clean up here. */ 72 73 /* Chain up parent */ 74 if (parent_class->finalize) 75 parent_class->finalize(obj); 76 } 77 78 MixAudioInitParams *mix_aip_ref(MixAudioInitParams *mix) 79 { 80 return (MixAudioInitParams*)mix_params_ref(MIX_PARAMS(mix)); 81 } 82 83 /** 84 * mix_aip_dup: 85 * @obj: a #MixAudioInitParams object 86 * @returns: a newly allocated duplicate of the object. 87 * 88 * Copy duplicate of the object. 89 */ 90 MixParams* mix_aip_dup(const MixParams *obj) 91 { 92 MixParams *ret = NULL; 93 94 if (MIX_IS_AUDIOINITPARAMS(obj)) 95 { 96 MixAudioInitParams *duplicate = mix_aip_new(); 97 if (mix_aip_copy(MIX_PARAMS(duplicate), MIX_PARAMS(obj))) 98 { 99 ret = MIX_PARAMS(duplicate); 100 } 101 else 102 { 103 mix_aip_unref(duplicate); 104 } 105 } 106 107 return ret; 108 } 109 110 /** 111 * mix_aip_copy: 112 * @target: copy to target 113 * @src: copy from src 114 * @returns: boolean indicates if copy is successful. 115 * 116 * Copy instance data from @src to @target. 117 */ 118 gboolean mix_aip_copy(MixParams* target, const MixParams *src) 119 { 120 if (MIX_IS_AUDIOINITPARAMS(target) && MIX_IS_AUDIOINITPARAMS(src)) 121 { 122 // TODO perform copy. 123 // 124 // Now chainup base class 125 // Get the root class from the cached parent_class object. This cached parent_class object has not be overwritten by this current class. 126 // Using the cached parent_class object because this_class would have ->copy pointing to this method! 127 // Cached parent_class contains the class object before it is overwritten by this derive class. 128 // MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class); 129 if (parent_class->copy) 130 { 131 return parent_class->copy(MIX_PARAMS_CAST(target), MIX_PARAMS_CAST(src)); 132 } 133 else 134 return TRUE; 135 } 136 return FALSE; 137 } 138 139 /** 140 * mix_aip_equal: 141 * @first: first object to compare 142 * @second: seond object to compare 143 * @returns: boolean indicates if instance are equal. 144 * 145 * Copy instance data from @src to @target. 146 */ 147 gboolean mix_aip_equal(MixParams* first, MixParams *second) 148 { 149 gboolean ret = FALSE; 150 151 if (MIX_IS_AUDIOINITPARAMS(first) && MIX_IS_AUDIOINITPARAMS(second)) 152 { 153 // TODO: do deep compare 154 155 if (ret) 156 { 157 // members within this scope equal. chaining up. 158 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class); 159 if (klass->equal) 160 ret = parent_class->equal(first, second); 161 else 162 ret = TRUE; 163 } 164 } 165 166 return ret; 167 } 168