20 #include <assert.h> |
20 #include <assert.h> |
21 #include <string.h> |
21 #include <string.h> |
22 |
22 |
23 #include "xaglobals.h" |
23 #include "xaglobals.h" |
24 #include "xaaudioiodevicecapabilitiesitf.h" |
24 #include "xaaudioiodevicecapabilitiesitf.h" |
25 #ifdef _GSTREAMER_BACKEND_ |
25 #include "xacapabilitiesmgr.h" |
26 #include "XAStaticCapsAdaptation.h" |
26 |
27 #endif |
|
28 |
27 |
29 static XAchar deviceName1[] = "Default Mic"; |
28 static XAchar deviceName1[] = "Default Mic"; |
30 |
29 |
31 /* XAAudIODevCapaItfImpl* GetImpl |
30 /* XAAudIODevCapaItfImpl* GetImpl |
32 * Description: Validate interface pointer and cast it to implementation pointer. |
31 * Description: Validate interface pointer and cast it to implementation pointer. |
74 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
73 DEBUG_ERR("XA_RESULT_BUFFER_INSUFFICIENT"); |
75 res = XA_RESULT_BUFFER_INSUFFICIENT; |
74 res = XA_RESULT_BUFFER_INSUFFICIENT; |
76 } |
75 } |
77 else |
76 else |
78 { |
77 { |
79 |
|
80 #ifdef _GSTREAMER_BACKEND_ |
|
81 XAuint32 i; |
78 XAuint32 i; |
82 XAStaticCapsData temp; |
79 XACapabilities temp; |
83 for( i=0; i<impl->numInputDevices; i++ ) |
80 for( i=0; i<impl->numInputDevices; i++ ) |
84 { |
81 { |
85 /* query device id from adaptation using index value */ |
82 /* query device id from adaptation using index value */ |
86 res = XAStaticCapsAdapt_GetCapsByIdx(XACAP_DEVSRC|XACAP_AUDIO, i, &temp); |
83 res = XACapabilitiesMgr_GetCapsByIdx(impl->capslist, (XACapsType)(XACAP_DEVSRC|XACAP_AUDIO), i, &temp); |
87 pInputDeviceIDs[i] = temp.xaid; |
84 pInputDeviceIDs[i] = temp.xaid; |
88 } |
85 } |
89 #endif |
86 |
90 pInputDeviceIDs[0] = 0xAD7E5001; |
87 pInputDeviceIDs[0] = 0xAD7E5001; |
91 } |
88 } |
92 } |
89 } |
93 *pNumInputs = impl->numInputDevices; |
90 *pNumInputs = impl->numInputDevices; |
94 } |
91 } |
103 XAAudioIODeviceCapabilitiesItf self, |
100 XAAudioIODeviceCapabilitiesItf self, |
104 XAuint32 deviceId, |
101 XAuint32 deviceId, |
105 XAAudioInputDescriptor* pDescriptor) |
102 XAAudioInputDescriptor* pDescriptor) |
106 { |
103 { |
107 XAAudIODevCapaItfImpl* impl = GetImpl(self); |
104 XAAudIODevCapaItfImpl* impl = GetImpl(self); |
|
105 XACapabilities temp; |
108 XAresult res = XA_RESULT_SUCCESS; |
106 XAresult res = XA_RESULT_SUCCESS; |
109 DEBUG_API("->XAAudIODevCapaItfImpl_QueryAudioInputCapabilities"); |
107 DEBUG_API("->XAAudIODevCapaItfImpl_QueryAudioInputCapabilities"); |
110 |
108 |
111 if( !impl || !pDescriptor ) |
109 if( !impl || !pDescriptor ) |
112 { |
110 { |
114 res = XA_RESULT_PARAMETER_INVALID; |
112 res = XA_RESULT_PARAMETER_INVALID; |
115 } |
113 } |
116 else |
114 else |
117 { |
115 { |
118 memset(pDescriptor,0,sizeof(XAAudioInputDescriptor)); |
116 memset(pDescriptor,0,sizeof(XAAudioInputDescriptor)); |
119 #ifdef _GSTREAMER_BACKEND_ |
117 |
120 /* query capabilities from adaptation using device id */ |
118 /* query capabilities from adaptation using device id */ |
121 XAStaticCapsData temp; |
119 |
122 |
120 |
123 res = XAStaticCapsAdapt_GetCapsById(XACAP_DEVSRC|XACAP_AUDIO, deviceId, &temp); |
121 res = XACapabilitiesMgr_GetCapsById(impl->capslist, (XACapsType)(XACAP_DEVSRC|XACAP_AUDIO), deviceId, &temp); |
124 if( res == XA_RESULT_SUCCESS ) |
122 if( res == XA_RESULT_SUCCESS ) |
125 { |
123 { |
|
124 XAAudioInputDescriptor* desc = ((XAAudioInputDescriptor*)(temp.pEntry)); |
126 /* map applicable values to XAAudioCodecCapabilities */ |
125 /* map applicable values to XAAudioCodecCapabilities */ |
127 pDescriptor->maxChannels=temp.maxCh; |
126 pDescriptor->maxChannels=desc->maxChannels; |
128 pDescriptor->minSampleRate=temp.minSR*1000; /* milliHz */ |
127 pDescriptor->minSampleRate=desc->minSampleRate*1000; /* milliHz */ |
129 if (temp.maxSR < (0xFFFFFFFF / 1000)) |
128 if (desc->maxSampleRate < (0xFFFFFFFF / 1000)) |
130 { |
129 { |
131 pDescriptor->maxSampleRate = temp.maxSR*1000; |
130 pDescriptor->maxSampleRate = desc->maxSampleRate*1000; |
132 } |
131 } |
133 else |
132 else |
134 { |
133 { |
135 pDescriptor->maxSampleRate = 0xFFFFFFFF; |
134 pDescriptor->maxSampleRate = 0xFFFFFFFF; |
136 } |
135 } |
139 pDescriptor->deviceScope = XA_DEVSCOPE_ENVIRONMENT; |
138 pDescriptor->deviceScope = XA_DEVSCOPE_ENVIRONMENT; |
140 pDescriptor->deviceLocation = XA_DEVLOCATION_HANDSET; |
139 pDescriptor->deviceLocation = XA_DEVLOCATION_HANDSET; |
141 pDescriptor->deviceName = temp.adaptId; |
140 pDescriptor->deviceName = temp.adaptId; |
142 /* other caps undefined */ |
141 /* other caps undefined */ |
143 } |
142 } |
144 #endif |
143 |
145 switch (deviceId) |
144 switch (deviceId) |
146 { |
145 { |
147 case 0xAD7E5001: |
146 case 0xAD7E5001: |
148 { |
147 { |
149 impl->sampleRateArray[0] = 8000000; |
148 impl->sampleRateArray[0] = 8000000; |
240 res = XA_RESULT_BUFFER_INSUFFICIENT; |
239 res = XA_RESULT_BUFFER_INSUFFICIENT; |
241 } |
240 } |
242 else |
241 else |
243 { |
242 { |
244 |
243 |
245 #ifdef _GSTREAMER_BACKEND_ |
244 |
246 XAuint32 i = 0; |
245 XAuint32 i = 0; |
247 XAStaticCapsData temp; |
246 XACapabilities temp; |
248 for( i=0; i<impl->numOutputDevices; i++ ) |
247 for( i=0; i<impl->numOutputDevices; i++ ) |
249 { |
248 { |
250 /* query device id from adaptation using index value */ |
249 /* query device id from adaptation using index value */ |
251 res = XAStaticCapsAdapt_GetCapsByIdx(XACAP_DEVSNK|XACAP_AUDIO, i, &temp); |
250 res = XACapabilitiesMgr_GetCapsByIdx(impl->capslist, (XACapsType)(XACAP_DEVSNK|XACAP_AUDIO), i, &temp); |
252 pOutputDeviceIDs[i] = temp.xaid; |
251 pOutputDeviceIDs[i] = temp.xaid; |
253 } |
252 } |
254 #endif |
253 |
255 pOutputDeviceIDs[0] = 0xAD7E5002; |
254 pOutputDeviceIDs[0] = 0xAD7E5002; |
256 } |
255 } |
257 } |
256 } |
258 *pNumOutputs = impl->numOutputDevices; |
257 *pNumOutputs = impl->numOutputDevices; |
259 } |
258 } |
270 XAAudioOutputDescriptor* pDescriptor) |
269 XAAudioOutputDescriptor* pDescriptor) |
271 { |
270 { |
272 |
271 |
273 XAAudIODevCapaItfImpl* impl = GetImpl(self); |
272 XAAudIODevCapaItfImpl* impl = GetImpl(self); |
274 XAresult res = XA_RESULT_SUCCESS; |
273 XAresult res = XA_RESULT_SUCCESS; |
|
274 XACapabilities temp; |
275 DEBUG_API("->XAAudIODevCapaItfImpl_QueryAudioOutputCapabilities"); |
275 DEBUG_API("->XAAudIODevCapaItfImpl_QueryAudioOutputCapabilities"); |
276 |
276 |
277 if( !impl || !pDescriptor ) |
277 if( !impl || !pDescriptor ) |
278 { |
278 { |
279 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
279 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
281 } |
281 } |
282 else |
282 else |
283 { |
283 { |
284 memset(pDescriptor,0,sizeof(XAAudioOutputDescriptor)); |
284 memset(pDescriptor,0,sizeof(XAAudioOutputDescriptor)); |
285 /* query capabilities from adaptation using device id */ |
285 /* query capabilities from adaptation using device id */ |
286 #ifdef _GSTREAMER_BACKEND_ |
286 |
287 XAStaticCapsData temp; |
287 |
288 |
288 |
289 res = XAStaticCapsAdapt_GetCapsById(XACAP_DEVSNK|XACAP_AUDIO, deviceId, &temp); |
289 res = XACapabilitiesMgr_GetCapsById(impl->capslist, (XACapsType)(XACAP_DEVSNK|XACAP_AUDIO), deviceId, &temp); |
290 if( res == XA_RESULT_SUCCESS ) |
290 if( res == XA_RESULT_SUCCESS ) |
291 { |
291 { |
|
292 XAAudioOutputDescriptor* desc = ((XAAudioOutputDescriptor*)(temp.pEntry)); |
292 /* map applicable values to XAAudioCodecCapabilities */ |
293 /* map applicable values to XAAudioCodecCapabilities */ |
293 pDescriptor->maxChannels=temp.maxCh; |
294 pDescriptor->maxChannels=desc->maxChannels; |
294 pDescriptor->minSampleRate=temp.minSR*1000; /* milliHz */ |
295 pDescriptor->minSampleRate=desc->minSampleRate*1000; /* milliHz */ |
295 if (temp.maxSR < (0xFFFFFFFF / 1000)) |
296 if (desc->maxSampleRate < (0xFFFFFFFF / 1000)) |
296 { |
297 { |
297 pDescriptor->maxSampleRate = temp.maxSR*1000; |
298 pDescriptor->maxSampleRate = desc->maxSampleRate*1000; |
298 } |
299 } |
299 else |
300 else |
300 { |
301 { |
301 pDescriptor->maxSampleRate = 0xFFFFFFFF; |
302 pDescriptor->maxSampleRate = 0xFFFFFFFF; |
302 } |
303 } |
425 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
426 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
426 res = XA_RESULT_PARAMETER_INVALID; |
427 res = XA_RESULT_PARAMETER_INVALID; |
427 } |
428 } |
428 else |
429 else |
429 { |
430 { |
430 #ifdef _GSTREAMER_BACKEND_ |
431 |
431 XAStaticCapsData temp; |
432 XACapabilities temp; |
432 XAuint32 associatedCount = 0; |
433 XAuint32 associatedCount = 0; |
433 |
434 |
434 XAuint32 i = 0; |
435 XAuint32 i = 0; |
435 for( i=0; i<impl->numInputDevices; i++ ) |
436 for( i=0; i<impl->numInputDevices; i++ ) |
436 { |
437 { |
437 /* query device id from adaptation using index value */ |
438 /* query device id from adaptation using index value */ |
438 res = XAStaticCapsAdapt_GetCapsByIdx(XACAP_DEVSRC|XACAP_AUDIO, i, &temp); |
439 res = XACapabilitiesMgr_GetCapsByIdx(impl->capslist, (XACapsType)(XACAP_DEVSRC|XACAP_AUDIO), i, &temp); |
439 if (temp.xaid != deviceId) |
440 if (temp.xaid != deviceId) |
440 { |
441 { |
441 associatedCount++; |
442 associatedCount++; |
442 } |
443 } |
443 } |
444 } |
452 } |
453 } |
453 |
454 |
454 for( i=0, associatedCount = 0; i<impl->numInputDevices; i++ ) |
455 for( i=0, associatedCount = 0; i<impl->numInputDevices; i++ ) |
455 { |
456 { |
456 /* query device id from adaptation using index value */ |
457 /* query device id from adaptation using index value */ |
457 res = XAStaticCapsAdapt_GetCapsByIdx(XACAP_DEVSRC|XACAP_AUDIO, i, &temp); |
458 res = XACapabilitiesMgr_GetCapsByIdx(impl->capslist, (XACapsType)(XACAP_DEVSRC|XACAP_AUDIO), i, &temp); |
458 if (temp.xaid != deviceId) |
459 if (temp.xaid != deviceId) |
459 { |
460 { |
460 pAudioInputDeviceIDs[associatedCount++] = temp.xaid; |
461 pAudioInputDeviceIDs[associatedCount++] = temp.xaid; |
461 } |
462 } |
462 } |
463 } |
463 } |
464 } |
464 |
465 |
465 *pNumAudioInputs = associatedCount; |
466 *pNumAudioInputs = associatedCount; |
466 #endif |
467 |
467 |
468 |
468 if(!pAudioInputDeviceIDs) |
469 if(!pAudioInputDeviceIDs) |
469 { |
470 { |
470 switch(deviceId) |
471 switch(deviceId) |
471 { |
472 { |
521 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
522 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
522 res = XA_RESULT_PARAMETER_INVALID; |
523 res = XA_RESULT_PARAMETER_INVALID; |
523 } |
524 } |
524 else |
525 else |
525 { |
526 { |
526 #ifdef _GSTREAMER_BACKEND_ |
527 |
527 XAStaticCapsData temp; |
528 XACapabilities temp; |
528 XAuint32 associatedCount = 0; |
529 XAuint32 associatedCount = 0; |
529 |
530 |
530 XAuint32 i = 0; |
531 XAuint32 i = 0; |
531 for( i=0; i<impl->numOutputDevices; i++ ) |
532 for( i=0; i<impl->numOutputDevices; i++ ) |
532 { |
533 { |
533 /* query device id from adaptation using index value */ |
534 /* query device id from adaptation using index value */ |
534 res = XAStaticCapsAdapt_GetCapsByIdx(XACAP_DEVSNK|XACAP_AUDIO, i, &temp); |
535 res = XACapabilitiesMgr_GetCapsByIdx(impl->capslist, (XACapsType)(XACAP_DEVSNK|XACAP_AUDIO), i, &temp); |
535 if (temp.xaid != deviceId) |
536 if (temp.xaid != deviceId) |
536 { |
537 { |
537 associatedCount++; |
538 associatedCount++; |
538 } |
539 } |
539 } |
540 } |
548 } |
549 } |
549 |
550 |
550 for( i=0, associatedCount = 0; i<impl->numOutputDevices; i++ ) |
551 for( i=0, associatedCount = 0; i<impl->numOutputDevices; i++ ) |
551 { |
552 { |
552 /* query device id from adaptation using index value */ |
553 /* query device id from adaptation using index value */ |
553 res = XAStaticCapsAdapt_GetCapsByIdx(XACAP_DEVSNK|XACAP_AUDIO, i, &temp); |
554 res = XACapabilitiesMgr_GetCapsByIdx(impl->capslist, (XACapsType)(XACAP_DEVSNK|XACAP_AUDIO), i, &temp); |
554 if (temp.xaid != deviceId) |
555 if (temp.xaid != deviceId) |
555 { |
556 { |
556 pAudioOutputDeviceIDs[associatedCount++] = temp.xaid; |
557 pAudioOutputDeviceIDs[associatedCount++] = temp.xaid; |
557 } |
558 } |
558 } |
559 } |
559 } |
560 } |
560 |
561 |
561 *pNumAudioOutputs = associatedCount; |
562 *pNumAudioOutputs = associatedCount; |
562 #endif |
563 |
563 |
564 |
564 if(!pAudioOutputDeviceIDs) |
565 if(!pAudioOutputDeviceIDs) |
565 { |
566 { |
566 switch(deviceId) |
567 switch(deviceId) |
567 { |
568 { |
672 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
673 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
673 res = XA_RESULT_PARAMETER_INVALID; |
674 res = XA_RESULT_PARAMETER_INVALID; |
674 } |
675 } |
675 else |
676 else |
676 { |
677 { |
677 #ifdef _GSTREAMER_BACKEND_ |
678 |
678 XAStaticCapsData temp; |
679 /* XACapabilities temp; |
679 res = XAStaticCapsAdapt_GetCapsById(XACAP_DEVSNK|XACAP_AUDIO, |
680 res = XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_DEVSNK|XACAP_AUDIO), |
680 deviceId, &temp); |
681 deviceId, &temp); |
681 /* deviceid can be either input or output*/ |
682 deviceid can be either input or output |
682 if( res == XA_RESULT_FEATURE_UNSUPPORTED ) |
683 if( res == XA_RESULT_FEATURE_UNSUPPORTED ) |
683 { |
684 { |
684 res = XAStaticCapsAdapt_GetCapsById(XACAP_DEVSRC|XACAP_AUDIO, |
685 res = XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_DEVSRC|XACAP_AUDIO), |
685 deviceId, &temp); |
686 deviceId, &temp); |
686 } |
687 } |
687 if( res == XA_RESULT_SUCCESS ) |
688 if( res == XA_RESULT_SUCCESS ) |
688 { |
689 { |
|
690 XAAudioOutputDescriptor* desc = ((XAAudioOutputDescriptor*)(temp.pEntry)); |
689 XAuint32 count = 0, i = 0; |
691 XAuint32 count = 0, i = 0; |
690 for (i=0; i < sizeof(temp.pcmProfilesSupported)*8; i++) |
692 for (i=0; i < sizeof(temp.pcmProfilesSupported)*8; i++) |
691 count+=temp.pcmProfilesSupported>>i&0x1; |
693 count+=temp.pcmProfilesSupported>>i&0x1; |
692 |
694 |
693 if(pSampleFormats) |
695 if(pSampleFormats) |
737 **/ |
739 **/ |
738 |
740 |
739 /* XAAudIODevCapaItfImpl_Create |
741 /* XAAudIODevCapaItfImpl_Create |
740 * Description: Allocate and initialize XAAudIODevCapaItfImpl |
742 * Description: Allocate and initialize XAAudIODevCapaItfImpl |
741 */ |
743 */ |
742 XAAudIODevCapaItfImpl* XAAudIODevCapaItfImpl_Create() |
744 XAAudIODevCapaItfImpl* XAAudIODevCapaItfImpl_Create(XACapabilities* caps) |
743 { |
745 { |
744 XAAudIODevCapaItfImpl* self = (XAAudIODevCapaItfImpl*) |
746 XAAudIODevCapaItfImpl* self = (XAAudIODevCapaItfImpl*) |
745 calloc(1,sizeof(XAAudIODevCapaItfImpl)); |
747 calloc(1,sizeof(XAAudIODevCapaItfImpl)); |
746 DEBUG_API("->XAAudIODevCapaItfImpl_Create"); |
748 DEBUG_API("->XAAudIODevCapaItfImpl_Create"); |
747 |
749 |
768 XAAudIODevCapaItfImpl_RegisterAvailableAudioInputsChangedCallback; |
770 XAAudIODevCapaItfImpl_RegisterAvailableAudioInputsChangedCallback; |
769 self->itf.RegisterAvailableAudioOutputsChangedCallback = |
771 self->itf.RegisterAvailableAudioOutputsChangedCallback = |
770 XAAudIODevCapaItfImpl_RegisterAvailableAudioOutputsChangedCallback; |
772 XAAudIODevCapaItfImpl_RegisterAvailableAudioOutputsChangedCallback; |
771 self->itf.RegisterDefaultDeviceIDMapChangedCallback = |
773 self->itf.RegisterDefaultDeviceIDMapChangedCallback = |
772 XAAudIODevCapaItfImpl_RegisterDefaultDeviceIDMapChangedCallback; |
774 XAAudIODevCapaItfImpl_RegisterDefaultDeviceIDMapChangedCallback; |
773 #ifdef _GSTREAMER_BACKEND_ |
775 self->capslist = caps; |
774 /* init variables */ |
776 /* init variables */ |
775 assert( XAStaticCapsAdapt_GetCapsCount( XACAP_DEVSNK|XACAP_AUDIO, |
777 XACapabilitiesMgr_GetCapsCount( caps, (XACapsType)(XACAP_DEVSNK|XACAP_AUDIO), |
776 &(self->numOutputDevices) ) == XA_RESULT_SUCCESS ); |
778 &(self->numOutputDevices) ); |
777 assert( XAStaticCapsAdapt_GetCapsCount( XACAP_DEVSRC|XACAP_AUDIO, |
779 XACapabilitiesMgr_GetCapsCount( caps, (XACapsType)(XACAP_DEVSRC|XACAP_AUDIO), |
778 &(self->numInputDevices) ) == XA_RESULT_SUCCESS ); |
780 &(self->numInputDevices) ); |
779 #endif |
781 |
|
782 /*TODO: Remove this later*/ |
|
783 XACapabilitiesMgr_QueryColorFormats(caps, NULL, NULL); |
|
784 |
780 self->inputCbPtrToSelf = NULL; |
785 self->inputCbPtrToSelf = NULL; |
781 self->outputCbPtrToSelf = NULL; |
786 self->outputCbPtrToSelf = NULL; |
782 self->deviceMapCbPtrToSelf = NULL; |
787 self->deviceMapCbPtrToSelf = NULL; |
783 self->numInputDevices = 1; |
788 self->numInputDevices = 1; |
784 self->numOutputDevices = 1; |
789 self->numOutputDevices = 1; |