* basic questions
@ 2008-03-14 4:35 Harsha priya gupta
2008-03-14 22:35 ` Lee Revell
0 siblings, 1 reply; 7+ messages in thread
From: Harsha priya gupta @ 2008-03-14 4:35 UTC (permalink / raw)
To: alsa-devel
Hi,
I am ramping up on ALSA architecture and framework. I have a couple of basic
questions. I apologize if these questions are very basic to be raised in
this mailing list. If anyone can help me find answers, it would be great.
Thanks in advance.
1. My assumption is that ALSA handles only PCM streams today. Does it handle
encoded streams from application to sound card (Which can do hardware
decoding)?
2. What are the hwdep files in ALSA used for? Where do the concerned IOCTLS
land to?
Thanks and Regards,
Harsha.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: basic questions
2008-03-14 4:35 basic questions Harsha priya gupta
@ 2008-03-14 22:35 ` Lee Revell
2008-03-14 22:57 ` Eliot Blennerhassett
0 siblings, 1 reply; 7+ messages in thread
From: Lee Revell @ 2008-03-14 22:35 UTC (permalink / raw)
To: Harsha priya gupta; +Cc: alsa-devel
On Fri, Mar 14, 2008 at 12:35 AM, Harsha priya gupta
<harshapriya@gmail.com> wrote:
> Hi,
>
> I am ramping up on ALSA architecture and framework. I have a couple of basic
> questions. I apologize if these questions are very basic to be raised in
> this mailing list. If anyone can help me find answers, it would be great.
> Thanks in advance.
>
> 1. My assumption is that ALSA handles only PCM streams today. Does it handle
> encoded streams from application to sound card (Which can do hardware
> decoding)?
>
Someone else could probably give a better answer, but I believe that
currently ALSA has no API for cards that do HW decoding.
> 2. What are the hwdep files in ALSA used for? Where do the concerned IOCTLS
> land to?
Anything you want to do that doesn't fit into the ALSA framework.
Typically they're used for things like programming the card's DSP
engine. I've also used them for testing/QA in embedded development,
using hwdep ioctls to provide an alternate playback path, so that any
issues can quickly be determined to be an ALSA issue, or a problem
with the way we were programming the HW.
See the emu10k1 driver for a good example of hwdep ioctl usage. It's
used for things like loading DSP patches.
Lee
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: basic questions
2008-03-14 22:35 ` Lee Revell
@ 2008-03-14 22:57 ` Eliot Blennerhassett
2008-03-18 2:01 ` Lee Revell
0 siblings, 1 reply; 7+ messages in thread
From: Eliot Blennerhassett @ 2008-03-14 22:57 UTC (permalink / raw)
To: alsa-devel
On Saturday 15 March 2008 11:35:20 Lee Revell wrote:
> On Fri, Mar 14, 2008 at 12:35 AM, Harsha priya gupta
>
> <harshapriya@gmail.com> wrote:
> > Hi,
> >
> > I am ramping up on ALSA architecture and framework. I have a couple of
> > basic questions. I apologize if these questions are very basic to be
> > raised in this mailing list. If anyone can help me find answers, it would
> > be great. Thanks in advance.
> >
> > 1. My assumption is that ALSA handles only PCM streams today. Does it
> > handle encoded streams from application to sound card (Which can do
> > hardware decoding)?
>
> Someone else could probably give a better answer, but I believe that
> currently ALSA has no API for cards that do HW decoding.
Not AFAIK, and certainly the architecture assumes a constant data rate. I.e X
bytes consumed implies elapsed time of (X * constant) = the _period_
Alsa headers do define some format constants for compressed audio.
We would like to support compressed audio for our cards, which can do hardware
decoding. I did try to implement it early on, but got lost in the quagmire of
driver midlevel code and alsa-lib.
A first step would be to allow CBR compressed formats to pass through to the
driver unaltered. For these there is a defined bits per sample, though it can
be non-integer which might be a problem.
regards
--
Eliot Blennerhassett
www.audioscience.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: basic questions
2008-03-14 22:57 ` Eliot Blennerhassett
@ 2008-03-18 2:01 ` Lee Revell
2008-03-18 12:50 ` Harsha priya gupta
0 siblings, 1 reply; 7+ messages in thread
From: Lee Revell @ 2008-03-18 2:01 UTC (permalink / raw)
To: Eliot Blennerhassett; +Cc: alsa-devel
On Fri, Mar 14, 2008 at 6:57 PM, Eliot Blennerhassett
<linux@audioscience.com> wrote:
> On Saturday 15 March 2008 11:35:20 Lee Revell wrote:
> > On Fri, Mar 14, 2008 at 12:35 AM, Harsha priya gupta
> >
> > <harshapriya@gmail.com> wrote:
> > > Hi,
> > >
> > > I am ramping up on ALSA architecture and framework. I have a couple of
> > > basic questions. I apologize if these questions are very basic to be
> > > raised in this mailing list. If anyone can help me find answers, it would
> > > be great. Thanks in advance.
> > >
> > > 1. My assumption is that ALSA handles only PCM streams today. Does it
> > > handle encoded streams from application to sound card (Which can do
> > > hardware decoding)?
> >
> > Someone else could probably give a better answer, but I believe that
> > currently ALSA has no API for cards that do HW decoding.
>
> Not AFAIK, and certainly the architecture assumes a constant data rate. I.e X
> bytes consumed implies elapsed time of (X * constant) = the _period_
>
> Alsa headers do define some format constants for compressed audio.
>
> We would like to support compressed audio for our cards, which can do hardware
> decoding. I did try to implement it early on, but got lost in the quagmire of
> driver midlevel code and alsa-lib.
>
> A first step would be to allow CBR compressed formats to pass through to the
> driver unaltered. For these there is a defined bits per sample, though it can
> be non-integer which might be a problem.
I would look at how ALSA implements AC3 passthrough.
Lee
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: basic questions
2008-03-18 2:01 ` Lee Revell
@ 2008-03-18 12:50 ` Harsha priya gupta
0 siblings, 0 replies; 7+ messages in thread
From: Harsha priya gupta @ 2008-03-18 12:50 UTC (permalink / raw)
To: Lee Revell; +Cc: alsa-devel
Thanks a lot for the responses.
I see that there can be a way to implement a path for sending encoded
streams to sound card driver through ALSA for hardware decoding but it does
not explicitly exist today.
There are currently a lot of hardware that support decoding. If there is no
existing path in ALSA, what is the recommended way to do so? [ provide
different driver for encoded streams?]
As I am new to ALSA, it would be great if anyone could help me quantify the
effort and difficulty level involved and provide a direction for the same.
Would I be on the right path if;
1. Like PCM object, register a encoded stream object in ALSA framework
2. Provide IOCTLs from sound card driver for MMF to send encoded buffer
3. (is required??) implement API in ALSA driver and Libasound to route the
calls from MMF to sound card IOCTLs
Thanks a lot in advance,
-Harsha
On Tue, Mar 18, 2008 at 7:31 AM, Lee Revell <rlrevell@joe-job.com> wrote:
> On Fri, Mar 14, 2008 at 6:57 PM, Eliot Blennerhassett
> <linux@audioscience.com> wrote:
> > On Saturday 15 March 2008 11:35:20 Lee Revell wrote:
> > > On Fri, Mar 14, 2008 at 12:35 AM, Harsha priya gupta
> > >
> > > <harshapriya@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I am ramping up on ALSA architecture and framework. I have a
> couple of
> > > > basic questions. I apologize if these questions are very basic to
> be
> > > > raised in this mailing list. If anyone can help me find answers, it
> would
> > > > be great. Thanks in advance.
> > > >
> > > > 1. My assumption is that ALSA handles only PCM streams today. Does
> it
> > > > handle encoded streams from application to sound card (Which can do
> > > > hardware decoding)?
> > >
> > > Someone else could probably give a better answer, but I believe that
> > > currently ALSA has no API for cards that do HW decoding.
> >
> > Not AFAIK, and certainly the architecture assumes a constant data rate.
> I.e X
> > bytes consumed implies elapsed time of (X * constant) = the _period_
> >
> > Alsa headers do define some format constants for compressed audio.
> >
> > We would like to support compressed audio for our cards, which can do
> hardware
> > decoding. I did try to implement it early on, but got lost in the
> quagmire of
> > driver midlevel code and alsa-lib.
> >
> > A first step would be to allow CBR compressed formats to pass through
> to the
> > driver unaltered. For these there is a defined bits per sample, though
> it can
> > be non-integer which might be a problem.
>
> I would look at how ALSA implements AC3 passthrough.
>
> Lee
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
--
-Harsha
^ permalink raw reply [flat|nested] 7+ messages in thread
* Basic questions
@ 2017-07-30 10:00 tsepp2001
2017-07-30 14:24 ` Clemens Ladisch
0 siblings, 1 reply; 7+ messages in thread
From: tsepp2001 @ 2017-07-30 10:00 UTC (permalink / raw)
To: alsa-devel
Hi everybody,
I am new to ALSA-API and would be glad, if someone give me an advice to
the following questions. Up to now I used Rtaudio for cross compiling
the player for windows and Linux. But know I need to go more into ALSA...
- Am I right to use async mode to get lowest latency times and using
pause/play/stop?
- I used the following piece of code. But don't get any output. The
callback output shows "avail" with very short count of frames...
I write a whole file (raw) to buffer, called buffer_alsa with 6894888
frames. What is going wrong?
I get this output:
Frames: 6894888
buffer_size (frames): 2048
buffer_time (frames): 46439
period_size (frames): 256
period_time (usec): 5804
periods (count): 8
Avail: 1540
Avail: 1285
Avail: 1030
Avail: 775
Avail: 520
Avail: 265
Avail: 10
Avail: 2
Avail: 2
Avail: 3
Avail: 2
...
The code follows ...
Best regards
Thomas
-----------------------------
void MyCallback(snd_async_handler_t *pcm_callback)
{
snd_pcm_t *handle = snd_async_handler_get_pcm(pcm_callback);
snd_pcm_sframes_t avail;
//std::cout << "Period_size: " << period_size << std::endl;
avail = snd_pcm_avail_update(handle);
while (avail >= period_size)
{
snd_pcm_writei(handle, buffer_alsa , period_size);
avail = snd_pcm_avail_update(handle);
std::cout << " Avail: " << avail << std::endl;
}
}
//----------------------------------------------------
snd_pcm_hw_params_alloca(¶ms);
if ((err = snd_pcm_hw_params_any(handle, params)) < 0)
std::cout << " Error (reading configuration): " <<
snd_strerror(err) << std::endl;
/* Set parameters */
if ((err = snd_pcm_hw_params_set_access(handle,
params,SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
//printf("ERROR: Can't set interleaved mode. %s\n", snd_strerror(err));
std::cout << " Error (can't set interleaved mode): " <<
snd_strerror(err) << std::endl;
if ((err = snd_pcm_hw_params_set_format(handle, params, FORMAT)) < 0)
//printf("ERROR: Can't set format. %s\n", snd_strerror(err));
std::cout << " Error (can't set format): " <<
snd_strerror(err) << std::endl;
if ((err = snd_pcm_hw_params_set_channels(handle, params,
data.channels)) < 0)
//printf("ERROR: Can't set channels number. %s\n", snd_strerror(err));
std::cout << " Error (can't set channels number): " <<
snd_strerror(err) << std::endl;
if ((err = snd_pcm_hw_params_set_rate_near(handle, params, &fs, 0)) < 0)
//printf("ERROR: Can't set rate. %s\n", snd_strerror(err));
std::cout << " Error (can't set rate): " <<
snd_strerror(err) << std::endl;
if ((err = snd_pcm_hw_params_set_buffer_size_near(handle, params,
&buffer_size)) < 0)
std::cout << " Error (can't set buffer size): " <<
snd_strerror(err) << std::endl;
if ((err = snd_pcm_hw_params_set_period_size_near (handle, params,
&period_size, NULL)) < 0)
std::cout << " Error (can't set period size): " <<
snd_strerror(err) << std::endl;
/* Write parameters */
if ((err = snd_pcm_hw_params(handle, params)) < 0)
//printf("ERROR: Can't set hardware parameters. %s\n", snd_strerror(err));
std::cout << " Error (can't set harware params): " <<
snd_strerror(err) << std::endl;
//---------------------- ------------------------------
// Get Parameters
snd_pcm_hw_params_get_buffer_size(params, &buffer_sz);
std::cout << " buffer_size (frames): " << buffer_sz <<
std::endl;
snd_pcm_hw_params_get_buffer_time(params, &buffer_tm, NULL);
std::cout << " buffer_time (frames): " << buffer_tm <<
std::endl;
snd_pcm_hw_params_get_period_size(params, &aframes, 0);
std::cout << " period_size (frames): " << aframes <<
std::endl;
snd_pcm_hw_params_get_period_time(params, &data.channels, NULL); // tmp
Zeit in us
std::cout << " period_time (usec): " << data.channels
<< std::endl;
snd_pcm_hw_params_get_periods(params, &piods, 0);
std::cout << " periods (count): " << piods << std::endl;
//
----------------------------------------------------------------------------
//snd_pcm_hw_params_free (params);
// --------------------- Hardware-Params End ------------------------------
snd_pcm_sw_params_t *sw_params;
if ((err = snd_pcm_sw_params_malloc (&sw_params)) < 0)
{
std::cout << " Error (can't allocate sw params): " <<
snd_strerror(err) << std::endl;
return;
}
if ((err = snd_pcm_sw_params_current(handle, sw_params)) < 0)
{
std::cout << "Error (can't return curr sw config): " <<
snd_strerror(err) << std::endl;
return;
}
if ((err = snd_pcm_sw_params_set_start_threshold (handle, sw_params,
buffer_size)) < 0) // 0U oder 4096 ?
{ // This parameter controls the wake up point. If the count of
available samples is equal or greater than this value, then the
application will be activated.
std::cout << "Error (can't set start thresh mode): " <<
snd_strerror(err) << std::endl;
return;
}
/*
if ((err = snd_pcm_sw_params_set_silence_threshold( handle, sw_params, 0
)) < 0)
{
std::cout << " Error (can't set silence thres): " <<
snd_strerror(err) << std::endl;
return;
}
*/
if ((err = snd_pcm_sw_params_set_avail_min (handle, sw_params,
period_size)) < 0)
{
std::cout << " Error (can't set min avail count): " <<
snd_strerror(err) << std::endl;
return;
}
// here are two options for a fix
//snd_pcm_sw_params_set_silence_size( phandle, sw_params, ULONG_MAX );
/*
snd_pcm_uframes_t val;
if ((err = snd_pcm_sw_params_get_boundary(sw_params, &val)) < 0)
{
std::cout << " Error (can't get boundary): " <<
snd_strerror(err) << std::endl;
return;
}
if ((err = snd_pcm_sw_params_set_silence_size(handle, sw_params, val)) < 0)
{
std::cout << " Error (can't set silence): " <<
snd_strerror(err) << std::endl;
return;
}
*/
if ((err = snd_pcm_sw_params(handle, sw_params)) < 0)
{
std::cout << " Error (can't set sw params): " <<
snd_strerror(err) << std::endl;
return;
}
snd_pcm_sw_params_free(sw_params);
// ------------------------- SW-Params End ---------------------------------
if ((err = snd_pcm_prepare(handle)) < 0)
{
std::cout << " Error (can't prepare audio): " <<
snd_strerror(err) << std::endl;
return;
}
snd_async_handler_t *pcm_callback;
if ((err = snd_async_add_pcm_handler(&pcm_callback, handle, MyCallback,
NULL)) < 0)
{
std::cout << " Error (can't add pcm handler): " <<
snd_strerror(err) << std::endl;
return;
}
if ((err = snd_pcm_writei(handle, buffer_alsa, 2 * period_size) == -EPIPE))
{
std::cout << " Error: XRUN" << std::endl;
err = snd_pcm_recover(handle, err, 0);
if ((err = snd_pcm_prepare (handle)) < 0)
{
std::cout << " Error (can't prepare audio): " <<
snd_strerror(err) << std::endl;
return;
}
}
if ((err = snd_pcm_start(handle)) < 0)
{
std::cout << " Error (can't start audio): " <<
snd_strerror(err) << std::endl;
return;
}
void MyCallback(snd_async_handler_t *pcm_callback);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Basic questions
2017-07-30 10:00 Basic questions tsepp2001
@ 2017-07-30 14:24 ` Clemens Ladisch
0 siblings, 0 replies; 7+ messages in thread
From: Clemens Ladisch @ 2017-07-30 14:24 UTC (permalink / raw)
To: tsepp2001, alsa-devel
tsepp2001@t-online.de wrote:
> Am I right to use async mode
No. It is not supported by all devices, and almost impossible to use
correctly.
> to get lowest latency times
Latency depends on the buffer size, and how fast your code can react to
the notification that some space is available.
> and using pause/play/stop?
You probably want to use non-blocking mode.
Regards,
Clemens
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-30 14:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-14 4:35 basic questions Harsha priya gupta
2008-03-14 22:35 ` Lee Revell
2008-03-14 22:57 ` Eliot Blennerhassett
2008-03-18 2:01 ` Lee Revell
2008-03-18 12:50 ` Harsha priya gupta
-- strict thread matches above, loose matches on Subject: below --
2017-07-30 10:00 Basic questions tsepp2001
2017-07-30 14:24 ` Clemens Ladisch
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.