Some coding style updates by Vasilis Kaoutsis - one step after the other :-)
Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20788 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,67 +13,51 @@
|
|||||||
__USE_CORTEX_NAMESPACE
|
__USE_CORTEX_NAMESPACE
|
||||||
using namespace addon_host;
|
using namespace addon_host;
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
// *** implementation
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
App::App()
|
||||||
App app;
|
: BApplication(g_appSignature)
|
||||||
if(argc < 2 || strcmp(argv[1], "--addon-host") != 0)
|
{
|
||||||
{
|
|
||||||
int32 response = (new BAlert(
|
|
||||||
"Cortex AddOnHost",
|
|
||||||
"This program runs in the background, and is started automatically "
|
|
||||||
"by Cortex when necessary. You probably don't want to start it manually.",
|
|
||||||
"Continue", "Quit"))->Go();
|
|
||||||
if(response == 1)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
app.Run();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
App::~App() {}
|
|
||||||
App::App() :
|
|
||||||
BApplication(g_appSignature) {}
|
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
App::~App()
|
||||||
// *** BLooper
|
{
|
||||||
// -------------------------------------------------------- //
|
}
|
||||||
|
|
||||||
bool App::QuitRequested() {
|
|
||||||
|
bool
|
||||||
|
App::QuitRequested()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
// *** BHandler
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
void App::MessageReceived(
|
|
||||||
BMessage* message) {
|
|
||||||
|
|
||||||
|
void
|
||||||
|
App::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
// message->PrintToStream();
|
// message->PrintToStream();
|
||||||
|
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case M_INSTANTIATE: {
|
case M_INSTANTIATE:
|
||||||
|
{
|
||||||
// fetch node info
|
// fetch node info
|
||||||
dormant_node_info info;
|
dormant_node_info info;
|
||||||
const void *data;
|
const void *data;
|
||||||
ssize_t dataSize;
|
ssize_t dataSize;
|
||||||
err = message->FindData("info", B_RAW_TYPE, &data, &dataSize);
|
err = message->FindData("info", B_RAW_TYPE, &data, &dataSize);
|
||||||
if(err < B_OK) {
|
if (err < B_OK) {
|
||||||
PRINT((
|
PRINT((
|
||||||
"!!! App::MessageReceived(M_INSTANTIATE):\n"
|
"!!! App::MessageReceived(M_INSTANTIATE):\n"
|
||||||
" missing 'info'\n"));
|
" missing 'info'\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(dataSize != sizeof(info)) {
|
if (dataSize != sizeof(info)) {
|
||||||
PRINT((
|
PRINT((
|
||||||
"* App::MessageReceived(M_INSTANTIATE):\n"
|
"* App::MessageReceived(M_INSTANTIATE):\n"
|
||||||
" warning: 'info' size mismatch\n"));
|
" warning: 'info' size mismatch\n"));
|
||||||
if(dataSize > ssize_t(sizeof(info)))
|
if (dataSize > ssize_t(sizeof(info)))
|
||||||
dataSize = sizeof(info);
|
dataSize = sizeof(info);
|
||||||
}
|
}
|
||||||
memcpy(reinterpret_cast<void *>(&info), data, dataSize);
|
memcpy(reinterpret_cast<void *>(&info), data, dataSize);
|
||||||
@@ -81,16 +65,14 @@ void App::MessageReceived(
|
|||||||
// attempt to instantiate
|
// attempt to instantiate
|
||||||
BMediaRoster* r = BMediaRoster::Roster();
|
BMediaRoster* r = BMediaRoster::Roster();
|
||||||
media_node node;
|
media_node node;
|
||||||
err = r->InstantiateDormantNode(
|
err = r->InstantiateDormantNode(info, &node);
|
||||||
info,
|
|
||||||
&node);
|
|
||||||
|
|
||||||
// if(err == B_OK)
|
// if(err == B_OK)
|
||||||
// // reference it
|
// // reference it
|
||||||
// err = r->GetNodeFor(node.node, &node);
|
// err = r->GetNodeFor(node.node, &node);
|
||||||
|
|
||||||
// send status
|
// send status
|
||||||
if(err == B_OK) {
|
if (err == B_OK) {
|
||||||
BMessage m(M_INSTANTIATE_COMPLETE);
|
BMessage m(M_INSTANTIATE_COMPLETE);
|
||||||
m.AddInt32("node_id", node.node);
|
m.AddInt32("node_id", node.node);
|
||||||
message->SendReply(&m);
|
message->SendReply(&m);
|
||||||
@@ -100,22 +82,24 @@ void App::MessageReceived(
|
|||||||
m.AddInt32("error", err);
|
m.AddInt32("error", err);
|
||||||
message->SendReply(&m);
|
message->SendReply(&m);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_RELEASE: {
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case M_RELEASE:
|
||||||
|
{
|
||||||
// fetch node info
|
// fetch node info
|
||||||
live_node_info info;
|
live_node_info info;
|
||||||
const void *data;
|
const void *data;
|
||||||
ssize_t dataSize;
|
ssize_t dataSize;
|
||||||
err = message->FindData("info", B_RAW_TYPE, &data, &dataSize);
|
err = message->FindData("info", B_RAW_TYPE, &data, &dataSize);
|
||||||
if(err < B_OK) {
|
if (err < B_OK) {
|
||||||
PRINT((
|
PRINT((
|
||||||
"!!! App::MessageReceived(M_RELEASE):\n"
|
"!!! App::MessageReceived(M_RELEASE):\n"
|
||||||
" missing 'info'\n"));
|
" missing 'info'\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(dataSize != sizeof(info)) {
|
if (dataSize != sizeof(info)) {
|
||||||
PRINT((
|
PRINT((
|
||||||
"* App::MessageReceived(M_RELEASE):\n"
|
"* App::MessageReceived(M_RELEASE):\n"
|
||||||
" warning: 'info' size mismatch\n"));
|
" warning: 'info' size mismatch\n"));
|
||||||
@@ -130,7 +114,7 @@ void App::MessageReceived(
|
|||||||
err = r->ReleaseNode(info.node);
|
err = r->ReleaseNode(info.node);
|
||||||
|
|
||||||
// send status
|
// send status
|
||||||
if(err == B_OK) {
|
if (err == B_OK) {
|
||||||
BMessage m(M_RELEASE_COMPLETE);
|
BMessage m(M_RELEASE_COMPLETE);
|
||||||
m.AddInt32("node_id", info.node.node);
|
m.AddInt32("node_id", info.node.node);
|
||||||
message->SendReply(&m);
|
message->SendReply(&m);
|
||||||
@@ -140,13 +124,29 @@ void App::MessageReceived(
|
|||||||
m.AddInt32("error", err);
|
m.AddInt32("error", err);
|
||||||
message->SendReply(&m);
|
message->SendReply(&m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
_inherited::MessageReceived(message);
|
_inherited::MessageReceived(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// END -- AddOnHostApp.cpp --
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
App app;
|
||||||
|
if (argc < 2 || strcmp(argv[1], "--addon-host") != 0) {
|
||||||
|
int32 response = (new BAlert(
|
||||||
|
"Cortex AddOnHost",
|
||||||
|
"This program runs in the background, and is started automatically "
|
||||||
|
"by Cortex when necessary. You probably don't want to start it manually.",
|
||||||
|
"Continue", "Quit"))->Go();
|
||||||
|
if(response == 1)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
app.Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,38 +8,34 @@
|
|||||||
//
|
//
|
||||||
// * HISTORY
|
// * HISTORY
|
||||||
// e.moon 6nov99
|
// e.moon 6nov99
|
||||||
|
#ifndef NODE_MANAGER_ADD_ON_HOST_APP_H
|
||||||
|
#define NODE_MANAGER_ADD_ON_HOST_APP_H
|
||||||
|
|
||||||
#ifndef __NodeManager_AddOnHostApp_H__
|
|
||||||
#define __NodeManager_AddOnHostApp_H__
|
#include "cortex_defs.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <MediaAddOn.h>
|
#include <MediaAddOn.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
|
||||||
#include "cortex_defs.h"
|
|
||||||
__BEGIN_CORTEX_NAMESPACE
|
__BEGIN_CORTEX_NAMESPACE
|
||||||
namespace addon_host {
|
namespace addon_host {
|
||||||
|
|
||||||
class App :
|
class App:public BApplication {
|
||||||
public BApplication {
|
|
||||||
typedef BApplication _inherited;
|
typedef BApplication _inherited;
|
||||||
|
|
||||||
public: // *** implementation
|
public:
|
||||||
~App();
|
~App();
|
||||||
App();
|
App();
|
||||||
|
|
||||||
public: // *** BLooper
|
public:
|
||||||
bool QuitRequested();
|
bool QuitRequested();
|
||||||
|
void MessageReceived(BMessage* message);
|
||||||
public: // *** BHandler
|
|
||||||
void MessageReceived(
|
|
||||||
BMessage* message);
|
|
||||||
|
|
||||||
private: // implementation
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // addon_host
|
} // addon_host
|
||||||
__END_CORTEX_NAMESPACE
|
__END_CORTEX_NAMESPACE
|
||||||
#endif /*__NodeManager_AddOnHostApp_H__*/
|
|
||||||
|
|
||||||
|
#endif // NODE_MANAGER_ADD_ON_HOST_APP_H
|
||||||
|
|||||||
@@ -8,43 +8,32 @@
|
|||||||
//
|
//
|
||||||
// * HISTORY
|
// * HISTORY
|
||||||
// e.moon 8sep99 Begun
|
// e.moon 8sep99 Begun
|
||||||
|
#ifndef AUDIO_ADAPTER_ADD_ON_H
|
||||||
|
#define AUDIO_ADAPTER_ADD_ON_H
|
||||||
|
|
||||||
#ifndef __AudioAdapterAddOn_H__
|
|
||||||
#define __AudioAdapterAddOn_H__
|
|
||||||
|
|
||||||
#include <MediaAddOn.h>
|
#include <MediaAddOn.h>
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
class AudioAdapterAddOn :
|
class AudioAdapterAddOn : public BMediaAddOn {
|
||||||
public BMediaAddOn {
|
typedef BMediaAddOn _inherited;
|
||||||
typedef BMediaAddOn _inherited;
|
|
||||||
|
|
||||||
public: // ctor/dtor
|
|
||||||
// virtual ~AudioAdapterAddOn();
|
|
||||||
explicit AudioAdapterAddOn(image_id image);
|
|
||||||
|
|
||||||
public: // BMediaAddOn impl
|
public:
|
||||||
virtual status_t InitCheck(
|
//virtual ~AudioAdapterAddOn();
|
||||||
const char** out_failure_text);
|
explicit AudioAdapterAddOn(image_id image);
|
||||||
virtual int32 CountFlavors();
|
|
||||||
virtual status_t GetFlavorAt(
|
|
||||||
int32 n,
|
|
||||||
const flavor_info ** out_info);
|
|
||||||
virtual BMediaNode * InstantiateNodeFor(
|
|
||||||
const flavor_info * info,
|
|
||||||
BMessage * config,
|
|
||||||
status_t * out_error);
|
|
||||||
virtual status_t GetConfigurationFor(
|
|
||||||
BMediaNode * your_node,
|
|
||||||
BMessage * into_message);
|
|
||||||
|
|
||||||
virtual bool WantsAutoStart() { return false; }
|
public: // BMediaAddOn impl
|
||||||
virtual status_t AutoStart(
|
virtual status_t InitCheck(const char** out_failure_text);
|
||||||
int in_count,
|
virtual int32 CountFlavors();
|
||||||
BMediaNode ** out_node,
|
virtual status_t GetFlavorAt(int32 n, const flavor_info** out_info);
|
||||||
int32 * out_internal_id,
|
virtual BMediaNode* InstantiateNodeFor(const flavor_info* info,
|
||||||
bool * out_has_more) { return B_OK; }
|
BMessage* config, status_t* out_error);
|
||||||
|
virtual status_t GetConfigurationFor(BMediaNode* your_node,
|
||||||
|
BMessage* into_message);
|
||||||
|
|
||||||
|
virtual bool WantsAutoStart() { return false; }
|
||||||
|
virtual status_t AutoStart(int in_count, BMediaNode** out_node,
|
||||||
|
int32* out_internal_id, bool* out_has_more) { return B_OK; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__AudioAdapterAddOn_H__*/
|
#endif // AUDIO_ADAPTER_ADD_ON_H
|
||||||
|
|||||||
@@ -1,75 +1,58 @@
|
|||||||
// AudioAdapterNode.h
|
// AudioAdapterNode.h
|
||||||
|
#ifndef AUDIO_ADAPTER_NODE_H
|
||||||
|
#define AUDIO_ADAPTER_NODE_H
|
||||||
|
|
||||||
#ifndef __AudioAdapterNode_H__
|
|
||||||
#define __AudioAdapterNode_H__
|
|
||||||
|
|
||||||
#include "AudioFilterNode.h"
|
#include "AudioFilterNode.h"
|
||||||
#include "AudioAdapterParams.h"
|
#include "AudioAdapterParams.h"
|
||||||
|
|
||||||
class _AudioAdapterNode :
|
|
||||||
public AudioFilterNode
|
class _AudioAdapterNode : public AudioFilterNode {
|
||||||
{
|
|
||||||
typedef AudioFilterNode _inherited;
|
typedef AudioFilterNode _inherited;
|
||||||
|
|
||||||
public: // ctor/dtor
|
public: // ctor/dtor
|
||||||
virtual ~_AudioAdapterNode();
|
virtual ~_AudioAdapterNode();
|
||||||
_AudioAdapterNode(
|
_AudioAdapterNode(const char* name, IAudioOpFactory* opFactory,
|
||||||
const char* name,
|
BMediaAddOn* addOn = 0);
|
||||||
IAudioOpFactory* opFactory,
|
|
||||||
BMediaAddOn* addOn=0);
|
|
||||||
|
|
||||||
public: // AudioFilterNode
|
public: // AudioFilterNode
|
||||||
status_t getRequiredInputFormat(
|
status_t getRequiredInputFormat(media_format& ioFormat);
|
||||||
media_format& ioFormat);
|
status_t getPreferredInputFormat(media_format& ioFormat);
|
||||||
status_t getPreferredInputFormat(
|
status_t getRequiredOutputFormat(media_format& ioFormat);
|
||||||
media_format& ioFormat);
|
|
||||||
|
|
||||||
status_t getRequiredOutputFormat(
|
|
||||||
media_format& ioFormat);
|
|
||||||
|
|
||||||
status_t getPreferredOutputFormat(
|
|
||||||
media_format& ioFormat);
|
|
||||||
|
|
||||||
status_t validateProposedInputFormat(
|
|
||||||
const media_format& preferredFormat,
|
|
||||||
media_format& ioProposedFormat);
|
|
||||||
|
|
||||||
status_t validateProposedOutputFormat(
|
status_t getPreferredOutputFormat(media_format& ioFormat);
|
||||||
const media_format& preferredFormat,
|
|
||||||
media_format& ioProposedFormat);
|
|
||||||
|
|
||||||
virtual void SetParameterValue(
|
status_t validateProposedInputFormat(
|
||||||
int32 id,
|
const media_format& preferredFormat,
|
||||||
bigtime_t changeTime,
|
media_format& ioProposedFormat);
|
||||||
const void* value,
|
|
||||||
size_t size); //nyi
|
|
||||||
|
|
||||||
public: // BBufferProducer/Consumer
|
status_t validateProposedOutputFormat(
|
||||||
|
const media_format& preferredFormat,
|
||||||
|
media_format& ioProposedFormat);
|
||||||
|
|
||||||
virtual status_t Connected(
|
virtual void SetParameterValue(int32 id, bigtime_t changeTime,
|
||||||
const media_source& source,
|
const void* value, size_t size); //nyi
|
||||||
const media_destination& destination,
|
|
||||||
const media_format& format,
|
|
||||||
media_input* outInput);
|
|
||||||
|
|
||||||
virtual void Connect(
|
public: // BBufferProducer/Consumer
|
||||||
status_t status,
|
virtual status_t Connected(const media_source& source,
|
||||||
const media_source& source,
|
const media_destination& destination,
|
||||||
const media_destination& destination,
|
const media_format& format,
|
||||||
const media_format& format,
|
media_input* outInput);
|
||||||
char* ioName);
|
|
||||||
|
virtual void Connect(status_t status, const media_source& source,
|
||||||
private:
|
const media_destination& destination,
|
||||||
void _attemptInputFormatChange(
|
const media_format& format,
|
||||||
|
char* ioName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _attemptInputFormatChange(
|
||||||
const media_multi_audio_format& format); //nyi
|
const media_multi_audio_format& format); //nyi
|
||||||
|
|
||||||
void _attemptOutputFormatChange(
|
void _attemptOutputFormatChange(
|
||||||
const media_multi_audio_format& format); //nyi
|
const media_multi_audio_format& format); //nyi
|
||||||
|
|
||||||
void _broadcastInputFormatParams();
|
void _broadcastInputFormatParams();
|
||||||
void _broadcastOutputFormatParams();
|
void _broadcastOutputFormatParams();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // AUDIO_ADAPTER_NODE_H
|
||||||
|
|
||||||
#endif /*__AudioAdapterNode_H__*/
|
|
||||||
|
|||||||
@@ -5,17 +5,15 @@
|
|||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <ParameterWeb.h>
|
#include <ParameterWeb.h>
|
||||||
|
|
||||||
status_t _AudioAdapterParams::store(
|
status_t
|
||||||
int32 parameterID,
|
_AudioAdapterParams::store(parameterID, const void* data, size_t size)
|
||||||
const void* data,
|
{
|
||||||
size_t size) {
|
if (size < sizeof(int32))
|
||||||
|
|
||||||
if(size < sizeof(int32))
|
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
const uint32 d = *(uint32*)data;
|
const uint32 d = *(uint32*)data;
|
||||||
|
|
||||||
switch(parameterID) {
|
switch (parameterID) {
|
||||||
// input format restrictions (0='wildcard')
|
// input format restrictions (0='wildcard')
|
||||||
case P_INPUT_FORMAT:
|
case P_INPUT_FORMAT:
|
||||||
inputFormat.format = d;
|
inputFormat.format = d;
|
||||||
|
|||||||
@@ -1,47 +1,39 @@
|
|||||||
// AudioAdapterParams.h
|
// AudioAdapterParams.h
|
||||||
|
#ifndef AUDIO_ADAPTER_PARAMS_H
|
||||||
|
#define AUDIO_ADAPTER_PARAMS_H
|
||||||
|
|
||||||
#ifndef __AudioAdapterParams_H__
|
|
||||||
#define __AudioAdapterParams_H__
|
|
||||||
|
|
||||||
#include <MediaDefs.h>
|
|
||||||
|
|
||||||
#include "IParameterSet.h"
|
#include "IParameterSet.h"
|
||||||
|
|
||||||
class _AudioAdapterParams :
|
#include <MediaDefs.h>
|
||||||
public IParameterSet {
|
|
||||||
public:
|
|
||||||
enum parameter_id {
|
|
||||||
// input format restrictions (0='wildcard')
|
|
||||||
P_INPUT_FORMAT =101,
|
|
||||||
P_INPUT_CHANNEL_COUNT,
|
|
||||||
|
|
||||||
// output format restrictions (0='wildcard')
|
|
||||||
P_OUTPUT_FORMAT =201,
|
|
||||||
P_OUTPUT_CHANNEL_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
_AudioAdapterParams() :
|
|
||||||
inputFormat(media_raw_audio_format::wildcard),
|
|
||||||
outputFormat(media_raw_audio_format::wildcard) {}
|
|
||||||
|
|
||||||
status_t store(
|
|
||||||
int32 parameterID,
|
|
||||||
const void* data,
|
|
||||||
size_t size);
|
|
||||||
|
|
||||||
status_t retrieve(
|
|
||||||
int32 parameterID,
|
|
||||||
void* data,
|
|
||||||
size_t* ioSize);
|
|
||||||
|
|
||||||
void populateGroup(
|
class _AudioAdapterParams : public IParameterSet {
|
||||||
BParameterGroup* group);
|
public:
|
||||||
|
enum parameter_id {
|
||||||
public: // accessible parameters
|
// input format restrictions (0 = 'wildcard')
|
||||||
|
P_INPUT_FORMAT = 101,
|
||||||
|
P_INPUT_CHANNEL_COUNT,
|
||||||
|
|
||||||
media_multi_audio_format inputFormat;
|
// output format restrictions (0 = 'wildcard')
|
||||||
media_multi_audio_format outputFormat;
|
P_OUTPUT_FORMAT = 201,
|
||||||
|
P_OUTPUT_CHANNEL_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
_AudioAdapterParams()
|
||||||
|
:
|
||||||
|
inputFormat(media_raw_audio_format::wildcard),
|
||||||
|
outputFormat(media_raw_audio_format::wildcard)
|
||||||
|
{}
|
||||||
|
|
||||||
|
status_t store(int32 parameterID, const void* data, size_t size);
|
||||||
|
status_t retrieve(int32 parameterID, void* data, size_t* ioSize);
|
||||||
|
void populateGroup(BParameterGroup* group);
|
||||||
|
|
||||||
|
public: // accessible parameters
|
||||||
|
media_multi_audio_format inputFormat;
|
||||||
|
media_multi_audio_format outputFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__AudioAdapterParams_H__*/
|
#endif // AUDIO_ADAPTER_PARAMS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user