]> git.alsa-project.org Git - alsa-utils.git/commit
aplay: Fix playback for small raw files
authorDaniel Baluta <daniel.baluta@gmail.com>
Tue, 8 Aug 2017 22:06:00 +0000 (01:06 +0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 9 Aug 2017 08:39:36 +0000 (10:39 +0200)
commit1c9adf46b8e69f4b55eac414df68a14e84eecd03
treec1d99e09011d071640793f1cbc23b2881bd7a1a9
parentdba6db92284a56d933cfa538f1a4fd7ecc175a62
aplay: Fix playback for small raw files

This fixes a bug when trying to play files with size
smaller than maximum supported header size.

Lets have a look at the following example:

$ aplay -s 2 sample.raw

-> playback_go(fd = 10, loaded = 26, count = 2, name="sample.raw")
--> l = loaded = 26
--> c = count - written = 2
--> c -= l = 2 - 26 = -24
---> r = safe_read(fd, audiobuf + 26, -24)
---> r = -1, EXIT_FAILURE

In this case we have already 'loaded' from the input file more
bytes that we need to send to pcm device. So, we need to adjust
the number of bytes loaded and avoid reading a negative number
of bytes.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
aplay/aplay.c