This code was duplicated in alsasrc and alsasink.
https://bugzilla.gnome.org/show_bug.cgi?id=763985
}
return TRUE;
}
+
+void
+alsa_detect_channels_mapping (GstObject * obj, snd_pcm_t * handle,
+ GstAudioRingBufferSpec * spec, guint channels, GstAudioRingBuffer * buf)
+{
+ if (spec->type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW && channels < 9) {
+ snd_pcm_chmap_t *chmap = snd_pcm_get_chmap (handle);
+ if (chmap && chmap->channels == channels) {
+ GstAudioChannelPosition pos[8];
+ if (alsa_chmap_to_channel_positions (chmap, pos))
+ gst_audio_ring_buffer_set_channel_positions (buf, pos);
+ }
+ free (chmap);
+ }
+}
#endif /* SND_CHMAP_API_VERSION */
#ifdef SND_CHMAP_API_VERSION
gboolean alsa_chmap_to_channel_positions (const snd_pcm_chmap_t *chmap,
GstAudioChannelPosition *pos);
+
+void alsa_detect_channels_mapping (GstObject * obj,
+ snd_pcm_t * handle,
+ GstAudioRingBufferSpec * spec,
+ guint channels,
+ GstAudioRingBuffer * buf);
#endif
#endif /* __GST_ALSA_H__ */
}
#ifdef SND_CHMAP_API_VERSION
- if (spec->type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW && alsa->channels < 9) {
- snd_pcm_chmap_t *chmap = snd_pcm_get_chmap (alsa->handle);
- if (chmap && chmap->channels == alsa->channels) {
- GstAudioChannelPosition pos[8];
- if (alsa_chmap_to_channel_positions (chmap, pos))
- gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SINK
- (alsa)->ringbuffer, pos);
- }
- free (chmap);
- }
+ alsa_detect_channels_mapping (GST_OBJECT (alsa), alsa->handle, spec,
+ alsa->channels, GST_AUDIO_BASE_SINK (alsa)->ringbuffer);
#endif /* SND_CHMAP_API_VERSION */
return TRUE;
}
#ifdef SND_CHMAP_API_VERSION
- if (spec->type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW && alsa->channels < 9) {
- snd_pcm_chmap_t *chmap = snd_pcm_get_chmap (alsa->handle);
- if (chmap && chmap->channels == alsa->channels) {
- GstAudioChannelPosition pos[8];
- if (alsa_chmap_to_channel_positions (chmap, pos))
- gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SRC
- (alsa)->ringbuffer, pos);
- }
- free (chmap);
- }
+ alsa_detect_channels_mapping (GST_OBJECT (alsa), alsa->handle, spec,
+ alsa->channels, GST_AUDIO_BASE_SRC (alsa)->ringbuffer);
#endif /* SND_CHMAP_API_VERSION */
return TRUE;