moved the check for settings like sample rate, buffer count, buffer frames in open()

changes on auich.settings are now taken into account when restarting media_server


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27972 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2008-10-11 15:31:15 +00:00
parent d654f56af2
commit c019da3ccf
3 changed files with 32 additions and 19 deletions

View File

@ -721,30 +721,13 @@ init_driver(void)
void *settings_handle;
pci_info info;
num_cards = 0;
PRINT(("init_driver()\n"));
// get driver settings
settings_handle = load_driver_settings("auich.settings");
settings_handle = load_driver_settings(AUICH_SETTINGS);
if (settings_handle != NULL) {
const char *item;
char *end;
uint32 value;
item = get_driver_parameter (settings_handle, "sample_rate", "48000", "48000");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.sample_rate = value;
item = get_driver_parameter (settings_handle, "buffer_frames", "256", "256");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.buffer_frames = value;
item = get_driver_parameter (settings_handle, "buffer_count", "4", "4");
value = strtoul (item, &end, 0);
if (*end == '\0') current_settings.buffer_count = value;
current_settings.use_thread = get_driver_boolean_parameter (settings_handle, "use_thread", false, false);
unload_driver_settings (settings_handle);
}

View File

@ -167,6 +167,8 @@ typedef struct _auich_dev {
} auich_dev;
#define AUICH_SETTINGS "auich.settings"
typedef struct {
uint32 sample_rate;
uint32 buffer_frames;

View File

@ -29,6 +29,7 @@
*
*/
#include <driver_settings.h>
#include <OS.h>
#include <MediaDefs.h>
#include <strings.h>
@ -43,6 +44,7 @@
#include "util.h"
#include "io.h"
static void
auich_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) {
auich_dev *dev = (auich_dev*)card;
@ -1011,6 +1013,7 @@ static status_t
auich_open(const char *name, uint32 flags, void** cookie)
{
auich_dev *card = NULL;
void *settings_handle;
int ix;
LOG(("open()\n"));
@ -1039,6 +1042,31 @@ auich_open(const char *name, uint32 flags, void** cookie)
*cookie = card;
card->multi.card = card;
// get driver settings
settings_handle = load_driver_settings(AUICH_SETTINGS);
if (settings_handle != NULL) {
const char *item;
char *end;
uint32 value;
item = get_driver_parameter (settings_handle, "sample_rate", "48000", "48000");
value = strtoul (item, &end, 0);
if (*end == '\0')
current_settings.sample_rate = value;
item = get_driver_parameter (settings_handle, "buffer_frames", "256", "256");
value = strtoul (item, &end, 0);
if (*end == '\0')
current_settings.buffer_frames = value;
item = get_driver_parameter (settings_handle, "buffer_count", "4", "4");
value = strtoul (item, &end, 0);
if (*end == '\0')
current_settings.buffer_count = value;
unload_driver_settings(settings_handle);
}
LOG(("stream_new\n"));
card->rstream = auich_stream_new(card, AUICH_USE_RECORD, current_settings.buffer_frames, current_settings.buffer_count);