Skip to contentSkip to conversation

question application playback

DISCUSSION Ricardo Barbosa 7 participants 9 messages Jan 3, 2012 – Jan 30, 2012

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 6 lines · Ricardo Barbosa

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

#2 lore raw
Quoted 11 lines · Daniel Mack
Quoted 6 lines · Ricardo Barbosa

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

Signature · 1 line
~Vinod
#3 lore raw
In reply to Ricardo Barbosa

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

Quoted 19 lines · Ricardo Barbosa

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
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw

Hello

Quoted 9 lines · Irfan shaikh

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

Quoted 6 lines · Ricardo Barbosa
Quoted 5 lines

Hi all.

I am new to development using the alsa API and follow the link code http://equalarea.com/paul/alsa-audio.html

Quoted 8 lines
Quoted 8 lines

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.

Quoted 12 lines
Quoted 6 lines

Regards.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
Quoted 13 lines · Rajeev kumar
Quoted 5 lines · Ricardo Barbosa
Quoted 4 lines

Hi all.

I am new to development using the alsa API and follow the link code

http://equalarea.com/paul/alsa-audio.html

Quoted 7 lines
Quoted 7 lines

insert the following code.

   FILE *fp;
   fp = fopen("file.mp3", "r");
   fclose(fp);
Quoted 7 lines
Quoted 1 line
Quoted 1 line

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

Quoted 1 line
Quoted 1 line

AFAIK, ALSA can play mp3 files.

really??? not the pcm interface.....

Signature · 1 line
~Vinod
#6 lore raw
Quoted 15 lines · 在 2012年1月4日 上午8:33,Vinod Koul <[email protected]>写道:
Quoted 13 lines · Rajeev kumar
Quoted 5 lines · Ricardo Barbosa
Quoted 4 lines

Hi all.

I am new to development using the alsa API and follow the link code

http://equalarea.com/paul/alsa-audio.html

Quoted 7 lines
Quoted 7 lines

insert the following code.

   FILE *fp;
   fp = fopen("file.mp3", "r");
   fclose(fp);
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

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

Quoted 1 line
Quoted 1 line

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

Quoted 8 lines

--
~Vinod

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#7 lore raw
Quoted 5 lines · Wang Xingchao

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

#8 lore raw

thanks your comments, gabriel.

Quoted 11 lines · 在 2012年1月29日 上午10:51,Gabriel M. Beddingfield <[email protected]> 写道:
Quoted 5 lines · Wang Xingchao

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.

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. :)

Quoted 6 lines

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.

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.

Quoted 4 lines

3. aplay is able to do some format conversion. For example, man aplay shows that it supports MPEG decode.

exactly. :)

Quoted 5 lines

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

Quoted 7 lines

-gabriel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel