46 #include "CAHALAudioStream.h"
49 #include "CAAutoDisposer.h"
50 #include "CADebugMacros.h"
51 #include "CAException.h"
52 #include "CAPropertyAddress.h"
58 CAHALAudioStream::CAHALAudioStream(AudioObjectID inAudioStream)
60 CAHALAudioObject(inAudioStream)
64 CAHALAudioStream::~CAHALAudioStream()
68 UInt32 CAHALAudioStream::GetDirection()
const
70 CAPropertyAddress theAddress(kAudioStreamPropertyDirection);
71 return GetPropertyData_UInt32(theAddress, 0, NULL);
74 UInt32 CAHALAudioStream::GetTerminalType()
const
76 CAPropertyAddress theAddress(kAudioStreamPropertyTerminalType);
77 return GetPropertyData_UInt32(theAddress, 0, NULL);
80 UInt32 CAHALAudioStream::GetStartingChannel()
const
82 CAPropertyAddress theAddress(kAudioStreamPropertyStartingChannel);
83 return GetPropertyData_UInt32(theAddress, 0, NULL);
86 UInt32 CAHALAudioStream::GetLatency()
const
88 CAPropertyAddress theAddress(kAudioStreamPropertyLatency);
89 return GetPropertyData_UInt32(theAddress, 0, NULL);
92 void CAHALAudioStream::GetCurrentVirtualFormat(AudioStreamBasicDescription& outFormat)
const
94 CAPropertyAddress theAddress(kAudioStreamPropertyVirtualFormat);
95 UInt32 theSize =
sizeof(AudioStreamBasicDescription);
96 GetPropertyData(theAddress, 0, NULL, theSize, &outFormat);
99 void CAHALAudioStream::SetCurrentVirtualFormat(
const AudioStreamBasicDescription& inFormat)
101 CAPropertyAddress theAddress(kAudioStreamPropertyVirtualFormat);
102 SetPropertyData(theAddress, 0, NULL,
sizeof(AudioStreamBasicDescription), &inFormat);
105 UInt32 CAHALAudioStream::GetNumberAvailableVirtualFormats()
const
107 CAPropertyAddress theAddress(kAudioStreamPropertyAvailableVirtualFormats);
108 UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
109 theAnswer /=
sizeof(AudioStreamRangedDescription);
113 void CAHALAudioStream::GetAvailableVirtualFormats(UInt32& ioNumberFormats, AudioStreamRangedDescription* outFormats)
const
115 CAPropertyAddress theAddress(kAudioStreamPropertyAvailableVirtualFormats);
116 UInt32 theSize = ioNumberFormats *
sizeof(AudioStreamRangedDescription);
117 GetPropertyData(theAddress, 0, NULL, theSize, outFormats);
118 ioNumberFormats = theSize /
sizeof(AudioStreamRangedDescription);
121 void CAHALAudioStream::GetAvailableVirtualFormatByIndex(UInt32 inIndex, AudioStreamRangedDescription& outFormat)
const
123 UInt32 theNumberFormats = GetNumberAvailableVirtualFormats();
124 if((theNumberFormats > 0) && (inIndex < theNumberFormats))
126 CAAutoArrayDelete<AudioStreamRangedDescription> theFormats(theNumberFormats);
127 GetAvailableVirtualFormats(theNumberFormats, theFormats);
128 if((theNumberFormats > 0) && (inIndex < theNumberFormats))
130 outFormat = theFormats[inIndex];
135 void CAHALAudioStream::GetCurrentPhysicalFormat(AudioStreamBasicDescription& outFormat)
const
137 CAPropertyAddress theAddress(kAudioStreamPropertyPhysicalFormat);
138 UInt32 theSize =
sizeof(AudioStreamBasicDescription);
139 GetPropertyData(theAddress, 0, NULL, theSize, &outFormat);
142 void CAHALAudioStream::SetCurrentPhysicalFormat(
const AudioStreamBasicDescription& inFormat)
144 CAPropertyAddress theAddress(kAudioStreamPropertyPhysicalFormat);
145 SetPropertyData(theAddress, 0, NULL,
sizeof(AudioStreamBasicDescription), &inFormat);
148 UInt32 CAHALAudioStream::GetNumberAvailablePhysicalFormats()
const
150 CAPropertyAddress theAddress(kAudioStreamPropertyAvailablePhysicalFormats);
151 UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
152 theAnswer /=
sizeof(AudioStreamRangedDescription);
156 void CAHALAudioStream::GetAvailablePhysicalFormats(UInt32& ioNumberFormats, AudioStreamRangedDescription* outFormats)
const
158 CAPropertyAddress theAddress(kAudioStreamPropertyAvailablePhysicalFormats);
159 UInt32 theSize = ioNumberFormats *
sizeof(AudioStreamRangedDescription);
160 GetPropertyData(theAddress, 0, NULL, theSize, outFormats);
161 ioNumberFormats = theSize /
sizeof(AudioStreamRangedDescription);
164 void CAHALAudioStream::GetAvailablePhysicalFormatByIndex(UInt32 inIndex, AudioStreamRangedDescription& outFormat)
const
166 UInt32 theNumberFormats = GetNumberAvailablePhysicalFormats();
167 if((theNumberFormats > 0) && (inIndex < theNumberFormats))
169 CAAutoArrayDelete<AudioStreamRangedDescription> theFormats(theNumberFormats);
170 GetAvailablePhysicalFormats(theNumberFormats, theFormats);
171 if((theNumberFormats > 0) && (inIndex < theNumberFormats))
173 outFormat = theFormats[inIndex];