summaryrefslogtreecommitdiffstats
path: root/alsa-pcm.c
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-09-20 12:09:20 +1000
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:33 +1100
commit3786b607d4dd5e738cbe491dbfb03c2283e74358 (patch)
tree83f150ee7eee8ab42d827f6a1b3c5af68ac9fcbd /alsa-pcm.c
parent99a09bc4fe16d275b2bf839cb8f37192b2235e24 (diff)
Add 'uid' field to AP, store AP in PCM private data, fix helper macros
We want to use a UID when registering APs, that must start with "ap_", and acts as a unique identifier for each AP. To move forward with the adoption of routing PCMs to differing APs, we now store the AP in the PCM private data - set at pcm_open. A fix to the helper macros now allows additional args to be passed in for inclusion to the debug string Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'alsa-pcm.c')
-rw-r--r--alsa-pcm.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/alsa-pcm.c b/alsa-pcm.c
index 9b55a14..ac9175b 100644
--- a/alsa-pcm.c
+++ b/alsa-pcm.c
@@ -9,13 +9,8 @@
#include "alsa.h"
-#define AP_LOGNAME "CORE"
-
-#define DO_AUDIOPATH_CB(callback, substream, ...) \
+#define DO_AUDIOPATH_CB(ap, callback, substream, ...) \
do { \
- struct avirt_audiopath *ap; \
- ap = avirt_get_current_audiopath(); \
- CHK_NULL_V(ap, "Cannot find Audio Path!"); \
if (ap->pcm_ops->callback) { \
return ap->pcm_ops->callback((substream), \
##__VA_ARGS__); \
@@ -42,8 +37,10 @@ static int pcm_open(struct snd_pcm_substream *substream)
struct snd_pcm_hardware *hw;
unsigned int bytes_per_sample = 0, blocksize = 0;
- audiopath = avirt_get_current_audiopath();
- CHK_NULL_V(audiopath, "Cannot find Audio Path!");
+ char *uid = "ap_dummy"; // TD MF: Make this dynamic!
+ audiopath = avirt_get_audiopath(uid);
+ CHK_NULL_V(audiopath, "Cannot find Audio Path uid: '%s'!", uid);
+ substream->private_data = audiopath;
blocksize = audiopath->blocksize;
@@ -82,7 +79,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
hw->period_bytes_max = blocksize * bytes_per_sample * config->channels;
// Do additional Audio Path 'open' callback
- DO_AUDIOPATH_CB(open, substream);
+ DO_AUDIOPATH_CB(audiopath, open, substream);
return 0;
}
@@ -99,7 +96,8 @@ static int pcm_close(struct snd_pcm_substream *substream)
{
DINFO(AP_LOGNAME, "");
// Do additional Audio Path 'close' callback
- DO_AUDIOPATH_CB(close, substream);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ close, substream);
return 0;
}
@@ -133,9 +131,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}
- audiopath = avirt_get_current_audiopath();
- CHK_NULL_V(audiopath, "Cannot find Audio Path!");
-
+ audiopath = ((struct avirt_audiopath *)substream->private_data);
bufsz = params_buffer_bytes(hw_params) * audiopath->hw->periods_max;
err = snd_pcm_lib_alloc_vmalloc_buffer(substream, bufsz);
@@ -183,7 +179,8 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
static int pcm_prepare(struct snd_pcm_substream *substream)
{
// Do additional Audio Path 'prepare' callback
- DO_AUDIOPATH_CB(prepare, substream);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ prepare, substream);
return 0;
}
@@ -212,7 +209,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
}
// Do additional Audio Path 'trigger' callback
- DO_AUDIOPATH_CB(trigger, substream, cmd);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ trigger, substream, cmd);
return 0;
}
@@ -230,7 +228,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream)
{
// Do additional Audio Path 'pointer' callback
- DO_AUDIOPATH_CB(pointer, substream);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ pointer, substream);
return 0;
}
@@ -258,7 +257,8 @@ static int pcm_get_time_info(
group = avirt_alsa_get_group(substream->stream);
CHK_NULL(group);
- DO_AUDIOPATH_CB(get_time_info, substream, system_ts, audio_ts,
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ get_time_info, substream, system_ts, audio_ts,
audio_tstamp_config, audio_tstamp_report);
return 0;
@@ -288,8 +288,8 @@ static int pcm_copy_user(struct snd_pcm_substream *substream, int channel,
//offset = frames_to_bytes(runtime, pos);
// Do additional Audio Path 'copy_user' callback
- DINFO(AP_LOGNAME, "");
- DO_AUDIOPATH_CB(copy_user, substream, channel, pos, src, count);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ copy_user, substream, channel, pos, src, count);
return 0;
}
@@ -310,8 +310,9 @@ static int pcm_copy_user(struct snd_pcm_substream *substream, int channel,
static int pcm_copy_kernel(struct snd_pcm_substream *substream, int channel,
unsigned long pos, void *buf, unsigned long count)
{
- DINFO(AP_LOGNAME, "");
- DO_AUDIOPATH_CB(copy_kernel, substream, channel, pos, buf, count);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ copy_kernel, substream, channel, pos, buf, count);
+
return 0;
}
@@ -326,16 +327,18 @@ static int pcm_copy_kernel(struct snd_pcm_substream *substream, int channel,
*/
int pcm_ack(struct snd_pcm_substream *substream)
{
- DINFO(AP_LOGNAME, "");
- DO_AUDIOPATH_CB(ack, substream);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ ack, substream);
+
return 0;
}
static int pcm_silence(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos, snd_pcm_uframes_t count)
{
- DINFO(AP_LOGNAME, "");
- DO_AUDIOPATH_CB(fill_silence, substream, channel, pos, count);
+ DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
+ fill_silence, substream, channel, pos, count);
+
return 0;
}