From 7c8482e991585675146d52f5df3b1e98147f591d Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 16 May 2007 21:43:15 +0000 Subject: [PATCH] * Count samples, not bytes, stupid :P * Don't try to bypass semaphore counting, it should just work(tm) * Minor cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21158 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/audio/hda/driver.c | 1 - src/add-ons/kernel/drivers/audio/hda/driver.h | 2 +- src/add-ons/kernel/drivers/audio/hda/hda_controller.c | 10 +++------- src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.c | 5 +++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/add-ons/kernel/drivers/audio/hda/driver.c b/src/add-ons/kernel/drivers/audio/hda/driver.c index 77acc9be85..ee0d74088e 100644 --- a/src/add-ons/kernel/drivers/audio/hda/driver.c +++ b/src/add-ons/kernel/drivers/audio/hda/driver.c @@ -7,7 +7,6 @@ pci_module_info* pci; const char** publish_devices(void); /* Just to silence compiler */ - status_t init_hardware(void) { diff --git a/src/add-ons/kernel/drivers/audio/hda/driver.h b/src/add-ons/kernel/drivers/audio/hda/driver.h index e464b9472d..685a306a44 100644 --- a/src/add-ons/kernel/drivers/audio/hda/driver.h +++ b/src/add-ons/kernel/drivers/audio/hda/driver.h @@ -8,7 +8,7 @@ #include #include -#ifdef COMPILED_FOR_R5 +#ifdef COMPILE_FOR_R5 #define DEVFS_PATH_FORMAT "audio/multi/hda/%lu" #include #else diff --git a/src/add-ons/kernel/drivers/audio/hda/hda_controller.c b/src/add-ons/kernel/drivers/audio/hda/hda_controller.c index 1b744550f0..a53a95da03 100644 --- a/src/add-ons/kernel/drivers/audio/hda/hda_controller.c +++ b/src/add-ons/kernel/drivers/audio/hda/hda_controller.c @@ -60,10 +60,8 @@ hda_stream_check_intr(hda_controller* ctrlr, hda_stream* s) uint8 sts = OREG8(ctrlr,s->off,STS); if (sts) { cpu_status status; - int32 count; OREG8(ctrlr,s->off,STS) = sts; - status = disable_interrupts(); acquire_spinlock(&s->lock); @@ -74,9 +72,7 @@ hda_stream_check_intr(hda_controller* ctrlr, hda_stream* s) release_spinlock(&s->lock); restore_interrupts(status); - get_sem_count(s->buffer_ready_sem, &count); - if (count <= 0) - release_sem_etc(s->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); + release_sem_etc(s->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); } } @@ -176,7 +172,7 @@ hda_stream_setup_buffers(hda_codec* codec, hda_stream* s, const char* desc) /* Setup BDL entries */ for (idx=0; idx < s->num_buffers; idx++, bdl++) { bdl->address = buffer_pa + (idx*buffer_size); - bdl->length = buffer_size; + bdl->length = s->sample_size * s->num_channels * s->buffer_length; bdl->ioc = 1; } @@ -208,7 +204,7 @@ hda_stream_setup_buffers(hda_codec* codec, hda_stream* s, const char* desc) OREG32(codec->ctrlr,s->off,BDPL) = s->bdl_pa; OREG32(codec->ctrlr,s->off,BDPU) = 0; OREG16(codec->ctrlr,s->off,LVI) = s->num_buffers -1; - OREG32(codec->ctrlr,s->off,CBL) = s->num_channels * s->num_buffers * s->sample_size; + OREG32(codec->ctrlr,s->off,CBL) = s->num_channels * s->num_buffers; OREG8(codec->ctrlr,s->off,CTL0) = CTL0_IOCE | CTL0_FEIE | CTL0_DEIE; OREG8(codec->ctrlr,s->off,CTL2) = s->id << 4; diff --git a/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.c b/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.c index b85f0a7bbc..6241433c9e 100644 --- a/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.c +++ b/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.c @@ -216,9 +216,10 @@ buffer_exchange(hda_codec* codec, multi_buffer_info* data) hda_stream_start(codec->ctrlr, codec->playback_stream); /* do playback */ - rc=acquire_sem_etc(codec->playback_stream->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000); + rc=acquire_sem(codec->playback_stream->buffer_ready_sem); if (rc != B_OK) { - dprintf("%s: Timeout waiting for playback buffer to finish!\n", __func__); + dprintf("%s: Error waiting for playback buffer to finish (%s)!\n", __func__, + strerror(rc)); return rc; }