- Remove hackish modprobe install scripts for auto-loading OSS and sequencer modules (bsc#1136562); it's invoked from systemd unit file included in alsa-utils now - Backport upstream fixes: 0001-pcm-direct-Add-generic-hw_ptr_alignment-function-for.patch 0002-pcm-dshare-Added-hw_ptr_alignment-option-in-configur.patch 0003-pcm-dsnoop-Added-hw_ptr_alignment-option-in-configur.patch 0004-pcm-file-add-support-for-infile-reading-in-non-inter.patch 0005-pcm-file-use-snd_pcm_file_areas_read_infile-for-read.patch 0006-pcm-file-add-missing-unlock-on-early-return.patch 0007-ucm-Add-UCM-profile-for-CX2072X-codec-on-Baytrail-Ch.patch 0008-pcm-add-mmap_begin-callback-to-snd_pcm_fast_ops_t-ap.patch 0009-pcm-file-add-infile-read-support-for-mmap-mode.patch 0010-aserver-fix-resource-leak-coverity.patch 0011-src-conf.c-add-missing-va_end-call-coverity.patch 0012-config-parse_string-fix-the-dynamic-buffer-allocatio.patch 0013-control_shm-remove-duplicate-code-coverity.patch 0014-control_shm-add-missing-socket-close-to-the-error-pa.patch 0015-pcm-fix-memory-leak-in-_snd_pcm_parse_config_chmaps-.patch 0016-pcm_file-call-pclose-correctly-for-popen-coverity.patch 0017-pcm_hw-close-file-descriptor-in-the-error-path-in-sn.patch 0018-rawmidi-use-snd_dlobj_cache_get2-in-rawmidi-open-cov.patch 0019-rawmidi_hw-add-sanity-check-for-the-invalid-stream-a.patch 0020-topology-various-coverity-fixes.patch 0021-ucm-coverity-fixes.patch 0022-pcm_file-coverity-fixes-including-double-locking.patch 0023-topology-next-round-of-coverity-fixes.patch 0024-pcm_file-another-locking-fix-coverity.patch 0025-ucm-another-coverity-fix-in-uc_mgr_config_load.patch - Drop the downstream CX2072X UCM profile, which is replaced with OBS-URL: https://build.opensuse.org/request/show/706089 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=253
94 lines
2.9 KiB
Diff
94 lines
2.9 KiB
Diff
From fe7ff721a954c3f8c2183febc7c3fa5736357b67 Mon Sep 17 00:00:00 2001
|
|
From: Adam Miartus <amiartus@de.adit-jv.com>
|
|
Date: Thu, 23 May 2019 15:00:40 +0200
|
|
Subject: [PATCH 09/25] pcm: file: add infile read support for mmap mode
|
|
|
|
mmap_begin callback is used to copy data from input file to mmaped
|
|
buffer
|
|
|
|
guard for corner use of api (multiple mmap_begin calls by user) is
|
|
introduced to check if next continuous buffer was already overwritten
|
|
|
|
buffer is overwritten with input file data only in case of stream capture
|
|
|
|
Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
|
|
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
src/pcm/pcm_file.c | 31 +++++++++++++++++++++++++++++++
|
|
1 file changed, 31 insertions(+)
|
|
|
|
diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
|
|
index 8e2c70b12ab1..52cc10a9436a 100644
|
|
--- a/src/pcm/pcm_file.c
|
|
+++ b/src/pcm/pcm_file.c
|
|
@@ -88,6 +88,7 @@ typedef struct {
|
|
size_t buffer_bytes;
|
|
struct wav_fmt wav_header;
|
|
size_t filelen;
|
|
+ char ifmmap_overwritten;
|
|
} snd_pcm_file_t;
|
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
@@ -630,6 +631,8 @@ static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
|
|
const snd_pcm_channel_area_t *areas;
|
|
snd_pcm_sframes_t result;
|
|
|
|
+ file->ifmmap_overwritten = 0;
|
|
+
|
|
result = snd_pcm_mmap_begin(file->gen.slave, &areas, &ofs, &siz);
|
|
if (result >= 0) {
|
|
assert(ofs == offset && siz == size);
|
|
@@ -640,6 +643,32 @@ static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
|
|
return result;
|
|
}
|
|
|
|
+static int snd_pcm_file_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
|
|
+ snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames)
|
|
+{
|
|
+ snd_pcm_file_t *file = pcm->private_data;
|
|
+ snd_pcm_channel_area_t areas_if[pcm->channels];
|
|
+ snd_pcm_uframes_t frames_if;
|
|
+ void *buffer = NULL;
|
|
+ int result;
|
|
+
|
|
+ result = snd_pcm_mmap_begin(file->gen.slave, areas, offset, frames);
|
|
+ if (result < 0)
|
|
+ return result;
|
|
+
|
|
+ if (pcm->stream != SND_PCM_STREAM_CAPTURE)
|
|
+ return result;
|
|
+
|
|
+ /* user may run mmap_begin without mmap_commit multiple times in row */
|
|
+ if (file->ifmmap_overwritten)
|
|
+ return result;
|
|
+ file->ifmmap_overwritten = 1;
|
|
+
|
|
+ snd_pcm_file_areas_read_infile(pcm, *areas, *offset, *frames);
|
|
+
|
|
+ return result;
|
|
+}
|
|
+
|
|
static int snd_pcm_file_hw_free(snd_pcm_t *pcm)
|
|
{
|
|
snd_pcm_file_t *file = pcm->private_data;
|
|
@@ -666,6 +695,7 @@ static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|
file->wbuf_size = slave->buffer_size * 2;
|
|
file->wbuf_size_bytes = snd_pcm_frames_to_bytes(slave, file->wbuf_size);
|
|
file->wbuf_used_bytes = 0;
|
|
+ file->ifmmap_overwritten = 0;
|
|
assert(!file->wbuf);
|
|
file->wbuf = malloc(file->wbuf_size_bytes);
|
|
if (file->wbuf == NULL) {
|
|
@@ -777,6 +807,7 @@ static const snd_pcm_fast_ops_t snd_pcm_file_fast_ops = {
|
|
.poll_descriptors = snd_pcm_generic_poll_descriptors,
|
|
.poll_revents = snd_pcm_generic_poll_revents,
|
|
.htimestamp = snd_pcm_generic_htimestamp,
|
|
+ .mmap_begin = snd_pcm_file_mmap_begin,
|
|
};
|
|
|
|
/**
|
|
--
|
|
2.16.4
|
|
|