2012-01-23, 09:55
Quote:For those reasons I passed it an AEAudioFormat structure with all the details of the next stream.
This is already occurring, please see the below snippets
Code:
CSingleLock streamLock(m_streamLock);
bool wasEmpty = m_streams.empty();
CSoftAEStream *stream = new CSoftAEStream(dataFormat, sampleRate, channelLayout, options);
m_streams.push_back(stream);
streamLock.Leave();
if (AE_IS_RAW(dataFormat))
OpenSink();
else if (wasEmpty || !m_preferSeemless)
OpenSink();
Note that OpenSink is called AFTER the new stream has been added to the m_streams vector.
Code:
/* if we dont have a master stream, choose one based on the seemless setting */
if (!masterStream && !m_streams.empty())
masterStream = m_preferSeemless ? m_streams.front() : m_streams.back();
If we are not in RAW mode the above code picks up the stream based on the preferSeemless setting, which if false, will be the new stream just added in MakeStream.
Code:
/* the desired format */
AEAudioFormat newFormat;
/* override the sample rate & channel layout based on the master stream if there is one */
if (masterStream)
{
newFormat.m_sampleRate = masterStream->GetSampleRate();
newFormat.m_channelLayout = masterStream->m_initChannelLayout;
/* dont resolve the channels if we are transoding or in raw mode */
if (!m_transcode && !m_rawPassthrough)
newFormat.m_channelLayout.ResolveChannels(m_stdChLayout);
}
If we have a masterStream, get the deatils from it, which is exactly what that AEAudioFormat structure is that your trying to pass the method.
AE works in float, as does the visualizations, mixing, etc... this was an intentional design decision and any code that causes this conversion to float to be bypassed will be rejected due to the added complexity. Much work has gone into optimising the float conversion code on all platforms, including embedded platforms such as ARM with NEON extensions.
Because AE is working in float, the best possible output format is Float, if it fails to open that due to your hardware limits, your sink is supposed to try the next best until it finds a compatible format. So with ALSA it tries:
FLOAT
DOUBLE
S24NE3, S24LE3, S24BE3,
S24NE4, S24LE4, S24BE4,
S32NE, S32LE, S32BE,
S16_NE, S16_LE, S16_BE,
S8
U8
In that order, ensuring it gets the best possible format on the hardware. I fail to see how passing the format would help since it is already determined by what the stream is using.
Also, Exclusive mode is windows only, and any platform specific code should NOT be in CSoftAE or CSoftAEStream, thats what the sinks are for.