aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyalsa/pcm.h4
-rw-r--r--src/pcm.c8
-rw-r--r--tests/src/pcm_out_test.cc6
-rw-r--r--utils/tinyplay.c3
4 files changed, 12 insertions, 9 deletions
diff --git a/include/tinyalsa/pcm.h b/include/tinyalsa/pcm.h
index 6569146..b40550c 100644
--- a/include/tinyalsa/pcm.h
+++ b/include/tinyalsa/pcm.h
@@ -335,9 +335,9 @@ int pcm_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DE
int pcm_read(struct pcm *pcm, void *data, unsigned int count) TINYALSA_DEPRECATED;
-int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count);
+int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
-int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count);
+int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count) TINYALSA_DEPRECATED;
int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset, unsigned int *frames);
diff --git a/src/pcm.c b/src/pcm.c
index 3d7da0c..10e477b 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -1547,10 +1547,10 @@ int pcm_mmap_transfer(struct pcm *pcm, void *buffer, unsigned int frames)
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count)
{
if ((~pcm->flags) & (PCM_OUT | PCM_MMAP))
- return -ENOSYS;
+ return -EINVAL;
unsigned int frames = pcm_bytes_to_frames(pcm, count);
- int res = pcm_mmap_transfer(pcm, (void *) data, frames);
+ int res = pcm_writei(pcm, (void *) data, frames);
if (res < 0) {
return res;
@@ -1562,10 +1562,10 @@ int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count)
int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count)
{
if ((~pcm->flags) & (PCM_IN | PCM_MMAP))
- return -ENOSYS;
+ return -EINVAL;
unsigned int frames = pcm_bytes_to_frames(pcm, count);
- int res = pcm_mmap_transfer(pcm, data, frames);
+ int res = pcm_readi(pcm, data, frames);
if (res < 0) {
return res;
diff --git a/tests/src/pcm_out_test.cc b/tests/src/pcm_out_test.cc
index cbc6983..f8d4345 100644
--- a/tests/src/pcm_out_test.cc
+++ b/tests/src/pcm_out_test.cc
@@ -192,13 +192,13 @@ TEST_F(PcmOutMmapTest, Write) {
buffer[i] = static_cast<char>(i);
}
- int written_frames = 0;
+ int res = 0;
unsigned int frames = pcm_bytes_to_frames(pcm_object, buffer_size);
pcm_start(pcm_object);
auto start = std::chrono::steady_clock::now();
for (uint32_t i = 0; i < write_count; ++i) {
- written_frames = pcm_mmap_write(pcm_object, buffer.get(), buffer_size);
- ASSERT_EQ(written_frames, frames);
+ res = pcm_mmap_write(pcm_object, buffer.get(), buffer_size);
+ ASSERT_EQ(res, 0);
}
pcm_stop(pcm_object);
diff --git a/utils/tinyplay.c b/utils/tinyplay.c
index 2689158..4c7ccf6 100644
--- a/utils/tinyplay.c
+++ b/utils/tinyplay.c
@@ -303,6 +303,9 @@ int main(int argc, char **argv)
case 'i':
cmd.filetype = opts.optarg;
break;
+ case 'M':
+ cmd.flags |= PCM_MMAP;
+ break;
case 'h':
print_usage(argv[0]);
return EXIT_SUCCESS;