CM ALSA Sink

The cmAlsaSink is used to send data to the speaker through the ALSA Interface. It supports the speaker data input format setting and multi-link for input. The ALSA device only supports one connection at a time, but cmAlsaSink can input data to multi-pipeline. If the input is more than one, it will mix the raw data before sending it to the speaker.


API Instructions

create/destroy

/* @device Alsa device, default hw:0,0 */ gpointer cm_audio_alsa_sink_create(gchar* device); void cm_audio_alsa_sink_destroy(gpointer hd);

start/stop

void cm_audio_alsa_sink_start(gpointer hd); void cm_audio_alsa_sink_stop(gpointer hd);

parameters

The input data format is obtained from the source and it may be different from the speaker supported. Set the caps string that the speaker supported, the data will be converted to it.

/* * @caps_str0 Speaker format, audio/x-raw,rate=44100,channels=2,... * if the input format is different from the speaker format, * set the speaker caps string, the input data will be converted. */ void cm_audio_alsa_sink_set_caps_str0(gpointer hd, const gchar* caps_str0);

data

Support multi-source links and use references to manage them. Multiple inputs must be in the same format to ensure that remixes are executed properly.

The sink needs to know the actual format of the input before playing, so must ensure the source is ready to be linked(the media info is ready).

others


Demo

PV to PB

Structure

Get data from the microphone and send it to the speaker to play.

image-20240520-071429.png

Main codes

For more details please refer to the demo file.

Test result

The speaker can hear the sound from the microphone. Users can use this demo to check whether the microphone and speaker are working correctly.