[alsa-devel] question application playback
Hi all.
I am new to development using the alsa API and follow the link code http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r"); fclose(fp);
and changed variable buf by the variable fp, but by running the file file.mp3 he does not play according to the way it interferes with the function snd_pcm_writei ? someone could help me in developing this playback, I thank
Regards.
On 01/03/2012 01:23 PM, Ricardo Barbosa wrote:
I am new to development using the alsa API and follow the link code http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r");
MP3s are compressed audio files that cannot be used directly with the ALSA API. If you have to use mp3 files, have a look at libmpg123 or use a higher level interface in the first place, for example GStreamer.
Daniel
On Tue, 2012-01-03 at 13:28 +0100, Daniel Mack wrote:
On 01/03/2012 01:23 PM, Ricardo Barbosa wrote:
I am new to development using the alsa API and follow the link code http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r");
MP3s are compressed audio files that cannot be used directly with the ALSA API. If you have to use mp3 files, have a look at libmpg123 or use a higher level interface in the first place, for example GStreamer.
Not true anymore, if you have device which supports compressed formats, the shining new alsa compress API are there for you to use :)
See Documentation/sound/alsa/compress_offload.txt
Hi,
ALSA can play only raw PCM data. It is not possible to play mp3 file directly. Use a decoder interface to decode the mp3 file and the send to ALSA.
Regards Irfan
On 01/03/2012 05:53 PM, Ricardo Barbosa wrote:
Hi all.
I am new to development using the alsa API and follow the link code http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r"); fclose(fp);
and changed variable buf by the variable fp, but by running the file file.mp3 he does not play according to the way it interferes with the function snd_pcm_writei ? someone could help me in developing this playback, I thank
Regards. _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hello On 1/3/2012 6:00 PM, Irfan shaikh wrote:
Hi,
ALSA can play only raw PCM data. It is not possible to play mp3
file directly. Use a decoder interface to decode the mp3 file and the send to ALSA.
Regards Irfan
Please avoid top posting
On 01/03/2012 05:53 PM, Ricardo Barbosa wrote:
Hi all.
I am new to development using the alsa API and follow the link code http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r"); fclose(fp);
and changed variable buf by the variable fp, but by running the file file.mp3 he does not play according to the way it interferes with the function snd_pcm_writei ? someone could help me in developing this playback, I thank
AFAIK, ALSA can play mp3 files.
Regards. _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On Wed, 2012-01-04 at 11:22 +0530, Rajeev kumar wrote:
On 01/03/2012 05:53 PM, Ricardo Barbosa wrote:
Hi all.
I am new to development using the alsa API and follow the link code
http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r"); fclose(fp);
and changed variable buf by the variable fp, but by running the
file file.mp3 he does not play according to the way it interferes with the function snd_pcm_writei ? someone could help me in developing this playback, I thank
AFAIK, ALSA can play mp3 files.
really??? not the pcm interface.....
在 2012年1月4日 上午8:33,Vinod Koul vinod.koul@linux.intel.com写道:
On Wed, 2012-01-04 at 11:22 +0530, Rajeev kumar wrote:
On 01/03/2012 05:53 PM, Ricardo Barbosa wrote:
Hi all.
I am new to development using the alsa API and follow the link code
http://equalarea.com/paul/alsa-audio.html
insert the following code.
FILE *fp; fp = fopen("file.mp3", "r"); fclose(fp);
and changed variable buf by the variable fp, but by running the
file file.mp3 he does not play according to the way it interferes with the function snd_pcm_writei ? someone could help me in developing this playback, I thank
AFAIK, ALSA can play mp3 files.
really??? not the pcm interface.....
i used tool "aplay" to "play" mp3 files sucessfully. :) well, in this scenario, alsa is used as data transfer interface, there must be mp3 decode interface in kernel layer to receive mp3 data and do the post work. mp3 data is regarded as pcm data during transfer, so the format and rate must be specified with aplay.
thanks --xingchao
-- ~Vinod
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On 01/29/2012 12:31 AM, Wang Xingchao wrote:
i used tool "aplay" to "play" mp3 files sucessfully. :) well, in this scenario, alsa is used as data transfer interface, there must be mp3 decode interface in kernel layer to receive mp3 data and do the post work. mp3 data is regarded as pcm data during transfer, so the format and rate must be specified with aplay.
1. There is no DSP done in the kernel. That includes MP3 decode. This is a hard and fast rule. Decode must either be done by the hardware or userspace. Never in the kernel.
2. Some audio hardware is able to decode the MP3 directly. Since I've never seen/used one, I don't know how its driver would work or how to set the hw_params... or if ALSA even supports passing this format to the audio device.
3. aplay is able to do some format conversion. For example, `man aplay` shows that it supports MPEG decode.
Conclusion: If you can set your hw_params to do SND_PCM_FORMAT_MPEG, then the hardware is doing the MPEG decode. Most cards/drivers will reject this, though... in which case you have to do the decode yourself with something like liblame or libmpg123.
-gabriel
thanks your comments, gabriel.
在 2012年1月29日 上午10:51,Gabriel M. Beddingfield gabrbedd@gmail.com 写道:
On 01/29/2012 12:31 AM, Wang Xingchao wrote:
i used tool "aplay" to "play" mp3 files sucessfully. :) well, in this scenario, alsa is used as data transfer interface, there must be mp3 decode interface in kernel layer to receive mp3 data and do the post work. mp3 data is regarded as pcm data during transfer, so the format and rate must be specified with aplay.
- There is no DSP done in the kernel. That includes MP3 decode. This is a hard and fast rule. Decode must either be done by the hardware or userspace. Never in the kernel.
A misunderstanding here. It's DSP interface in kernel, which send compress audio data to DSP for post process. The decoding is done by HW, that's true. :)
- Some audio hardware is able to decode the MP3 directly. Since I've never seen/used one, I don't know how its driver would work or how to set the hw_params... or if ALSA even supports passing this format to the audio device.
The interface can receive compressed format data such as MP3, so ALSA is only a transfer channel. ALSA is able to send MP3 data as faked PCM format.
- aplay is able to do some format conversion. For example, `man aplay` shows that it supports MPEG decode.
exactly. :)
Conclusion: If you can set your hw_params to do SND_PCM_FORMAT_MPEG, then the hardware is doing the MPEG decode. Most cards/drivers will reject this, though... in which case you have to do the decode yourself with something like liblame or libmpg123.
That's true. Take Intel's Medfield platform for example, It has DSP which handle HW decoding. And the DSP FW varies on different platform, it's able to receive compressed audio data(Mp3, DTS, AAC, etc) and what kernel layer done is the transfer work.
thanks --xingchao
-gabriel
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (7)
-
Daniel Mack
-
Gabriel M. Beddingfield
-
Irfan shaikh
-
Rajeev kumar
-
Ricardo Barbosa
-
Vinod Koul
-
Wang Xingchao