I'm trying to playback an audio CD by using cd_paranoia
(from the cdio
package) and to hand over the data read to the ALSA sound output. Buffered, of course. My issue is now the following: As stated in this example program, a call to paranoia_read ()
returns an int16_t*
containing one sector (2,352 bytes) of audio data, which can be then cast into a char*
.
The ALSA snd_pcm_writei ()
method, on the other hand needs a chunk of audio data in a char*
, whose length is to be determined by using the snd_pcm_hw_params_get_period_size ()
method, which basically returns the count of bytes sent to the sound device, until it triggers an interrupt. Sell also this example sourcecode.
The two methods will almost for sure return different values 'cause an ALSA frame has a different size than a CD sector. This would mean I'd have to divide the data cd-paranoia
delivers me somehow, so that they will fit into ALSA's frame structure. Or would it be sufficient just to stream the CD audio data into a big byte array (std::queue<char>
) and then, step by step, read as many bytes from this array, so that I will get a complete ALSA "frame"?
Any hints? Thank you.
snd_pcm_writei()
handles any number of frames.