Added more than two buffers support + various fixes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4611 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2003-09-10 15:49:09 +00:00
parent 5bae946703
commit c7116c9114
3 changed files with 25 additions and 37 deletions

View File

@ -1,7 +1,7 @@
/*
* multiaudio replacement media addon for BeOS
*
* Copyright (c) 2002, Jerome Duval (jerome.duval@free.fr)
* Copyright (c) 2002, 2003, Jerome Duval (jerome.duval@free.fr)
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
@ -254,9 +254,9 @@ status_t MultiAudioDevice::InitDriver()
// Set the sample rate
//
MFI.info_size = sizeof(MFI);
MFI.output.rate = select_multiaudio_rate(MD.output_rates); //B_SR_48000;
MFI.output.rate = select_multiaudio_rate(MD.output_rates);
MFI.output.cvsr = 0;
MFI.output.format = select_multiaudio_format(MD.output_formats); //B_FMT_16BIT;
MFI.output.format = select_multiaudio_format(MD.output_formats);
MFI.input.rate = MFI.output.rate;
MFI.input.cvsr = MFI.output.cvsr;
MFI.input.format = MFI.output.format;
@ -270,10 +270,10 @@ status_t MultiAudioDevice::InitDriver()
//
// Get the buffers
//
play_buffer_desc[0] = play_buffer_list0;
play_buffer_desc[1] = play_buffer_list1;
record_buffer_desc[0] = record_buffer_list0;
record_buffer_desc[1] = record_buffer_list1;
for (i = 0; i < NB_BUFFERS; i++) {
play_buffer_desc[i] = &play_buffer_list[i * MAX_CHANNELS];
record_buffer_desc[i] = &record_buffer_list[i * MAX_CHANNELS];
}
MBL.info_size = sizeof(MBL);
MBL.request_playback_buffer_size = 0; //use the default......
MBL.request_playback_buffers = NB_BUFFERS;
@ -282,7 +282,8 @@ status_t MultiAudioDevice::InitDriver()
MBL.request_record_buffer_size = 0; //use the default......
MBL.request_record_buffers = NB_BUFFERS;
MBL.request_record_channels = num_inputs;
MBL.record_buffers = (buffer_desc **) record_buffer_desc;
MBL.record_buffers = (buffer_desc **) record_buffer_desc;
rval = DRIVER_GET_BUFFERS(&MBL, 0);
if (B_OK != rval)
@ -292,34 +293,21 @@ status_t MultiAudioDevice::InitDriver()
}
for (i = 0; i < MBL.return_playback_buffers; i++)
{
for (int j=0; j < MBL.return_playback_channels; j++)
{
//fPlay[i][j] = (int32 *) MBL.playback_buffers[i][j].base;
for (int j=0; j < MBL.return_playback_channels; j++) {
PRINT(("MBL.playback_buffers[%d][%d].base: %p\n",
i,j,MBL.playback_buffers[i][j].base));
PRINT(("MBL.playback_buffers[%d][%d].stride: %i\n",
i,j,MBL.playback_buffers[i][j].stride));
}
//memset(MBL.playback_buffers[i][0].base, 0, MBL.return_playback_buffer_size * 4 /*samps to bytes*/);
//PRINT(("Play buffers[%d] size : %li zeroed\n",i, MBL.return_playback_buffer_size * 4));
}
for (i = 0; i < MBL.return_record_buffers; i++)
{
for (int j=0; j < MBL.return_record_channels; j++)
{
/*fRecord[i][j] = (int32 *) MBL.record_buffers[i][j].base;
PRINT(("Record buffers[%d][%d]: %p\n",i,j,fRecord[i][j]));*/
for (int j=0; j < MBL.return_record_channels; j++) {
PRINT(("MBL.record_buffers[%d][%d].base: %p\n",
i,j,MBL.record_buffers[i][j].base));
PRINT(("MBL.record_buffers[%d][%d].stride: %i\n",
i,j,MBL.record_buffers[i][j].stride));
}
//memset(MBL.record_buffers[i][0].base, 0, MBL.return_record_buffer_size * 4 /*samps to bytes*/);
//PRINT(("Record buffers[%d] size : %li zeroed\n",i, MBL.return_record_buffer_size * 4));
}
MMCI.info_size = sizeof(MMCI);
MMCI.control_count = MAX_CONTROLS;
MMCI.controls = MMC;

View File

@ -1,7 +1,7 @@
/*
* multiaudio replacement media addon for BeOS
*
* Copyright (c) 2002, Jerome Duval (jerome.duval@free.fr)
* Copyright (c) 2002, 2003, Jerome Duval (jerome.duval@free.fr)
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
@ -32,7 +32,7 @@
#define MAX_CONTROLS 128
#define MAX_CHANNELS 32
#define NB_BUFFERS 2
#define NB_BUFFERS 32
class MultiAudioDevice
{
@ -70,15 +70,10 @@ public:
multi_mix_control_info MMCI;
multi_mix_control MMC[MAX_CONTROLS];
/*int32 *fPlay[NB_BUFFERS][MAX_CHANNELS];
int32 *fRecord[NB_BUFFERS][MAX_CHANNELS];*/
buffer_desc play_buffer_list0[MAX_CHANNELS];
buffer_desc play_buffer_list1[MAX_CHANNELS];
buffer_desc play_buffer_list[NB_BUFFERS * MAX_CHANNELS];
buffer_desc record_buffer_list[NB_BUFFERS * MAX_CHANNELS];
buffer_desc *play_buffer_desc[NB_BUFFERS];
buffer_desc record_buffer_list0[MAX_CHANNELS];
buffer_desc record_buffer_list1[MAX_CHANNELS];
buffer_desc *record_buffer_desc[NB_BUFFERS];
private:

View File

@ -143,7 +143,9 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn *addon, char* name, MultiAudioDevice
* (fPreferredFormat.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
* fPreferredFormat.u.raw_audio.channel_count;
PRINT_OBJECT(*config);
if(config) {
PRINT_OBJECT(*config);
}
fInitCheckStatus = B_OK;
}
@ -1499,7 +1501,7 @@ MultiAudioNode::RunThread()
&& (input->fInput.source != media_source::null
|| input->fChannelId == 0)) {
//PRINT(("playback_buffer_cycle ok input : %i\n", i));
//PRINT(("playback_buffer_cycle ok input : %i %d\n", i, MBI.playback_buffer_cycle));
input->fBufferCycle = (MBI.playback_buffer_cycle - 1
+ fDevice->MBL.return_playback_buffers) % fDevice->MBL.return_playback_buffers;
@ -1769,7 +1771,7 @@ MultiAudioNode::StartThread()
return B_OK;
//allocate buffer free semaphore
fBuffer_free = create_sem( NB_BUFFERS - 1, "multi_audio out buffer free" );
fBuffer_free = create_sem( fDevice->MBL.return_playback_buffers - 1, "multi_audio out buffer free" );
if ( fBuffer_free < B_OK ) {
return B_ERROR;
@ -1879,6 +1881,9 @@ MultiAudioNode::GetConfigurationFor(BMessage * into_message)
bigtime_t last_change;
status_t err;
if(!into_message)
return B_BAD_VALUE;
buffer = malloc(size);
for(int32 i=0; i<fWeb->CountParameters(); i++) {