code style

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20821 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-04-25 18:34:20 +00:00
parent 43404c50c4
commit f96df43ff5
4 changed files with 222 additions and 306 deletions
@@ -1,30 +1,8 @@
/* /*
* multiaudio replacement media addon for BeOS
*
* Copyright (c) 2002, Jerome Duval ([email protected]) * Copyright (c) 2002, Jerome Duval ([email protected])
* * Distributed under the terms of the MIT License.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ */
#include <MediaDefs.h> #include <MediaDefs.h>
#include <MediaAddOn.h> #include <MediaAddOn.h>
#include <Errors.h> #include <Errors.h>
@@ -63,7 +41,7 @@ MultiAudioAddOn::~MultiAudioAddOn()
CALLED(); CALLED();
void *device = NULL; void *device = NULL;
for ( int32 i = 0; (device = fDevices.ItemAt(i)); i++ ) for (int32 i = 0; (device = fDevices.ItemAt(i)); i++)
delete (MultiAudioDevice *)device; delete (MultiAudioDevice *)device;
SaveSettings(); SaveSettings();
@@ -76,7 +54,7 @@ MultiAudioAddOn::MultiAudioAddOn(image_id image) :
CALLED(); CALLED();
fInitCheckStatus = B_NO_INIT; fInitCheckStatus = B_NO_INIT;
if(RecursiveScan("/dev/audio/hmulti/")!=B_OK) if (RecursiveScan("/dev/audio/hmulti/") != B_OK)
return; return;
LoadSettings(); LoadSettings();
@@ -107,11 +85,11 @@ status_t MultiAudioAddOn::GetFlavorAt(
{ {
CALLED(); CALLED();
if (out_info == 0) { if (out_info == 0) {
fprintf(stderr,"<- B_BAD_VALUE\n"); fprintf(stderr, "<- B_BAD_VALUE\n");
return B_BAD_VALUE; // we refuse to crash because you were stupid return B_BAD_VALUE; // we refuse to crash because you were stupid
} }
if (n < 0 || n > fDevices.CountItems() - 1) { if (n < 0 || n > fDevices.CountItems() - 1) {
fprintf(stderr,"<- B_BAD_INDEX\n"); fprintf(stderr, "<- B_BAD_INDEX\n");
return B_BAD_INDEX; return B_BAD_INDEX;
} }
@@ -125,37 +103,37 @@ status_t MultiAudioAddOn::GetFlavorAt(
} }
BMediaNode * MultiAudioAddOn::InstantiateNodeFor( BMediaNode * MultiAudioAddOn::InstantiateNodeFor(
const flavor_info * info, const flavor_info * info,
BMessage * config, BMessage * config,
status_t * out_error) status_t * out_error)
{ {
CALLED(); CALLED();
if (out_error == 0) { if (out_error == 0) {
fprintf(stderr,"<- NULL\n"); fprintf(stderr, "<- NULL\n");
return 0; // we refuse to crash because you were stupid return 0; // we refuse to crash because you were stupid
} }
MultiAudioDevice *device = (MultiAudioDevice*)fDevices.ItemAt(info->internal_id); MultiAudioDevice *device = (MultiAudioDevice*)fDevices.ItemAt(info->internal_id);
if(device == NULL) { if (device == NULL) {
*out_error = B_ERROR; *out_error = B_ERROR;
return NULL; return NULL;
} }
#ifdef MULTI_SAVE #ifdef MULTI_SAVE
if(fSettings.FindMessage(device->MD.friendly_name, config)==B_OK) { if (fSettings.FindMessage(device->MD.friendly_name, config) == B_OK) {
fSettings.RemoveData(device->MD.friendly_name); fSettings.RemoveData(device->MD.friendly_name);
} }
#endif #endif
MultiAudioNode * node MultiAudioNode * node =
= new MultiAudioNode(this, new MultiAudioNode(this,
device->MD.friendly_name, device->MD.friendly_name,
device, device,
info->internal_id, info->internal_id,
config); config);
if (node == 0) { if (node == 0) {
*out_error = B_NO_MEMORY; *out_error = B_NO_MEMORY;
fprintf(stderr,"<- B_NO_MEMORY\n"); fprintf(stderr, "<- B_NO_MEMORY\n");
} else { } else {
*out_error = node->InitCheck(); *out_error = node->InitCheck();
} }
@@ -171,10 +149,10 @@ MultiAudioAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_mes
into_message = new BMessage(); into_message = new BMessage();
MultiAudioNode * node = dynamic_cast<MultiAudioNode*>(your_node); MultiAudioNode * node = dynamic_cast<MultiAudioNode*>(your_node);
if (node == 0) { if (node == 0) {
fprintf(stderr,"<- B_BAD_TYPE\n"); fprintf(stderr, "<- B_BAD_TYPE\n");
return B_BAD_TYPE; return B_BAD_TYPE;
} }
if(node->GetConfigurationFor(into_message)==B_OK) { if (node->GetConfigurationFor(into_message) == B_OK) {
fSettings.AddMessage(your_node->Name(), into_message); fSettings.AddMessage(your_node->Name(), into_message);
} }
return B_OK; return B_OK;
@@ -182,12 +160,12 @@ MultiAudioAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_mes
#endif #endif
// currently never called by the media kit. Seems it is not implemented. // currently never called by the media kit. Seems it is not implemented.
if (into_message == 0) { if (into_message == 0) {
fprintf(stderr,"<- B_BAD_VALUE\n"); fprintf(stderr, "<- B_BAD_VALUE\n");
return B_BAD_VALUE; // we refuse to crash because you were stupid return B_BAD_VALUE; // we refuse to crash because you were stupid
} }
MultiAudioNode * node = dynamic_cast<MultiAudioNode*>(your_node); MultiAudioNode * node = dynamic_cast<MultiAudioNode*>(your_node);
if (node == 0) { if (node == 0) {
fprintf(stderr,"<- B_BAD_TYPE\n"); fprintf(stderr, "<- B_BAD_TYPE\n");
return B_BAD_TYPE; return B_BAD_TYPE;
} }
return node->GetConfigurationFor(into_message); return node->GetConfigurationFor(into_message);
@@ -201,10 +179,10 @@ bool MultiAudioAddOn::WantsAutoStart()
} }
status_t MultiAudioAddOn::AutoStart( status_t MultiAudioAddOn::AutoStart(
int in_count, int in_count,
BMediaNode ** out_node, BMediaNode ** out_node,
int32 * out_internal_id, int32 * out_internal_id,
bool * out_has_more) bool * out_has_more)
{ {
CALLED(); CALLED();
return B_OK; return B_OK;
@@ -216,9 +194,9 @@ MultiAudioAddOn::RecursiveScan(char* rootPath, BEntry *rootEntry)
CALLED(); CALLED();
BDirectory root; BDirectory root;
if(rootEntry!=NULL) if (rootEntry != NULL)
root.SetTo(rootEntry); root.SetTo(rootEntry);
else if(rootPath!=NULL) { else if (rootPath != NULL) {
root.SetTo(rootPath); root.SetTo(rootPath);
} else { } else {
PRINT(("Error in MultiAudioAddOn::RecursiveScan null params\n")); PRINT(("Error in MultiAudioAddOn::RecursiveScan null params\n"));
@@ -227,9 +205,9 @@ MultiAudioAddOn::RecursiveScan(char* rootPath, BEntry *rootEntry)
BEntry entry; BEntry entry;
while(root.GetNextEntry(&entry) > B_ERROR) { while (root.GetNextEntry(&entry) > B_ERROR) {
if(entry.IsDirectory()) { if (entry.IsDirectory()) {
RecursiveScan(rootPath, &entry); RecursiveScan(rootPath, &entry);
} else { } else {
BPath path; BPath path;
@@ -253,10 +231,10 @@ MultiAudioAddOn::SaveSettings(void)
{ {
CALLED(); CALLED();
BPath path; BPath path;
if(find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE); path.Append(SETTINGS_FILE);
BFile file(path.Path(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE); BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
if(file.InitCheck()==B_OK) if (file.InitCheck() == B_OK)
fSettings.Flatten(&file); fSettings.Flatten(&file);
} }
} }
@@ -269,14 +247,14 @@ MultiAudioAddOn::LoadSettings(void)
fSettings.MakeEmpty(); fSettings.MakeEmpty();
BPath path; BPath path;
if(find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE); path.Append(SETTINGS_FILE);
BFile file(path.Path(),B_READ_ONLY); BFile file(path.Path(), B_READ_ONLY);
if((file.InitCheck()==B_OK)&&(fSettings.Unflatten(&file)==B_OK)) if ((file.InitCheck() == B_OK) && (fSettings.Unflatten(&file) == B_OK))
{ {
PRINT_OBJECT(fSettings); PRINT_OBJECT(fSettings);
} else { } else {
PRINT(("Error unflattening settings file %s\n",path.Path())); PRINT(("Error unflattening settings file %s\n", path.Path()));
} }
} }
} }
@@ -1,30 +1,8 @@
/* /*
* multiaudio replacement media addon for BeOS
*
* Copyright (c) 2002, Jerome Duval ([email protected]) * Copyright (c) 2002, Jerome Duval ([email protected])
* * Distributed under the terms of the MIT License.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ */
#ifndef _MULTIAUDIOADDON_H #ifndef _MULTIAUDIOADDON_H
#define _MULTIAUDIOADDON_H #define _MULTIAUDIOADDON_H
@@ -34,49 +12,49 @@
#define SETTINGS_FILE "Media/multi_audio_settings" #define SETTINGS_FILE "Media/multi_audio_settings"
class MultiAudioAddOn : class MultiAudioAddOn :
public BMediaAddOn public BMediaAddOn
{ {
public: public:
virtual ~MultiAudioAddOn(void); virtual ~MultiAudioAddOn(void);
explicit MultiAudioAddOn(image_id image); explicit MultiAudioAddOn(image_id image);
/**************************/ /**************************/
/* begin from BMediaAddOn */ /* begin from BMediaAddOn */
public: public:
virtual status_t InitCheck( virtual status_t InitCheck(
const char ** out_failure_text); const char ** out_failure_text);
virtual int32 CountFlavors(void); virtual int32 CountFlavors(void);
virtual status_t GetFlavorAt( virtual status_t GetFlavorAt(
int32 n, int32 n,
const flavor_info ** out_info); const flavor_info ** out_info);
virtual BMediaNode * InstantiateNodeFor( virtual BMediaNode * InstantiateNodeFor(
const flavor_info * info, const flavor_info * info,
BMessage * config, BMessage * config,
status_t * out_error); status_t * out_error);
virtual status_t GetConfigurationFor( virtual status_t GetConfigurationFor(
BMediaNode * your_node, BMediaNode * your_node,
BMessage * into_message); BMessage * into_message);
virtual bool WantsAutoStart(void); virtual bool WantsAutoStart(void);
virtual status_t AutoStart( virtual status_t AutoStart(
int in_count, int in_count,
BMediaNode ** out_node, BMediaNode ** out_node,
int32 * out_internal_id, int32 * out_internal_id,
bool * out_has_more); bool * out_has_more);
/* end from BMediaAddOn */ /* end from BMediaAddOn */
/************************/ /************************/
private: private:
status_t RecursiveScan(char* path, BEntry *rootEntry = NULL); status_t RecursiveScan(char* path, BEntry *rootEntry = NULL);
void SaveSettings(); void SaveSettings();
void LoadSettings(); void LoadSettings();
status_t fInitCheckStatus; status_t fInitCheckStatus;
BList fDevices; BList fDevices;
BMessage fSettings; // settings loaded from settings directory BMessage fSettings; // settings loaded from settings directory
}; };
extern "C" _EXPORT BMediaAddOn *make_media_addon( image_id you ); extern "C" _EXPORT BMediaAddOn *make_media_addon(image_id you);
#endif /* _MULTIAUDIOADDON_H */ #endif /* _MULTIAUDIOADDON_H */
@@ -1,30 +1,8 @@
/* /*
* multiaudio replacement media addon for BeOS * Copyright (c) 2002-2007, Jerome Duval ([email protected])
* * Distributed under the terms of the MIT License.
* Copyright (c) 2002, 2003, Jerome Duval ([email protected])
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ */
#include "MultiAudioDevice.h" #include "MultiAudioDevice.h"
#include "debug.h" #include "debug.h"
#include "driver_io.h" #include "driver_io.h"
@@ -33,17 +11,17 @@
#include <string.h> #include <string.h>
float SAMPLE_RATES[] = { float SAMPLE_RATES[] = {
8000.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, 44100.0, 8000.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, 44100.0,
48000.0, 64000.0, 88200.0, 96000.0, 176400.0, 192000.0, 384000.0, 1536000.0 48000.0, 64000.0, 88200.0, 96000.0, 176400.0, 192000.0, 384000.0, 1536000.0
}; };
float MultiAudioDevice::convert_multiaudio_rate_to_media_rate(uint32 rate) float MultiAudioDevice::convert_multiaudio_rate_to_media_rate(uint32 rate)
{ {
uint8 count = 0; uint8 count = 0;
uint8 size = sizeof(SAMPLE_RATES)/sizeof(SAMPLE_RATES[0]); uint8 size = sizeof(SAMPLE_RATES) / sizeof(SAMPLE_RATES[0]);
while(count < size) { while (count < size) {
if(rate & 1) if (rate & 1)
return SAMPLE_RATES[count]; return SAMPLE_RATES[count];
count++; count++;
rate >>= 1; rate >>= 1;
@@ -51,21 +29,23 @@ float MultiAudioDevice::convert_multiaudio_rate_to_media_rate(uint32 rate)
return 0.0; return 0.0;
} }
uint32 MultiAudioDevice::convert_media_rate_to_multiaudio_rate(float rate) uint32 MultiAudioDevice::convert_media_rate_to_multiaudio_rate(float rate)
{ {
uint8 count = 0; uint8 count = 0;
uint size = sizeof(SAMPLE_RATES)/sizeof(SAMPLE_RATES[0]); uint size = sizeof(SAMPLE_RATES) / sizeof(SAMPLE_RATES[0]);
while(count < size) { while (count < size) {
if(rate <= SAMPLE_RATES[count]) if (rate <= SAMPLE_RATES[count])
return (0x1 << count); return (0x1 << count);
count++; count++;
} }
return 0; return 0;
} }
uint32 MultiAudioDevice::convert_multiaudio_format_to_media_format(uint32 fmt) uint32 MultiAudioDevice::convert_multiaudio_format_to_media_format(uint32 fmt)
{ {
switch(fmt) { switch (fmt) {
case B_FMT_FLOAT: case B_FMT_FLOAT:
return media_raw_audio_format::B_AUDIO_FLOAT; return media_raw_audio_format::B_AUDIO_FLOAT;
case B_FMT_18BIT: case B_FMT_18BIT:
@@ -87,7 +67,7 @@ uint32 MultiAudioDevice::convert_multiaudio_format_to_media_format(uint32 fmt)
int16 MultiAudioDevice::convert_multiaudio_format_to_valid_bits(uint32 fmt) int16 MultiAudioDevice::convert_multiaudio_format_to_valid_bits(uint32 fmt)
{ {
switch(fmt) { switch (fmt) {
case B_FMT_18BIT: case B_FMT_18BIT:
return 18; return 18;
case B_FMT_20BIT: case B_FMT_20BIT:
@@ -105,7 +85,7 @@ int16 MultiAudioDevice::convert_multiaudio_format_to_valid_bits(uint32 fmt)
uint32 MultiAudioDevice::convert_media_format_to_multiaudio_format(uint32 fmt) uint32 MultiAudioDevice::convert_media_format_to_multiaudio_format(uint32 fmt)
{ {
switch(fmt) { switch (fmt) {
case media_raw_audio_format::B_AUDIO_FLOAT: case media_raw_audio_format::B_AUDIO_FLOAT:
return B_FMT_FLOAT; return B_FMT_FLOAT;
case media_raw_audio_format::B_AUDIO_INT: case media_raw_audio_format::B_AUDIO_INT:
@@ -121,36 +101,38 @@ uint32 MultiAudioDevice::convert_media_format_to_multiaudio_format(uint32 fmt)
} }
} }
uint32 MultiAudioDevice::select_multiaudio_rate(uint32 rate) uint32 MultiAudioDevice::select_multiaudio_rate(uint32 rate)
{ {
//highest rate //highest rate
uint32 crate = B_SR_1536000; uint32 crate = B_SR_1536000;
while(crate != 0) { while (crate != 0) {
if(rate & crate) if (rate & crate)
return crate; return crate;
crate >>= 1; crate >>= 1;
} }
return 0; return 0;
} }
uint32 MultiAudioDevice::select_multiaudio_format(uint32 fmt) uint32 MultiAudioDevice::select_multiaudio_format(uint32 fmt)
{ {
//highest format //highest format
if(fmt & B_FMT_FLOAT) { if (fmt & B_FMT_FLOAT) {
return B_FMT_FLOAT; return B_FMT_FLOAT;
} else if(fmt & B_FMT_32BIT) { } else if (fmt & B_FMT_32BIT) {
return B_FMT_32BIT; return B_FMT_32BIT;
} else if(fmt & B_FMT_24BIT) { } else if (fmt & B_FMT_24BIT) {
return B_FMT_24BIT; return B_FMT_24BIT;
} else if(fmt & B_FMT_20BIT) { } else if (fmt & B_FMT_20BIT) {
return B_FMT_20BIT; return B_FMT_20BIT;
} else if(fmt & B_FMT_18BIT) { } else if (fmt & B_FMT_18BIT) {
return B_FMT_18BIT; return B_FMT_18BIT;
} else if(fmt & B_FMT_16BIT) { } else if (fmt & B_FMT_16BIT) {
return B_FMT_16BIT; return B_FMT_16BIT;
} else if(fmt & B_FMT_8BIT_S) { } else if (fmt & B_FMT_8BIT_S) {
return B_FMT_8BIT_S; return B_FMT_8BIT_S;
} else if(fmt & B_FMT_8BIT_U) { } else if (fmt & B_FMT_8BIT_U) {
return B_FMT_8BIT_U; return B_FMT_8BIT_U;
} else } else
return 0; return 0;
@@ -161,8 +143,8 @@ uint32 MultiAudioDevice::select_multiaudio_format(uint32 fmt)
MultiAudioDevice::~MultiAudioDevice() MultiAudioDevice::~MultiAudioDevice()
{ {
CALLED(); CALLED();
if ( fd != 0 ) { if (fd != 0) {
close( fd ); close(fd);
} }
} }
@@ -176,7 +158,7 @@ MultiAudioDevice::MultiAudioDevice(const char* name, const char* path)
PRINT(("name : %s, path : %s\n", fDevice_name, fDevice_path)); PRINT(("name : %s, path : %s\n", fDevice_name, fDevice_path));
if(InitDriver()!=B_OK) if (InitDriver() != B_OK)
return; return;
fInitCheckStatus = B_OK; fInitCheckStatus = B_OK;
@@ -212,7 +194,7 @@ status_t MultiAudioDevice::InitDriver()
MD.info_size = sizeof(MD); MD.info_size = sizeof(MD);
MD.request_channel_count = MAX_CHANNELS; MD.request_channel_count = MAX_CHANNELS;
MD.channels = MCI; MD.channels = MCI;
rval = DRIVER_GET_DESCRIPTION(&MD,0); rval = DRIVER_GET_DESCRIPTION(&MD, 0);
if (B_OK != rval) if (B_OK != rval)
{ {
fprintf(stderr, "Failed on B_MULTI_GET_DESCRIPTION\n"); fprintf(stderr, "Failed on B_MULTI_GET_DESCRIPTION\n");
@@ -220,32 +202,32 @@ status_t MultiAudioDevice::InitDriver()
} }
PRINT(("Friendly name:\t%s\nVendor:\t\t%s\n", PRINT(("Friendly name:\t%s\nVendor:\t\t%s\n",
MD.friendly_name,MD.vendor_info)); MD.friendly_name, MD.vendor_info));
PRINT(("%ld outputs\t%ld inputs\n%ld out busses\t%ld in busses\n", PRINT(("%ld outputs\t%ld inputs\n%ld out busses\t%ld in busses\n",
MD.output_channel_count,MD.input_channel_count, MD.output_channel_count, MD.input_channel_count,
MD.output_bus_channel_count,MD.input_bus_channel_count)); MD.output_bus_channel_count, MD.input_bus_channel_count));
PRINT(("\nChannels\n" PRINT(("\nChannels\n"
"ID\tKind\tDesig\tConnectors\n")); "ID\tKind\tDesig\tConnectors\n"));
for (i = 0 ; i < (MD.output_channel_count + MD.input_channel_count); i++) for (i = 0 ; i < (MD.output_channel_count + MD.input_channel_count); i++)
{ {
PRINT(("%ld\t%d\t0x%lx\t0x%lx\n",MD.channels[i].channel_id, PRINT(("%ld\t%d\t0x%lx\t0x%lx\n", MD.channels[i].channel_id,
MD.channels[i].kind, MD.channels[i].kind,
MD.channels[i].designations, MD.channels[i].designations,
MD.channels[i].connectors)); MD.channels[i].connectors));
} }
PRINT(("\n")); PRINT(("\n"));
PRINT(("Output rates\t\t0x%lx\n",MD.output_rates)); PRINT(("Output rates\t\t0x%lx\n", MD.output_rates));
PRINT(("Input rates\t\t0x%lx\n",MD.input_rates)); PRINT(("Input rates\t\t0x%lx\n", MD.input_rates));
PRINT(("Max CVSR\t\t%.0f\n",MD.max_cvsr_rate)); PRINT(("Max CVSR\t\t%.0f\n", MD.max_cvsr_rate));
PRINT(("Min CVSR\t\t%.0f\n",MD.min_cvsr_rate)); PRINT(("Min CVSR\t\t%.0f\n", MD.min_cvsr_rate));
PRINT(("Output formats\t\t0x%lx\n",MD.output_formats)); PRINT(("Output formats\t\t0x%lx\n", MD.output_formats));
PRINT(("Input formats\t\t0x%lx\n",MD.input_formats)); PRINT(("Input formats\t\t0x%lx\n", MD.input_formats));
PRINT(("Lock sources\t\t0x%lx\n",MD.lock_sources)); PRINT(("Lock sources\t\t0x%lx\n", MD.lock_sources));
PRINT(("Timecode sources\t0x%lx\n",MD.timecode_sources)); PRINT(("Timecode sources\t0x%lx\n", MD.timecode_sources));
PRINT(("Interface flags\t\t0x%lx\n",MD.interface_flags)); PRINT(("Interface flags\t\t0x%lx\n", MD.interface_flags));
PRINT(("Control panel string:\t\t%s\n",MD.control_panel)); PRINT(("Control panel string:\t\t%s\n", MD.control_panel));
PRINT(("\n")); PRINT(("\n"));
num_outputs = MD.output_channel_count; num_outputs = MD.output_channel_count;
@@ -254,11 +236,11 @@ status_t MultiAudioDevice::InitDriver()
// Get and set enabled channels // Get and set enabled channels
MCE.info_size = sizeof(MCE); MCE.info_size = sizeof(MCE);
MCE.enable_bits = (uchar *) &mce_enable_bits; MCE.enable_bits = (uchar *) & mce_enable_bits;
rval = DRIVER_GET_ENABLED_CHANNELS(&MCE, sizeof(MCE)); rval = DRIVER_GET_ENABLED_CHANNELS(&MCE, sizeof(MCE));
if (B_OK != rval) if (B_OK != rval)
{ {
fprintf(stderr, "Failed on B_MULTI_GET_ENABLED_CHANNELS len is 0x%lx\n",sizeof(MCE)); fprintf(stderr, "Failed on B_MULTI_GET_ENABLED_CHANNELS len is 0x%lx\n", sizeof(MCE));
return B_ERROR; return B_ERROR;
} }
@@ -314,19 +296,19 @@ status_t MultiAudioDevice::InitDriver()
} }
for (i = 0; i < MBL.return_playback_buffers; i++) for (i = 0; i < MBL.return_playback_buffers; i++)
for (int j=0; j < MBL.return_playback_channels; j++) { for (int j = 0; j < MBL.return_playback_channels; j++) {
PRINT(("MBL.playback_buffers[%d][%d].base: %p\n", PRINT(("MBL.playback_buffers[%d][%d].base: %p\n",
i,j,MBL.playback_buffers[i][j].base)); i, j, MBL.playback_buffers[i][j].base));
PRINT(("MBL.playback_buffers[%d][%d].stride: %i\n", PRINT(("MBL.playback_buffers[%d][%d].stride: %i\n",
i,j,MBL.playback_buffers[i][j].stride)); i, j, MBL.playback_buffers[i][j].stride));
} }
for (i = 0; i < MBL.return_record_buffers; i++) for (i = 0; i < MBL.return_record_buffers; i++)
for (int j=0; j < MBL.return_record_channels; j++) { for (int j = 0; j < MBL.return_record_channels; j++) {
PRINT(("MBL.record_buffers[%d][%d].base: %p\n", PRINT(("MBL.record_buffers[%d][%d].base: %p\n",
i,j,MBL.record_buffers[i][j].base)); i, j, MBL.record_buffers[i][j].base));
PRINT(("MBL.record_buffers[%d][%d].stride: %i\n", PRINT(("MBL.record_buffers[%d][%d].stride: %i\n",
i,j,MBL.record_buffers[i][j].stride)); i, j, MBL.record_buffers[i][j].stride));
} }
MMCI.info_size = sizeof(MMCI); MMCI.info_size = sizeof(MMCI);
@@ -1,30 +1,8 @@
/* /*
* multiaudio replacement media addon for BeOS * Copyright (c) 2002-2007, Jerome Duval ([email protected])
* * Distributed under the terms of the MIT License.
* Copyright (c) 2002, 2003, Jerome Duval ([email protected])
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ */
#ifndef _MULTIAUDIODEVICE_H #ifndef _MULTIAUDIODEVICE_H
#define _MULTIAUDIODEVICE_H #define _MULTIAUDIODEVICE_H
@@ -36,47 +14,47 @@
class MultiAudioDevice class MultiAudioDevice
{ {
public: public:
explicit MultiAudioDevice(const char *name, const char* path); explicit MultiAudioDevice(const char *name, const char* path);
virtual ~MultiAudioDevice(void); virtual ~MultiAudioDevice(void);
virtual status_t InitCheck(void) const; virtual status_t InitCheck(void) const;
static float convert_multiaudio_rate_to_media_rate(uint32 rate); static float convert_multiaudio_rate_to_media_rate(uint32 rate);
static uint32 convert_media_rate_to_multiaudio_rate(float rate); static uint32 convert_media_rate_to_multiaudio_rate(float rate);
static uint32 convert_multiaudio_format_to_media_format(uint32 fmt); static uint32 convert_multiaudio_format_to_media_format(uint32 fmt);
static int16 convert_multiaudio_format_to_valid_bits(uint32 fmt); static int16 convert_multiaudio_format_to_valid_bits(uint32 fmt);
static uint32 convert_media_format_to_multiaudio_format(uint32 fmt); static uint32 convert_media_format_to_multiaudio_format(uint32 fmt);
static uint32 select_multiaudio_rate(uint32 rate); static uint32 select_multiaudio_rate(uint32 rate);
static uint32 select_multiaudio_format(uint32 fmt); static uint32 select_multiaudio_format(uint32 fmt);
int DoBufferExchange(multi_buffer_info *MBI); int DoBufferExchange(multi_buffer_info *MBI);
int DoSetMix(multi_mix_value_info *MMVI); int DoSetMix(multi_mix_value_info *MMVI);
int DoGetMix(multi_mix_value_info *MMVI); int DoGetMix(multi_mix_value_info *MMVI);
private: private:
status_t InitDriver(); status_t InitDriver();
int fd; //file descriptor for hw driver int fd; //file descriptor for hw driver
char fDevice_name[32]; char fDevice_name[32];
char fDevice_path[32]; char fDevice_path[32];
public: public:
multi_description MD; multi_description MD;
multi_channel_info MCI[MAX_CHANNELS]; multi_channel_info MCI[MAX_CHANNELS];
multi_format_info MFI; multi_format_info MFI;
multi_buffer_list MBL; multi_buffer_list MBL;
multi_mix_control_info MMCI; multi_mix_control_info MMCI;
multi_mix_control MMC[MAX_CONTROLS]; multi_mix_control MMC[MAX_CONTROLS];
buffer_desc play_buffer_list[NB_BUFFERS * MAX_CHANNELS]; buffer_desc play_buffer_list[NB_BUFFERS * MAX_CHANNELS];
buffer_desc record_buffer_list[NB_BUFFERS * MAX_CHANNELS]; buffer_desc record_buffer_list[NB_BUFFERS * MAX_CHANNELS];
buffer_desc *play_buffer_desc[NB_BUFFERS]; buffer_desc *play_buffer_desc[NB_BUFFERS];
buffer_desc *record_buffer_desc[NB_BUFFERS]; buffer_desc *record_buffer_desc[NB_BUFFERS];
private: private:
status_t fInitCheckStatus; status_t fInitCheckStatus;
}; };
#endif #endif