Lunar Mushrooms
Lunar Mushrooms

Reputation: 8928

ALSA : How to do stop and resume audio?

I need is to play a wave file multiple times. I don't want to call the hardware/software parameter settings APIs, each time the wave file is played again.

{start...play wave partially...stop}, {start...play wave partially...stop},  {start...play wave partially...stop}, ... 

What apis are to be used here ? It is okay to drop the unplayed frames. When I checked alsa API, I can see lots of similar apis suspend/resume/stop .... What is the right combination to start and stop audio for above use case ?

Upvotes: 1

Views: 4225

Answers (1)

CL.
CL.

Reputation: 180060

After a PCM device has been stopped with snd_pcm_drop, you can restart it by calling snd_pcm_prepare, writing new data into the buffer, and then calling snd_pcm_start or using automatic start (which is enabled by default).

Upvotes: 2

Related Questions