summaryrefslogtreecommitdiff
path: root/src/pcm/pcm_plugin.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2004-12-21 14:11:00 +0000
committerTakashi Iwai <tiwai@suse.de>2004-12-21 14:11:00 +0000
commit2b54677fdb34cca314f5b9560ccbafbf784590f5 (patch)
treead3db155d6236e0cef75ee75d047804b06cb5150 /src/pcm/pcm_plugin.c
parent73aa2549d9c6ad623159674f5cbb53dabf9c28d5 (diff)
downloadalsa-lib-2b54677fdb34cca314f5b9560ccbafbf784590f5.tar.gz
Change error message handling
Change the handling of non-fatal errors. Now the non-fatal error messages are not shown in stderr and no assert() as default. The behavior can be changed with LIBASOUND_DEBUG environment variable.
Diffstat (limited to 'src/pcm/pcm_plugin.c')
-rw-r--r--src/pcm/pcm_plugin.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
index f5972911..d8a5a028 100644
--- a/src/pcm/pcm_plugin.c
+++ b/src/pcm/pcm_plugin.c
@@ -373,7 +373,11 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
break;
frames = plugin->write(pcm, areas, offset, frames,
slave_areas, slave_offset, &slave_frames);
- assert(slave_frames <= snd_pcm_mmap_playback_avail(slave));
+ if (CHECK_SANITY(slave_frames > snd_pcm_mmap_playback_avail(slave))) {
+ SNDMSG("write overflow %ld > %ld", slave_frames,
+ snd_pcm_mmap_playback_avail(slave));
+ return -EPIPE;
+ }
snd_atomic_write_begin(&plugin->watom);
snd_pcm_mmap_appl_forward(pcm, frames);
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
@@ -415,7 +419,11 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
break;
frames = plugin->read(pcm, areas, offset, frames,
slave_areas, slave_offset, &slave_frames);
- assert(slave_frames <= snd_pcm_mmap_capture_avail(slave));
+ if (CHECK_SANITY(slave_frames > snd_pcm_mmap_capture_avail(slave))) {
+ SNDMSG("read overflow %ld > %ld", slave_frames,
+ snd_pcm_mmap_playback_avail(slave));
+ return -EPIPE;
+ }
snd_atomic_write_begin(&plugin->watom);
snd_pcm_mmap_appl_forward(pcm, frames);
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
@@ -531,7 +539,10 @@ snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
slave_size -= frames;
xfer += frames;
}
- assert(size == 0);
+ if (CHECK_SANITY(size)) {
+ SNDMSG("short commit: %ld", size);
+ return -EPIPE;
+ }
return xfer;
}