summaryrefslogtreecommitdiffstats
path: root/alsa-pcm.c
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-08 16:59:57 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:40 +1100
commit3b2d2634474398bb40c64941c828a4cf6b363d4a (patch)
tree8224fd64a1a4898d0c126c6655b0dd8e5a0a1b2c /alsa-pcm.c
parentde58013ed69a18b28816894e4740ef4b71814bd9 (diff)
Fix DO_AUDIOPATH_CB, remove unused PCM cbs for now
We don't want to return inside the macro call necessarily. Some PCM cbs require differing return values. Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'alsa-pcm.c')
-rw-r--r--alsa-pcm.c117
1 files changed, 50 insertions, 67 deletions
diff --git a/alsa-pcm.c b/alsa-pcm.c
index 9ec21fc..17c08fd 100644
--- a/alsa-pcm.c
+++ b/alsa-pcm.c
@@ -16,12 +16,9 @@
#define D_ERRORK(fmt, args...) DERROR(D_LOGNAME, fmt, ##args)
#define DO_AUDIOPATH_CB(ap, callback, substream, ...) \
- do { \
- if ((ap)->pcm_ops->callback) { \
- return (ap)->pcm_ops->callback((substream), \
- ##__VA_ARGS__); \
- } \
- } while (0)
+ (((ap)->pcm_ops->callback) ? \
+ (ap)->pcm_ops->callback((substream), ##__VA_ARGS__) : \
+ 0)
/**
* avirt_pcm_period_elapsed - PCM buffer complete callback
@@ -76,9 +73,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
hw->channels_max = chans;
// Do additional Audio Path 'open' callback
- DO_AUDIOPATH_CB(audiopath, open, substream);
-
- return 0;
+ return DO_AUDIOPATH_CB(audiopath, open, substream);
}
/**
@@ -92,10 +87,9 @@ static int pcm_open(struct snd_pcm_substream *substream)
static int pcm_close(struct snd_pcm_substream *substream)
{
// Do additional Audio Path 'close' callback
- DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
- close, substream);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), close,
+ substream);
}
/**
@@ -111,7 +105,7 @@ static int pcm_close(struct snd_pcm_substream *substream)
static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{
- int err;
+ int retval;
size_t bufsz;
struct avirt_audiopath *audiopath;
struct avirt_stream *stream;
@@ -120,25 +114,21 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
if (IS_ERR_VALUE(stream) || !stream)
return PTR_ERR(stream);
- if ((params_channels(hw_params) > stream->channels)
- || (params_channels(hw_params) < stream->channels)) {
- pr_err("Requested number of channels not supported.\n");
+ if ((params_channels(hw_params) > stream->channels) ||
+ (params_channels(hw_params) < stream->channels)) {
+ D_ERRORK("Requested number of channels: %d not supported",
+ params_channels(hw_params));
return -EINVAL;
}
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);
- if (err <= 0) {
- pr_err("pcm: buffer allocation failed (%d)\n", err);
- return err;
- }
+ retval = snd_pcm_lib_alloc_vmalloc_buffer(substream, bufsz);
+ if (retval < 0)
+ D_ERRORK("pcm: buffer allocation failed: %d", retval);
- // Do additional Audio Path 'hw_params' callback
- DO_AUDIOPATH_CB(hw_params, substream, hw_params);
-
- return 0;
+ return retval;
}
/**
@@ -152,13 +142,14 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
*/
static int pcm_hw_free(struct snd_pcm_substream *substream)
{
- DINFO(AP_LOGNAME, "");
- CHK_ERR(snd_pcm_lib_free_vmalloc_buffer(substream));
+ int err;
// Do additional Audio Path 'hw_free' callback
- DO_AUDIOPATH_CB(hw_free, substream);
+ err = DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), hw_free,
+ substream);
- return 0;
+ return snd_pcm_lib_free_vmalloc_buffer(substream);
}
/**
@@ -174,10 +165,9 @@ 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(((struct avirt_audiopath *)substream->private_data),
- prepare, substream);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), prepare,
+ substream);
}
/**
@@ -204,10 +194,9 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
}
// Do additional Audio Path 'trigger' callback
- DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
- trigger, substream, cmd);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), trigger,
+ substream, cmd);
}
/**
@@ -223,10 +212,9 @@ 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(((struct avirt_audiopath *)substream->private_data),
- pointer, substream);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), pointer,
+ substream);
}
/**
@@ -247,11 +235,10 @@ static int pcm_get_time_info(
struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
{
- 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;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data),
+ get_time_info, substream, system_ts, audio_ts,
+ audio_tstamp_config, audio_tstamp_report);
}
/**
@@ -278,10 +265,9 @@ 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
- DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
- copy_user, substream, channel, pos, src, count);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), copy_user,
+ substream, channel, pos, src, count);
}
/**
@@ -300,10 +286,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)
{
- DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
- copy_kernel, substream, channel, pos, buf, count);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data),
+ copy_kernel, substream, channel, pos, buf, count);
}
/**
@@ -317,19 +302,17 @@ static int pcm_copy_kernel(struct snd_pcm_substream *substream, int channel,
*/
static int pcm_ack(struct snd_pcm_substream *substream)
{
- DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
- ack, substream);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data), ack,
+ substream);
}
static int pcm_silence(struct snd_pcm_substream *substream, int channel,
snd_pcm_uframes_t pos, snd_pcm_uframes_t count)
{
- DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
- fill_silence, substream, channel, pos, count);
-
- return 0;
+ return DO_AUDIOPATH_CB(
+ ((struct avirt_audiopath *)substream->private_data),
+ fill_silence, substream, channel, pos, count);
}
struct snd_pcm_ops pcm_ops = {
@@ -341,10 +324,10 @@ struct snd_pcm_ops pcm_ops = {
.prepare = pcm_prepare,
.trigger = pcm_trigger,
.pointer = pcm_pointer,
- .get_time_info = pcm_get_time_info,
- .fill_silence = pcm_silence,
+ //.get_time_info = pcm_get_time_info,
+ //.fill_silence = pcm_silence,
.copy_user = pcm_copy_user,
- .copy_kernel = pcm_copy_kernel,
+ //.copy_kernel = pcm_copy_kernel,
.page = snd_pcm_lib_get_vmalloc_page,
- .ack = pcm_ack,
+ //.ack = pcm_ack,
};