From c8ffcaaefe60facee55d53cc38bfd294fc1934ea Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 16 Oct 2019 12:23:42 +0200 Subject: [PATCH] plugins: just check the data pointer We don't need to look at the data type, we just just be happy when the data pointer is filled in. --- spa/plugins/alsa/alsa-pcm-sink.c | 6 +----- spa/plugins/alsa/alsa-pcm-source.c | 4 +--- spa/plugins/alsa/alsa-seq-source.c | 4 +--- spa/plugins/audioconvert/channelmix.c | 4 +--- spa/plugins/audioconvert/fmtconvert.c | 4 +--- spa/plugins/audioconvert/merger.c | 4 +--- spa/plugins/audioconvert/resample.c | 4 +--- spa/plugins/audioconvert/splitter.c | 4 +--- spa/plugins/audioconvert/test-source.c | 4 +--- spa/plugins/audiomixer/audiomixer.c | 4 +--- spa/plugins/audiomixer/mixer-dsp.c | 4 +--- spa/plugins/audiotestsrc/audiotestsrc.c | 4 +--- spa/plugins/bluez5/a2dp-sink.c | 6 +----- spa/plugins/bluez5/a2dp-source.c | 4 +--- spa/plugins/bluez5/sco-sink.c | 6 +----- spa/plugins/bluez5/sco-source.c | 4 +--- spa/plugins/test/fakesink.c | 4 +--- spa/plugins/test/fakesrc.c | 4 +--- spa/plugins/videotestsrc/videotestsrc.c | 4 +--- spa/plugins/volume/volume.c | 4 +--- 20 files changed, 20 insertions(+), 66 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm-sink.c b/spa/plugins/alsa/alsa-pcm-sink.c index 85d77fc88..67d9569c4 100644 --- a/spa/plugins/alsa/alsa-pcm-sink.c +++ b/spa/plugins/alsa/alsa-pcm-sink.c @@ -544,7 +544,6 @@ impl_node_port_use_buffers(void *object, for (i = 0; i < n_buffers; i++) { struct buffer *b = &this->buffers[i]; struct spa_data *d = buffers[i]->datas; - uint32_t type; b->buf = buffers[i]; b->id = i; @@ -552,10 +551,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(b->buf, SPA_META_Header, sizeof(*b->h)); - type = d[0].type; - if ((type == SPA_DATA_MemFd || - type == SPA_DATA_DmaBuf || - type == SPA_DATA_MemPtr) && d[0].data == NULL) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/alsa/alsa-pcm-source.c b/spa/plugins/alsa/alsa-pcm-source.c index 70a7a5d6b..02efb61f5 100644 --- a/spa/plugins/alsa/alsa-pcm-source.c +++ b/spa/plugins/alsa/alsa-pcm-source.c @@ -564,9 +564,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(b->buf, SPA_META_Header, sizeof(*b->h)); - if (!((d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf || - d[0].type == SPA_DATA_MemPtr) && d[0].data != NULL)) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/alsa/alsa-seq-source.c b/spa/plugins/alsa/alsa-seq-source.c index c0f195bd6..1e0f53fdf 100644 --- a/spa/plugins/alsa/alsa-seq-source.c +++ b/spa/plugins/alsa/alsa-seq-source.c @@ -726,9 +726,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(b->buf, SPA_META_Header, sizeof(*b->h)); - if (!((d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf || - d[0].type == SPA_DATA_MemPtr) && d[0].data != NULL)) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index 580e7a4db..2178f4524 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -748,9 +748,7 @@ impl_node_port_use_buffers(void *object, else if (size != d[j].maxsize) return -EINVAL; - if (!((d[j].type == SPA_DATA_MemPtr || - d[j].type == SPA_DATA_MemFd || - d[j].type == SPA_DATA_DmaBuf) && d[j].data != NULL)) { + if (d[j].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return -EINVAL; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 82d807d9f..f1e44487b 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -690,9 +690,7 @@ impl_node_port_use_buffers(void *object, return -EINVAL; } - if (!((d[j].type == SPA_DATA_MemPtr || - d[j].type == SPA_DATA_MemFd || - d[j].type == SPA_DATA_DmaBuf) && d[j].data != NULL)) { + if (d[j].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory %d on buffer %d", this, j, i); return -EINVAL; diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index e706f9149..a22af59a9 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -789,9 +789,7 @@ impl_node_port_use_buffers(void *object, } for (j = 0; j < n_datas; j++) { - if (!((d[j].type == SPA_DATA_MemPtr || - d[j].type == SPA_DATA_MemFd || - d[j].type == SPA_DATA_DmaBuf) && d[j].data != NULL)) { + if (d[j].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory %d on buffer %d %d %p", this, j, i, d[j].type, d[j].data); return -EINVAL; diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 96f9a25a9..898d8da55 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -602,9 +602,7 @@ impl_node_port_use_buffers(void *object, if (size != d[j].maxsize) return -EINVAL; - if (!((d[j].type == SPA_DATA_MemPtr || - d[j].type == SPA_DATA_MemFd || - d[j].type == SPA_DATA_DmaBuf) && d[j].data != NULL)) { + if (d[j].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return -EINVAL; diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 48a8185b2..731d91d73 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -745,9 +745,7 @@ impl_node_port_use_buffers(void *object, b->flags = 0; for (j = 0; j < n_datas; j++) { - if (!((d[j].type == SPA_DATA_MemPtr || - d[j].type == SPA_DATA_MemFd || - d[j].type == SPA_DATA_DmaBuf) && d[j].data != NULL)) { + if (d[j].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory %d on buffer %d %d %p", this, j, i, d[j].type, d[j].data); return -EINVAL; diff --git a/spa/plugins/audioconvert/test-source.c b/spa/plugins/audioconvert/test-source.c index ccd02fc92..144c4e15e 100644 --- a/spa/plugins/audioconvert/test-source.c +++ b/spa/plugins/audioconvert/test-source.c @@ -663,9 +663,7 @@ impl_node_port_use_buffers(void *object, else if (size != d[j].maxsize) return -EINVAL; - if (!((d[j].type == SPA_DATA_MemPtr || - d[j].type == SPA_DATA_MemFd || - d[j].type == SPA_DATA_DmaBuf) && d[j].data != NULL)) { + if (d[j].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return -EINVAL; diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index ea44999e5..e4b55deaf 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -559,9 +559,7 @@ impl_node_port_use_buffers(void *object, b->outstanding = (direction == SPA_DIRECTION_INPUT); b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if (!((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data != NULL)) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return -EINVAL; diff --git a/spa/plugins/audiomixer/mixer-dsp.c b/spa/plugins/audiomixer/mixer-dsp.c index d797086d4..3b1241ab6 100644 --- a/spa/plugins/audiomixer/mixer-dsp.c +++ b/spa/plugins/audiomixer/mixer-dsp.c @@ -591,9 +591,7 @@ impl_node_port_use_buffers(void *object, b->id = i; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if (!((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data != NULL)) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %d", this, i); return -EINVAL; } diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index b1f1ebc33..c383a15c1 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -780,9 +780,7 @@ impl_node_port_use_buffers(void *object, b->outstanding = false; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if ((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data == NULL) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return -EINVAL; diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index ba2092b07..d9febe2d9 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -1233,7 +1233,6 @@ impl_node_port_use_buffers(void *object, for (i = 0; i < n_buffers; i++) { struct buffer *b = &port->buffers[i]; - uint32_t type; b->buf = buffers[i]; b->id = i; @@ -1241,10 +1240,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - type = buffers[i]->datas[0].type; - if ((type == SPA_DATA_MemFd || - type == SPA_DATA_DmaBuf || - type == SPA_DATA_MemPtr) && buffers[i]->datas[0].data == NULL) { + if (buffers[i]->datas[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index ec064648f..3ffb70e34 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -898,9 +898,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if (!((d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf || - d[0].type == SPA_DATA_MemPtr) && d[0].data != NULL)) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index 46e9591d2..9583afd21 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -923,7 +923,6 @@ impl_node_port_use_buffers(void *object, for (i = 0; i < n_buffers; i++) { struct buffer *b = &port->buffers[i]; - uint32_t type; b->buf = buffers[i]; b->id = i; @@ -931,10 +930,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - type = buffers[i]->datas[0].type; - if ((type == SPA_DATA_MemFd || - type == SPA_DATA_DmaBuf || - type == SPA_DATA_MemPtr) && buffers[i]->datas[0].data == NULL) { + if (buffers[i]->datas[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/bluez5/sco-source.c b/spa/plugins/bluez5/sco-source.c index 1eb194cb3..7fdb0b05b 100644 --- a/spa/plugins/bluez5/sco-source.c +++ b/spa/plugins/bluez5/sco-source.c @@ -829,9 +829,7 @@ impl_node_port_use_buffers(void *object, b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if (!((d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf || - d[0].type == SPA_DATA_MemPtr) && d[0].data != NULL)) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: need mapped memory", this); return -EINVAL; } diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index d08c01ca7..a2f5117f9 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -584,9 +584,7 @@ impl_node_port_use_buffers(void *object, b->outstanding = true; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if ((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data == NULL) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); } diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index df8edc70f..234236340 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -599,9 +599,7 @@ impl_node_port_use_buffers(void *object, b->outstanding = false; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if ((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data == NULL) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); } diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index b384eba07..a654903e0 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -699,9 +699,7 @@ impl_node_port_use_buffers(void *object, b->outstanding = false; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if ((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data == NULL) { + if (d[0].data == NULL) { spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return -EINVAL; diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 82ecc3141..0a321f63e 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -530,9 +530,7 @@ impl_node_port_use_buffers(void *object, b->flags = direction == SPA_DIRECTION_INPUT ? BUFFER_FLAG_OUT : 0; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - if ((d[0].type == SPA_DATA_MemPtr || - d[0].type == SPA_DATA_MemFd || - d[0].type == SPA_DATA_DmaBuf) && d[0].data != NULL) { + if (d[0].data == NULL) { b->ptr = d[0].data; b->size = d[0].maxsize; } else {