return audio_ring_dist(cntinfo.ptr, oss->hw.pos_emul, oss->hw.size_emul);
}
+static void oss_run_buffer_out(HWVoiceOut *hw)
+{
+ OSSVoiceOut *oss = (OSSVoiceOut *)hw;
+
+ if (!oss->mmapped) {
+ audio_generic_run_buffer_out(hw);
+ }
+}
+
static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
size_t to_copy = MIN(len, hw->size_emul - hw->pos_emul);
memcpy(hw->buf_emul + hw->pos_emul, buf, to_copy);
- hw->pos_emul = (hw->pos_emul + to_copy) % hw->pos_emul;
+ hw->pos_emul = (hw->pos_emul + to_copy) % hw->size_emul;
buf += to_copy;
len -= to_copy;
}
oss->nfrags = obt.nfrags;
oss->fragsize = obt.fragsize;
- if (obt.nfrags * obt.fragsize & hw->info.align) {
+ if (obt.nfrags * obt.fragsize % hw->info.bytes_per_frame) {
dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n",
- obt.nfrags * obt.fragsize, hw->info.align + 1);
+ obt.nfrags * obt.fragsize, hw->info.bytes_per_frame);
}
- hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
+ hw->samples = (obt.nfrags * obt.fragsize) / hw->info.bytes_per_frame;
oss->mmapped = 0;
if (oopts->has_try_mmap && oopts->try_mmap) {
- hw->size_emul = hw->samples << hw->info.shift;
+ hw->size_emul = hw->samples * hw->info.bytes_per_frame;
hw->buf_emul = mmap(
NULL,
hw->size_emul,
AudiodevOssPerDirectionOptions *opdo = oss->dev->u.oss.out;
if (enable) {
- bool poll_mode = opdo->try_poll;
+ hw->poll_mode = opdo->try_poll;
ldebug("enabling voice\n");
- if (poll_mode) {
+ if (hw->poll_mode) {
oss_poll_out(hw);
- poll_mode = 0;
}
- hw->poll_mode = poll_mode;
if (!oss->mmapped) {
return;
}
- audio_pcm_info_clear_buf(&hw->info, hw->buf_emul, hw->mix_buf->size);
+ audio_pcm_info_clear_buf(&hw->info, hw->buf_emul, hw->samples);
trig = PCM_ENABLE_OUTPUT;
if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr(errno,
oss->nfrags = obt.nfrags;
oss->fragsize = obt.fragsize;
- if (obt.nfrags * obt.fragsize & hw->info.align) {
+ if (obt.nfrags * obt.fragsize % hw->info.bytes_per_frame) {
dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",
- obt.nfrags * obt.fragsize, hw->info.align + 1);
+ obt.nfrags * obt.fragsize, hw->info.bytes_per_frame);
}
- hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
+ hw->samples = (obt.nfrags * obt.fragsize) / hw->info.bytes_per_frame;
oss->fd = fd;
oss->dev = dev;
len, dst);
break;
}
+ break;
}
pos += nread;
AudiodevOssPerDirectionOptions *opdo = oss->dev->u.oss.out;
if (enable) {
- bool poll_mode = opdo->try_poll;
+ hw->poll_mode = opdo->try_poll;
- if (poll_mode) {
+ if (hw->poll_mode) {
oss_poll_in(hw);
- poll_mode = 0;
}
- hw->poll_mode = poll_mode;
} else {
if (hw->poll_mode) {
- hw->poll_mode = 0;
qemu_set_fd_handler (oss->fd, NULL, NULL, NULL);
+ hw->poll_mode = 0;
}
}
}
.init_out = oss_init_out,
.fini_out = oss_fini_out,
.write = oss_write,
+ .run_buffer_out = oss_run_buffer_out,
.get_buffer_out = oss_get_buffer_out,
.put_buffer_out = oss_put_buffer_out,
.enable_out = oss_enable_out,