Move pa_format_info_to_sample_spec_fake() to core-format

I will need to use the function from outside libpulse.

I added the channel map argument, because the function will be called
from another function that is expected to initialize the channel map.
I don't know if it's in practice necessary, but it shouldn't do any
harm either.
core-format: Add pa_format_info_get_sample_format()
core-format: Add pa_format_info_get_rate()

This also fixes an issue in pa_format_info_to_sample_spec(): it did
no validation for the rate value. Now the validation is taken care of
in pa_format_info_get_rate().
core-format: Add pa_format_info_get_channels()

This also fixes an issue in pa_format_info_to_sample_spec(): it did
no validation for the channels value. Now the validation is taken care
of in pa_format_info_get_channels().
core-format: Add pa_format_info_get_channel_map()
format: Simplify pa_format_info_to_sample_spec()
core-format: Add pa_format_info_to_sample_spec2()

The function will be used in pa_sink_input_new() and
pa_source_output_new(). The fallback parameters are used to merge the
data in the format info with the sink/source sample spec and channel
map, when the format info is lacking some information.
core-format: Add pa_format_info_from_sample_spec2()

The function will be used in pa_sink_input_new() and
pa_source_output_new() to convert the sample spec given by the client
to a format info object. The set_format, set_rate and set_channels
will be set according to the stream flags (PA_SINK_INPUT_FIX_FORMAT
etc.).
sink-input, source-output: Do routing related validity checks immediately after routing

It's more logical that way.
format, core-format: Constify some function parameters
stream-util: Add pa_stream_get_volume_channel_map()

The new function isn't used yet, but it soon will.
stream: Remove a volume channel validity check

The check is done for clients that use pa_stream_new() but not for
clients that use pa_stream_new_extended(). This is inconsistent. We
could check that the volume channels match the channels set in the
format info struct that is passed to pa_stream_new_extended(), but
that doesn't work if the format info doesn't contain the channel
information (that can happen if the client wants the server to choose
the channel count for the stream). And it should also be possible to
pass a mono volume for a multi-channel stream. The check could be
extended to handle all these cases, but I don't see much point in
wasting time on that. The server will anyway validate the stream
parameters, it's not particularly important to fail already when the
stream is being created at the client side.
sink-input, source-output: Interpret missing PCM parameters in format info as a request to decide those parameters at the server end

The "fix flags" (PA_SINK_INPUT_FIX_FORMAT etc.) don't work properly
with the pa_stream_new_extended() interface. This patch fixes it so
that the same effect can be achieved by leaving some of the PCM
parameters unspecified in format info objects. Also, when converting
a sample spec to a format info when using the old pa_stream_new()
interface, the "fix flags" are taken into account in that conversion.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=68952
def, format: Document how to leave PCM parameters to be decided by the server
stream: Improve pa_stream_connect_playback() documentation
stream: Mention pa_stream_new_extended() in the high-level stream creation documentation
format: Add some error logging
alsa-card: Don't free the modargs in pa__init

The modargs are in both cases (a succesfull as well as a failed module
initialization) freed already in pa__done().

To avoid leaking modargs memory before they are assigned to u->modargs, the
code is reorganized to first allocate userdata, and then allocate the modargs.
Local variable ma is not needed anymore.

discussion here
http://lists.freedesktop.org/archives/pulseaudio-discuss/2013-December/019661.html

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Reported-by: poljar (Damir Jelić) <poljarinho@gmail.com>
caps: Use standard macro when checking for Linux

linux and __linux are non-standard, according to
http://sourceforge.net/p/predef/wiki/OperatingSystems/

Reported-By: Damir Jelić <poljarinho@gmail.com>
rtp-recv: Only try adding the group membership for multicast addresses