All of lore.kernel.org
 help / color / mirror / Atom feed
* question application playback
@ 2012-01-03 12:23 Ricardo Barbosa
  2012-01-03 12:28 ` Daniel Mack
  2012-01-03 12:30 ` Irfan shaikh
  0 siblings, 2 replies; 9+ messages in thread
From: Ricardo Barbosa @ 2012-01-03 12:23 UTC (permalink / raw)
  To: Alsa-devel

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-03 12:23 question application playback Ricardo Barbosa
@ 2012-01-03 12:28 ` Daniel Mack
  2012-01-03 12:49   ` Vinod Koul
  2012-01-03 12:30 ` Irfan shaikh
  1 sibling, 1 reply; 9+ messages in thread
From: Daniel Mack @ 2012-01-03 12:28 UTC (permalink / raw)
  To: alsa-devel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-03 12:23 question application playback Ricardo Barbosa
  2012-01-03 12:28 ` Daniel Mack
@ 2012-01-03 12:30 ` Irfan shaikh
  2012-01-04  5:52   ` Rajeev kumar
  1 sibling, 1 reply; 9+ messages in thread
From: Irfan shaikh @ 2012-01-03 12:30 UTC (permalink / raw)
  To: Ricardo Barbosa; +Cc: Alsa-devel

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
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-03 12:28 ` Daniel Mack
@ 2012-01-03 12:49   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2012-01-03 12:49 UTC (permalink / raw)
  To: Daniel Mack; +Cc: alsa-devel

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

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-03 12:30 ` Irfan shaikh
@ 2012-01-04  5:52   ` Rajeev kumar
  2012-01-04 13:33     ` Vinod Koul
  0 siblings, 1 reply; 9+ messages in thread
From: Rajeev kumar @ 2012-01-04  5:52 UTC (permalink / raw)
  To: Irfan shaikh; +Cc: Ricardo Barbosa, 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
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-04  5:52   ` Rajeev kumar
@ 2012-01-04 13:33     ` Vinod Koul
  2012-01-29  6:31       ` Wang Xingchao
  0 siblings, 1 reply; 9+ messages in thread
From: Vinod Koul @ 2012-01-04 13:33 UTC (permalink / raw)
  To: Rajeev kumar; +Cc: Ricardo Barbosa, Irfan shaikh, 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.....

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-04 13:33     ` Vinod Koul
@ 2012-01-29  6:31       ` Wang Xingchao
  2012-01-29 15:51         ` Gabriel M. Beddingfield
  0 siblings, 1 reply; 9+ messages in thread
From: Wang Xingchao @ 2012-01-29  6:31 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Ricardo Barbosa, Rajeev kumar, Irfan shaikh, Alsa-devel

在 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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-29  6:31       ` Wang Xingchao
@ 2012-01-29 15:51         ` Gabriel M. Beddingfield
  2012-01-30  2:25           ` Wang Xingchao
  0 siblings, 1 reply; 9+ messages in thread
From: Gabriel M. Beddingfield @ 2012-01-29 15:51 UTC (permalink / raw)
  To: 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: question application playback
  2012-01-29 15:51         ` Gabriel M. Beddingfield
@ 2012-01-30  2:25           ` Wang Xingchao
  0 siblings, 0 replies; 9+ messages in thread
From: Wang Xingchao @ 2012-01-30  2:25 UTC (permalink / raw)
  To: Gabriel M. Beddingfield; +Cc: alsa-devel

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

>
> 3. 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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-01-30  2:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-03 12:23 question application playback Ricardo Barbosa
2012-01-03 12:28 ` Daniel Mack
2012-01-03 12:49   ` Vinod Koul
2012-01-03 12:30 ` Irfan shaikh
2012-01-04  5:52   ` Rajeev kumar
2012-01-04 13:33     ` Vinod Koul
2012-01-29  6:31       ` Wang Xingchao
2012-01-29 15:51         ` Gabriel M. Beddingfield
2012-01-30  2:25           ` Wang Xingchao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.