aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-09-03 15:53:54 +1000
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:30 +1100
commita0213245df08e8eb2f3316e924539af216a95599 (patch)
tree92ca41ef849b702c73b29f0cacfc2a57f1ce58cc
parentf7f995a28c82c126619858ed40b92b5f33ddf2fe (diff)
Remove the unnecessary allocation of substreams in avirt_alsa_dev_group
Substreams are actually allocated by the PCM middle layer, so we do not need to do this here Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r--alsa-pcm.c9
-rwxr-xr-xalsa.c52
-rwxr-xr-xalsa.h10
3 files changed, 2 insertions, 69 deletions
diff --git a/alsa-pcm.c b/alsa-pcm.c
index 8c01c36..c5ff0b0 100644
--- a/alsa-pcm.c
+++ b/alsa-pcm.c
@@ -230,18 +230,9 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
*/
static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
- struct avirt_alsa_dev_group *group;
-
- DINFO(AP_LOGNAME, "");
-
- group = avirt_alsa_get_dev_group(substream->stream);
- CHK_NULL(group);
-
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
- group->streams[substream->pcm->device].substream = substream;
- break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
break;
diff --git a/alsa.c b/alsa.c
index 738048f..045624b 100755
--- a/alsa.c
+++ b/alsa.c
@@ -79,31 +79,6 @@ static int alloc_dev_config(struct avirt_alsa_dev_config **devconfig,
return 0;
}
-/**
- * alloc_dev_streams - Initializes ALSA device substream buffers
- * @return: 0 on success or error code otherwise
- */
-static int alloc_dev_streams(struct avirt_alsa_dev_config *config,
- struct avirt_alsa_stream **streams,
- unsigned numdevices)
-{
- unsigned i;
-
- if (numdevices == 0)
- return 0;
-
- *streams = kzalloc(sizeof(struct avirt_alsa_stream) * numdevices,
- GFP_KERNEL);
-
- if (!(*streams))
- return -EFAULT;
-
- for (i = 0; i < numdevices; i++)
- (*streams)[i].hw_frame_idx = 0;
-
- return 0;
-}
-
struct avirt_alsa_dev_group *avirt_alsa_get_dev_group(int direction)
{
if (!_driver) {
@@ -155,8 +130,6 @@ int avirt_alsa_configure_pcm(struct avirt_alsa_dev_config *config,
group->devices = numdevices;
- CHK_ERR(alloc_dev_streams(group->config, &group->streams,
- group->devices));
return 0;
}
@@ -207,12 +180,8 @@ int avirt_alsa_deregister(void)
snd_card_free(_driver->card);
CHK_NULL(_driver->playback.config);
kfree(_driver->playback.config);
- CHK_NULL(_driver->playback.streams);
- kfree(_driver->playback.streams);
CHK_NULL(_driver->capture.config);
kfree(_driver->capture.config);
- CHK_NULL(_driver->capture.streams);
- kfree(_driver->capture.streams);
CHK_NULL(_driver);
kfree(_driver);
@@ -229,27 +198,8 @@ int avirt_alsa_deregister(void)
*/
int pcm_buff_complete_cb(struct snd_pcm_substream *substream)
{
- int maxframe, deviceid;
- struct avirt_audiopath *audiopath;
- struct avirt_alsa_dev_group *group;
-
- deviceid = substream->pcm->device;
-
- group = avirt_alsa_get_dev_group(substream->stream);
- CHK_NULL(group);
-
- audiopath = avirt_get_current_audiopath();
- CHK_NULL_V(audiopath, "Cannot find Audio Path!");
-
- group->streams[deviceid].hw_frame_idx += audiopath->blocksize;
- maxframe = audiopath->blocksize * audiopath->hw->periods_max;
-
- // Once the index reaches the DMA buffer boundary, reset it to 0
- if (group->streams[deviceid].hw_frame_idx >= maxframe)
- group->streams[deviceid].hw_frame_idx = 0;
-
// Notify ALSA middle layer of the elapsed period boundary
- snd_pcm_period_elapsed(group->streams[deviceid].substream);
+ snd_pcm_period_elapsed(substream);
return 0;
}
diff --git a/alsa.h b/alsa.h
index 113b575..ef9b9ca 100755
--- a/alsa.h
+++ b/alsa.h
@@ -11,6 +11,7 @@
#define __AVIRT_ALSA_H__
#include <linux/platform_device.h>
+#include <sound/pcm.h>
#define MAX_NAME_LEN 32
@@ -54,19 +55,10 @@ struct avirt_alsa_dev_config {
};
/**
- * Stream maintainance
- */
-struct avirt_alsa_stream {
- int hw_frame_idx;
- struct snd_pcm_substream *substream;
-};
-
-/**
* Collection of devices
*/
struct avirt_alsa_dev_group {
struct avirt_alsa_dev_config *config;
- struct avirt_alsa_stream *streams;
int devices;
int buffersize;
};