Add my ESound Daemon Sink media node source code.

I need it on an other box anyway...
Currently uses hardcoded server IP.
Jamfile likely doesn't work (needs net libs);
 and requires ZETA due to TextParameter (for server IP but unused yet; I think Haiku should have it too) will need some ifdefs
Use the provided makefile for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17886 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2006-06-20 22:17:12 +00:00
parent c345b8eb08
commit bdc29e6a6e
12 changed files with 3224 additions and 0 deletions
@@ -0,0 +1,316 @@
/*
* ESounD media addon for BeOS
*
* Copyright (c) 2006 François Revol ([email protected])
*
* Based on Multi Audio addon for Haiku,
* 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.
*
*/
#define _ZETA_TS_FIND_DIR_ 1
#include <FindDirectory.h>
#include <File.h>
#include <Path.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <errno.h>
#include <stdlib.h>
#include "compat.h"
//#undef DEBUG
//#define DEBUG 4
#include "debug.h"
#include <Debug.h>
#include "ESDEndpoint.h"
ESDEndpoint::ESDEndpoint()
: BDataIO()
, fHost(NULL)
, fPort(ESD_PORT)
, fSocket(-1)
, fDefaultCommand(ESD_CMD_STREAM_PLAY)
, fDefaultCommandSent(false)
, fDefaultFormat(ESD_BITS8 | ESD_MONO)
, fDefaultRate(ESD_DEFAULT_RATE)
, fLatency(0LL)
{
CALLED();
}
ESDEndpoint::~ESDEndpoint()
{
CALLED();
if (fSocket > -1)
closesocket(fSocket);
fSocket = -1;
}
status_t ESDEndpoint::SendAuthKey()
{
CALLED();
BPath kfPath;
status_t err;
off_t size;
char key[ESD_MAX_KEY];
err = find_directory(B_USER_SETTINGS_DIRECTORY, &kfPath);
kfPath.Append("esd_auth");
BFile keyFile(kfPath.Path(), B_READ_WRITE|B_CREATE_FILE);
err = keyFile.GetSize(&size);
if (err < 0)
return err;
if (size < ESD_MAX_KEY) {
keyFile.Seek(0LL, SEEK_SET);
srand(time(NULL));
for (int i = 0; i < ESD_MAX_KEY; i++)
key[i] = (char)(rand() % 256);
err = keyFile.Write(key, ESD_MAX_KEY);
if (err < 0)
return err;
if (err < ESD_MAX_KEY)
return EIO;
}
err = keyFile.Read(key, ESD_MAX_KEY);
if (err < 0)
return err;
if (err < ESD_MAX_KEY)
return EIO;
memcpy(fAuthKey, key, sizeof(esd_key_t));
return write(fSocket, fAuthKey, ESD_MAX_KEY);
}
status_t ESDEndpoint::Connect(const char *host, uint16 port)
{
status_t err;
CALLED();
fHost = host;
fPort = port;
struct hostent *he;
struct sockaddr_in sin;
he = gethostbyname(host);
PRINT(("gethostbyname(%s) = %p\n", host, he));
if (!he)
return ENOENT;
memcpy((struct in_addr *)&sin.sin_addr, he->h_addr, sizeof(struct in_addr));
fSocket = socket(AF_INET, SOCK_STREAM, 0);
if (fSocket < 0)
return errno;
sin.sin_family = AF_INET;
sin.sin_port = htons( port );
err = connect(fSocket, (struct sockaddr *) &sin, sizeof(sin));
PRINT(("connect: %s\n", strerror(err)));
if (err < 0)
return errno;
/* uint32 cmd = ESD_CMD_CONNECT;
err = write(fSocket, &cmd, sizeof(cmd));
if (err < 0)
return errno;
if (err < sizeof(cmd))
return EIO;
*/
err = SendAuthKey();
if (err < 0)
return errno;
bigtime_t ping = system_time();
uint32 endian = ESD_ENDIAN_TAG;
err = write(fSocket, &endian, sizeof(endian));
if (err < 0)
return errno;
if (err < sizeof(endian))
return EIO;
uint32 ok;
read(fSocket, &ok, sizeof(uint32));
ping = system_time() - ping;
fLatency = ping;
int flag = 1;
setsockopt(fSocket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
// read(fSocket, &ok, sizeof(uint32));
// connect
// auth
// ask server latency
// calc network latency (time (send+recv) / 2) ?
// get default format
return B_OK;
}
status_t ESDEndpoint::Disconnect()
{
CALLED();
if (fSocket > -1)
closesocket(fSocket);
fSocket = -1;
return B_OK;
}
status_t ESDEndpoint::SetCommand(esd_command_t cmd)
{
CALLED();
if (fDefaultCommandSent)
return EALREADY;
fDefaultCommand = cmd;
return B_OK;
}
status_t ESDEndpoint::SetFormat(int bits, int channels, float rate)
{
esd_format_t fmt = 0;
CALLED();
if (fDefaultCommandSent)
return EALREADY;
PRINT(("SetFormat(%d,%d,%d)\n", bits, channels, rate));
switch (bits) {
case 8:
fmt |= ESD_BITS8;
break;
case 16:
fmt |= ESD_BITS16;
break;
default:
return EINVAL;
}
switch (channels) {
case 1:
fmt |= ESD_MONO;
break;
case 2:
fmt |= ESD_STEREO;
break;
default:
return EINVAL;
}
fmt |= ESD_STREAM | ESD_FUNC_PLAY;
PRINT(("SetFormat: %08lx\n", fmt));
fDefaultFormat = fmt;
fDefaultRate = rate;
return B_OK;
}
status_t ESDEndpoint::GetServerInfo()
{
CALLED();
struct serverinfo {
uint32 ver;
uint32 rate;
uint32 fmt;
} si;
status_t err;
err = SendCommand(ESD_CMD_SERVER_INFO, (const uint8 *)&si, 0, (uint8 *)&si, sizeof(si));
if (err < 0)
return err;
PRINT(("err %d, version: %lu, rate: %lu, fmt: %lu\n", err, si.ver, si.rate, si.fmt));
return B_OK;
}
bool ESDEndpoint::CanSend()
{
CALLED();
return fDefaultCommandSent;
}
ssize_t ESDEndpoint::Read(void *buffer, size_t size)
{
CALLED();
return EINVAL;
}
ssize_t ESDEndpoint::Write(const void *buffer, size_t size)
{
status_t err = B_OK;
CALLED();
if (!fDefaultCommandSent)
err = SendDefaultCommand();
if (err < B_OK)
return err;
//PRINT(("write(fSocket, buffer, %d)\n", size));
//fprintf(stderr, "ESDEndpoint::Write(, %d) %s\n", size, (size%2)?"ODD BUFFER SIZE":"");
if (fDefaultFormat & ESD_BITS16) {
size /= 2;
size *= 2;
}
err = write(fSocket, buffer, size);
if (err != size) {
fprintf(stderr, "ESDEndpoint::Write: sent only %d of %d!\n", err, size);
}
//PRINT(("write(fSocket, buffer, %d): %s\n", size, strerror(err)));
if (err < B_OK)
return errno;
return err;
}
status_t ESDEndpoint::SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen)
{
status_t err;
CALLED();
err = send(fSocket, &cmd, sizeof(cmd), 0);
if (err < B_OK)
return errno;
if (obuf && olen) {
err = send(fSocket, obuf, olen, 0);
if (err < B_OK)
return errno;
}
err = B_OK;
if (ibuf && ilen) {
err = recv(fSocket, ibuf, ilen, 0);
if (err < B_OK)
return errno;
/* return received len */
}
return err;
}
status_t ESDEndpoint::SendDefaultCommand()
{
status_t err;
struct {
esd_format_t format;
esd_rate_t rate;
char name[ESD_MAX_NAME];
} c;
CALLED();
if (fDefaultCommandSent)
return EALREADY;
c.format = fDefaultFormat;
c.rate = fDefaultRate;
strcpy(c.name, "BeOS/Haiku/ZETA Media Kit output");
err = SendCommand(fDefaultCommand, (uint8 *)&c, sizeof(c), NULL, 0);
if (err < B_OK)
return err;
PRINT(("SendCommand: %s\n", strerror(err)));
fDefaultCommandSent = true;
return B_OK;
}
@@ -0,0 +1,84 @@
/*
* ESounD media addon for BeOS
*
* Copyright (c) 2006 François Revol ([email protected])
*
* Based on Multi Audio addon for Haiku,
* 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 ESDENDPOINT_H
#define ESDENDPOINT_H
#include "esdproto.h"
#include <DataIO.h>
#include <String.h>
//#define ESD_FMT 8
#define ESD_FMT 16
class ESDEndpoint : public BDataIO {
public:
ESDEndpoint();
~ESDEndpoint();
/* */
status_t SendAuthKey();
status_t Connect(const char *host, uint16 port=ESD_PORT);
status_t Disconnect();
/* set the default command and format for BDataIO interface */
status_t SetCommand(esd_command_t cmd=ESD_CMD_STREAM_PLAY);
status_t SetFormat(int bits, int channels, float rate=ESD_DEFAULT_RATE);
status_t GetServerInfo();
/* */
bigtime_t GetLatency() const { return fLatency; };
bool CanSend();
/* BDataIO */
virtual ssize_t Read(void *buffer, size_t size);
virtual ssize_t Write(const void *buffer, size_t size);
status_t SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen);
status_t SendDefaultCommand();
private:
BString fHost;
uint16 fPort;
int fSocket;
esd_key_t fAuthKey;
esd_command_t fDefaultCommand;
bool fDefaultCommandSent;
esd_format_t fDefaultFormat;
esd_rate_t fDefaultRate;
bigtime_t fLatency;
};
#endif /* ESDENDPOINT_H */
@@ -0,0 +1,306 @@
/*
* ESounD media addon for BeOS
*
* Copyright (c) 2006 François Revol ([email protected])
*
* Based on Multi Audio addon for Haiku,
* 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.
*
*/
#define _ZETA_TS_FIND_DIR_ 1
#include <MediaDefs.h>
#include <MediaAddOn.h>
#include <Errors.h>
#include <Node.h>
#include <Mime.h>
#include <StorageDefs.h>
#include <Path.h>
#include <Directory.h>
#include <Entry.h>
#include <FindDirectory.h>
#include "ESDSinkNode.h"
#include "ESDSinkAddOn.h"
#include "ESDEndpoint.h"
#include <limits.h>
#include <stdio.h>
#include <string.h>
//#undef DEBUG
//#define DEBUG 4
#include "debug.h"
#include <Debug.h>
//#define MULTI_SAVE
// instantiation function
extern "C" _EXPORT BMediaAddOn * make_media_addon(image_id image) {
CALLED();
return new ESDSinkAddOn(image);
}
// -------------------------------------------------------- //
// ctor/dtor
// -------------------------------------------------------- //
ESDSinkAddOn::~ESDSinkAddOn()
{
CALLED();
void *device = NULL;
for ( int32 i = 0; (device = fDevices.ItemAt(i)); i++ )
delete (ESDEndpoint *)device;
SaveSettings();
}
ESDSinkAddOn::ESDSinkAddOn(image_id image) :
BMediaAddOn(image),
fDevices()
{
CALLED();
fInitCheckStatus = B_NO_INIT;
LoadSettings();
if(SetupDefaultSinks()!=B_OK)
return;
fInitCheckStatus = B_OK;
}
// -------------------------------------------------------- //
// BMediaAddOn impl
// -------------------------------------------------------- //
status_t ESDSinkAddOn::InitCheck(
const char ** out_failure_text)
{
CALLED();
return B_OK;
}
int32 ESDSinkAddOn::CountFlavors()
{
CALLED();
//return fDevices.CountItems();
return 1;
}
status_t ESDSinkAddOn::GetFlavorAt(
int32 n,
const flavor_info ** out_info)
{
CALLED();
if (out_info == 0) {
fprintf(stderr,"<- B_BAD_VALUE\n");
return B_BAD_VALUE; // we refuse to crash because you were stupid
}
//if (n < 0 || n > fDevices.CountItems() - 1) {
if (n < 0 || n > 1) {
fprintf(stderr,"<- B_BAD_INDEX\n");
return B_BAD_INDEX;
}
ESDEndpoint *device = (ESDEndpoint *) fDevices.ItemAt(n);
flavor_info * infos = new flavor_info[1];
ESDSinkNode::GetFlavor(&infos[0], n);
// infos[0].name = device->MD.friendly_name;
infos[0].name = "ESounD Out";
(*out_info) = infos;
return B_OK;
}
BMediaNode * ESDSinkAddOn::InstantiateNodeFor(
const flavor_info * info,
BMessage * config,
status_t * out_error)
{
CALLED();
if (out_error == 0) {
fprintf(stderr,"<- NULL\n");
return 0; // we refuse to crash because you were stupid
}
BMessage defaults;
if (!config)
config = &defaults;
#ifdef MULTI_SAVE
if(fSettings.FindMessage(device->MD.friendly_name, config)==B_OK) {
fSettings.RemoveData(device->MD.friendly_name);
}
#endif
ESDSinkNode * node
= new ESDSinkNode(this,
"ESounD Sink",
config);
if (node == 0) {
*out_error = B_NO_MEMORY;
fprintf(stderr,"<- B_NO_MEMORY\n");
} else {
*out_error = node->InitCheck();
}
return node;
}
status_t
ESDSinkAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_message)
{
CALLED();
#ifdef MULTI_SAVE
if (into_message == 0) {
into_message = new BMessage();
ESDSinkNode * node = dynamic_cast<ESDSinkNode*>(your_node);
if (node == 0) {
fprintf(stderr,"<- B_BAD_TYPE\n");
return B_BAD_TYPE;
}
if(node->GetConfigurationFor(into_message)==B_OK) {
fSettings.AddMessage(your_node->Name(), into_message);
}
return B_OK;
}
#endif
// currently never called by the media kit. Seems it is not implemented.
if (into_message == 0) {
fprintf(stderr,"<- B_BAD_VALUE\n");
return B_BAD_VALUE; // we refuse to crash because you were stupid
}
ESDSinkNode * node = dynamic_cast<ESDSinkNode*>(your_node);
if (node == 0) {
fprintf(stderr,"<- B_BAD_TYPE\n");
return B_BAD_TYPE;
}
return node->GetConfigurationFor(into_message);
}
#if 0
bool ESDSinkAddOn::WantsAutoStart()
{
CALLED();
return true;//false;
}
status_t ESDSinkAddOn::AutoStart(
int in_count,
BMediaNode ** out_node,
int32 * out_internal_id,
bool * out_has_more)
{
CALLED();
const flavor_info *fi;
status_t err;
// XXX: LEAK!
PRINT(("AutoStart: in_count=%d\n", in_count));
// if (in_count < 1)
// return EINVAL;
*out_internal_id = 0;
*out_has_more = false;
err = GetFlavorAt(0, (const flavor_info **)&fi);
if (err < 0)
return err;
*out_node = InstantiateNodeFor((const flavor_info *)fi, NULL, &err);
delete fi;
if (err < 0)
return err;
return B_OK+1;
}
#endif
status_t
ESDSinkAddOn::SetupDefaultSinks()
{
CALLED();
#if 0
BDirectory root;
if(rootEntry!=NULL)
root.SetTo(rootEntry);
else if(rootPath!=NULL) {
root.SetTo(rootPath);
} else {
PRINT(("Error in ESDSinkAddOn::RecursiveScan null params\n"));
return B_ERROR;
}
BEntry entry;
while(root.GetNextEntry(&entry) > B_ERROR) {
if(entry.IsDirectory()) {
RecursiveScan(rootPath, &entry);
} else {
BPath path;
entry.GetPath(&path);
ESDEndpoint *device = new ESDEndpoint(path.Path() + strlen(rootPath), path.Path());
if (device) {
if (device->InitCheck() == B_OK)
fDevices.AddItem(device);
else
delete device;
}
}
}
#endif
return B_OK;
}
void
ESDSinkAddOn::SaveSettings(void)
{
CALLED();
BPath path;
if(find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE);
BFile file(path.Path(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
if(file.InitCheck()==B_OK)
fSettings.Flatten(&file);
}
}
void
ESDSinkAddOn::LoadSettings(void)
{
CALLED();
fSettings.MakeEmpty();
BPath path;
if(find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE);
BFile file(path.Path(),B_READ_ONLY);
if((file.InitCheck()==B_OK)&&(fSettings.Unflatten(&file)==B_OK))
{
//fSettings.PrintToStream();
} else {
PRINT(("Error unflattening settings file %s\n",path.Path()));
}
}
}
@@ -0,0 +1,87 @@
/*
* ESounD media addon for BeOS
*
* Copyright (c) 2006 François Revol ([email protected])
*
* Based on Multi Audio addon for Haiku,
* 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 _ESDSINK_ADDON_H
#define _ESDSINK_ADDON_H
#include <MediaDefs.h>
#include <MediaAddOn.h>
#define SETTINGS_FILE "Media/esd_sink_settings"
class ESDSinkAddOn :
public BMediaAddOn
{
public:
virtual ~ESDSinkAddOn(void);
explicit ESDSinkAddOn(image_id image);
/**************************/
/* begin from BMediaAddOn */
public:
virtual status_t InitCheck(
const char ** out_failure_text);
virtual int32 CountFlavors(void);
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(void);
virtual status_t AutoStart(
int in_count,
BMediaNode ** out_node,
int32 * out_internal_id,
bool * out_has_more);
*/
/* end from BMediaAddOn */
/************************/
private:
status_t SetupDefaultSinks();
void SaveSettings();
void LoadSettings();
status_t fInitCheckStatus;
BList fDevices;
BMessage fSettings; // settings loaded from settings directory
};
extern "C" _EXPORT BMediaAddOn *make_media_addon( image_id you );
#endif /* _ESDSINK_ADDON_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,364 @@
/*
* ESounD media addon for BeOS
*
* Copyright (c) 2006 François Revol ([email protected])
*
* Based on Multi Audio addon for Haiku,
* 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 _ESDSINK_NODE_H
#define _ESDSINK_NODE_H
#include <MediaDefs.h>
#include <MediaNode.h>
#include <FileInterface.h>
#include <BufferConsumer.h>
#include <BufferProducer.h>
#include <Controllable.h>
#include <MediaEventLooper.h>
#include <ParameterWeb.h>
#include <TimeSource.h>
#include <Controllable.h>
#include <File.h>
#include <Entry.h>
#include "ESDEndpoint.h"
//#define ENABLE_INPUT 1
//#define ENABLE_TS 1
/*bool format_is_acceptible(
const media_format & producer_format,
const media_format & consumer_format);*/
class ESDSinkNode :
public BBufferConsumer,
#if ENABLE_INPUT
public BBufferProducer,
#endif
#ifdef ENABLE_TS
public BTimeSource,
#endif
public BMediaEventLooper,
public BControllable
{
protected:
virtual ~ESDSinkNode(void);
public:
explicit ESDSinkNode(BMediaAddOn *addon, char* name, BMessage * config);
virtual status_t InitCheck(void) const;
/*************************/
/* begin from BMediaNode */
public:
virtual BMediaAddOn* AddOn(
int32 * internal_id) const; /* Who instantiated you -- or NULL for app class */
protected:
/* These don't return errors; instead, they use the global error condition reporter. */
/* A node is required to have a queue of at least one pending command (plus TimeWarp) */
/* and is recommended to allow for at least one pending command of each type. */
/* Allowing an arbitrary number of outstanding commands might be nice, but apps */
/* cannot depend on that happening. */
virtual void Preroll(void);
public:
virtual status_t HandleMessage(
int32 message,
const void * data,
size_t size);
protected:
virtual void NodeRegistered(void); /* reserved 2 */
virtual status_t RequestCompleted(const media_request_info &info);
virtual void SetTimeSource(BTimeSource *timeSource);
/* end from BMediaNode */
/***********************/
/******************************/
/* begin from BBufferConsumer */
//included from BMediaAddOn
//virtual status_t HandleMessage(
// int32 message,
// const void * data,
// size_t size);
/* Someone, probably the producer, is asking you about this format. Give */
/* your honest opinion, possibly modifying *format. Do not ask upstream */
/* producer about the format, since he's synchronously waiting for your */
/* reply. */
virtual status_t AcceptFormat(
const media_destination & dest,
media_format * format);
virtual status_t GetNextInput(
int32 * cookie,
media_input * out_input);
virtual void DisposeInputCookie(
int32 cookie);
virtual void BufferReceived(
BBuffer * buffer);
virtual void ProducerDataStatus(
const media_destination & for_whom,
int32 status,
bigtime_t at_performance_time);
virtual status_t GetLatencyFor(
const media_destination & for_whom,
bigtime_t * out_latency,
media_node_id * out_timesource);
virtual status_t Connected(
const media_source & producer, /* here's a good place to request buffer group usage */
const media_destination & where,
const media_format & with_format,
media_input * out_input);
virtual void Disconnected(
const media_source & producer,
const media_destination & where);
/* The notification comes from the upstream producer, so he's already cool with */
/* the format; you should not ask him about it in here. */
virtual status_t FormatChanged(
const media_source & producer,
const media_destination & consumer,
int32 change_tag,
const media_format & format);
/* Given a performance time of some previous buffer, retrieve the remembered tag */
/* of the closest (previous or exact) performance time. Set *out_flags to 0; the */
/* idea being that flags can be added later, and the understood flags returned in */
/* *out_flags. */
virtual status_t SeekTagRequested(
const media_destination & destination,
bigtime_t in_target_time,
uint32 in_flags,
media_seek_tag * out_seek_tag,
bigtime_t * out_tagged_time,
uint32 * out_flags);
/* end from BBufferConsumer */
/****************************/
/******************************/
/* begin from BBufferProducer */
#if 0
virtual status_t FormatSuggestionRequested( media_type type,
int32 quality,
media_format* format);
virtual status_t FormatProposal( const media_source& output,
media_format* format);
virtual status_t FormatChangeRequested( const media_source& source,
const media_destination& destination,
media_format* io_format,
int32* _deprecated_);
virtual status_t GetNextOutput( int32* cookie,
media_output* out_output);
virtual status_t DisposeOutputCookie( int32 cookie);
virtual status_t SetBufferGroup( const media_source& for_source,
BBufferGroup* group);
virtual status_t PrepareToConnect( const media_source& what,
const media_destination& where,
media_format* format,
media_source* out_source,
char* out_name);
virtual void Connect( status_t error,
const media_source& source,
const media_destination& destination,
const media_format& format,
char* io_name);
virtual void Disconnect( const media_source& what,
const media_destination& where);
virtual void LateNoticeReceived( const media_source& what,
bigtime_t how_much,
bigtime_t performance_time);
virtual void EnableOutput( const media_source & what,
bool enabled,
int32* _deprecated_);
virtual void AdditionalBufferRequested( const media_source& source,
media_buffer_id prev_buffer,
bigtime_t prev_time,
const media_seek_tag* prev_tag);
#endif
/* end from BBufferProducer */
/****************************/
/*****************/
/* BControllable */
/*****************/
/********************************/
/* start from BMediaEventLooper */
protected:
/* you must override to handle your events! */
/* you should not call HandleEvent directly */
virtual void HandleEvent( const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
/* end from BMediaEventLooper */
/******************************/
/********************************/
/* start from BTimeSource */
#ifdef ENABLE_TS
protected:
virtual void SetRunMode( run_mode mode);
virtual status_t TimeSourceOp( const time_source_op_info &op,
void *_reserved);
#endif
/* end from BTimeSource */
/******************************/
/********************************/
/* start from BControllable */
protected:
virtual status_t GetParameterValue( int32 id,
bigtime_t* last_change,
void* value,
size_t* ioSize);
virtual void SetParameterValue( int32 id,
bigtime_t when,
const void* value,
size_t size);
virtual BParameterWeb* MakeParameterWeb();
/* end from BControllable */
/******************************/
protected:
virtual status_t HandleStart(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
virtual status_t HandleSeek(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
virtual status_t HandleWarp(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
virtual status_t HandleStop(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
virtual status_t HandleBuffer(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
virtual status_t HandleDataStatus(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
virtual status_t HandleParameter(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
public:
static void GetFlavor(flavor_info * outInfo, int32 id);
static void GetFormat(media_format * outFormat);
status_t GetConfigurationFor(BMessage * into_message);
private:
ESDSinkNode( /* private unimplemented */
const ESDSinkNode & clone);
ESDSinkNode & operator=(
const ESDSinkNode & clone);
#if 0
void AllocateBuffers(node_output &channel);
BBuffer* FillNextBuffer( multi_buffer_info &MBI,
node_output &channel);
void UpdateTimeSource(multi_buffer_info &MBI,
multi_buffer_info &oldMBI,
node_input &input);
#endif
// node_output* FindOutput(media_source source);
// node_input* FindInput(media_destination dest);
// node_input* FindInput(int32 destinationId);
// void ProcessGroup(BParameterGroup *group, int32 index, int32 &nbParameters);
// void ProcessMux(BDiscreteParameter *parameter, int32 index);
status_t fInitCheckStatus;
BMediaAddOn *fAddOn;
int32 fId;
BList fInputs;
media_input fInput;
bigtime_t fLatency;
BList fOutputs;
media_output fOutput;
media_format fPreferredFormat;
bigtime_t fInternalLatency;
// this is computed from the real (negotiated) chunk size and bit rate,
// not the defaults that are in the parameters
bigtime_t fBufferPeriod;
//volatile uint32 fBufferCycle;
sem_id fBuffer_free;
thread_id fThread;
BString fHostname;
ESDEndpoint *fDevice;
//multi_description MD;
//multi_format_info MFI;
//multi_buffer_list MBL;
//multi_mix_control_info MMCI;
//multi_mix_control MMC[MAX_CONTROLS];
bool fTimeSourceStarted;
BParameterWeb *fWeb;
BMessage fConfig;
};
#endif /* _ESDSINK_NODE_H */
@@ -0,0 +1,279 @@
EsounD Protocol (Draft)
Author: ymnk<[email protected]>
Data: 2000-10-02
===============
Introduction
------------
This document describes the protocol in EsounD system.
Unfortunately, any formal description about EsounD had not existed.
So the author has tried to read the source code of EsounD and written this
document. The author is also the author of JEsd, which is a re-implementation
of EsounD in pure Java and this document is based on his knowledge,
which had gotten in hacking JEsd.
Connection Setup
----------------
The esd will wait for the TCP connection requests from EsounD compatible
applications. In the default, esd will listen to the TCP port 16001.
The client must send an initial byte of data to be authorized them-self
and to identify the byte order to be employed.
For authorization, client must send 'esd-key', which is a 16 byte data.
For endian-ness, client must send a 4 byte data.
If esd does not detect any error, '1' will be sent back and
'0' will be sent back in error.
Requests
--------
lock:
esd-key:ESDKEY
w result:BOOLEAN
At first, esd will check if the client has the right to lock the device
by esd-key. If that client has the right to do so, esd will lock the device
and send back true. If not, false will be sent back
unlock:
esd-key:ESDKEY
w result:BOOLEAN
At first, esd will check if the client has the right to unlock the device
by esd-key. If that client has the right to do so, esd will unlock the
device and send back true. If not, false will be sent back
...
Syntactic Conventions
--------------------
All numbers are in decimal, unless prefixed with '0x', in which case
they are in hexadecimal(base 16).
The general syntax used to describe data packets is:
Name:
encoded-form
...
encoded-form
For components described in the protocol descriptions as:
name: TYPE
w name: TYPE
the encode-form are:
N TYPE name
and
w N TYPE name
N is the number of bytes in the data stream, and TYPE is the interpretation
of those bytes. For example,
result: BOOLEAN
becomes:
4 BOOLEAN result
For components with a static numeric value the encode-form is:
N value name
The value is always interpreted as a N-byte unsigned integer.
Data Types
----------
CARD8: A single byte unsigned integer.
CARD32: 32-bit unsigned integer
ARRAY8: A collection of CARD8.
ARRAY8(n): This is a ARRAY8, which includes 'n' elements.
ENDIAN: This is a ARRAY8(4), which includes 'ENDN' or 'NDNE'.
If the first element is 'E', data from clients is in big-endian.
BOOLEAN: This is a CARD32 and includes '0' or '1'. '1' means true.
ESDKEY: This is a ARRAY8(16), which includes 'esd-key'.
ESDNAME: This is a ARRAY8(128), which includes 'esd-name'.
ESDSTREAM: This is a infinite ARRAY8.
FORMAT: This is a CARD32. Each bits in this data has following semantics,
(format&0x000f)==0x0000 8bit data
(format&0x000f)==0x0001 16bit data
(format&0x00f0)==0x0010 mono
(format&0x00f0)==0x0020 stereo
(format&0x0f00)==0x0000 stream
(format&0x0f00)==0x0100 sample
(format&0x0f00)==0x0200 ADPCM
(format&0xf000)==0x1000 play
(format&0xf000)==0x0000 monitor for streams, stop for samples
(format&0xf000)==0x2000 record for streams, loop for samples
MODE: This is a CARD32, which is '0', '1', '2' or '3'.
0 ERROR
1 STANDBY
2 AUTOSTANDBY
3 RUNNING
Packet Format
-------------
init:
4 0 opcode
16 ESDKEY esd-key
4 ENDIAN 'ENDN' or 'NDNE'
w 4 BOOLEAN 0 or 1
lock:
4 1 opcode
16 ESDKEY esd-key
4 ENDIAN unused
w 4 BOOLEAN 0 or 1
unlock:
4 2 opcode
16 ESDKEY esd-key
4 ENDIAN unused
w 4 BOOLEAN 0 or 1
stream-play:
4 3 opcode
4 FORMAT format
4 CARD32 rate
128 ESDNAME name
? ESDSTREAM stream of PCM sound
//stream-mon: This protocol is not used for the remote esd.
// 4 4 opcode
// 4 FORMA format
// 4 CARD3 rate
// 128 ESDNAME name
// w ? ESDSTREAM stream of PCM sound
stream-mon:
4 5 opcode
4 FORMAT format
4 CARD32 rate
128 ESDNAME name
w ? ESDSTREAM stream of PCM sound
sample-cache:
4 6 opcode
4 FORMAT format
4 CARD32 rate
4 n size
128 ESDNAME name
w 4 CARD32 sample-id
n ARRAY8(n) stream of PCM sound
w 4 CARD32 sample-id
sample-free:
4 7 opcode
4 CARD32 sample-id
w 4 CARD32 sample-id
sample-play:
4 8 opcode
4 CARD32 sample-id
w 4 CARD32 sample-id
sample-loop:
4 9 opcode
4 CARD32 sample-id
w 4 CARD32 sample-id
sample-stop:
4 10 opcode
4 CARD32 sample-id
w 4 CARD32 sample-id
sample-kill:
4 11 opcode
4 CARD32 sample-id
w 4 CARD32 sample-id
standby:
4 12 opcode
16 ESDKEY esd-key
4 ENDIAN unused
w 4 BOOLEAN 0 or 1
resume:
4 13 opcode
16 ESDKEY esd-key
4 ENDIAN unused
w 4 BOOLEAN 0 or 1
sample-getid:
4 14 opcode
128 ESDNAME name
w 4 CARD32 sample-id
stream-filter:
4 15 opcode
4 FORMAT format
4 CARD32 rate
128 ESDNAME name
w 4 BOOLEAN 0 or 1
server-info:
4 16 opcode
w 4 CARD32 version
w 4 CARD32 rate
w 4 FORMAT format
server-all-info:
4 17 opcode
w 4 CARD32 version
w 4 CARD32 rate
w 4 FORMAT format
w ? STREAMINFO
w ? SAMPLEINFO
STREAMINFO:
except for last in series
w 4 CARD32 id
w 16 ESDNAME name
w 4 CARD32 rate
w 4 CARD32 left-vol-scale
w 4 CARD32 right-vol-scale
w 4 FORMAT format
last in series
w 4 CARD32 0
w 32 ARRAY8(32) unused
SAMPLEINFO:
except for last in series
w 4 CARD32 id
w 16 ESDNAME name
w 4 CARD32 rate
w 4 CARD32 left-vol-scale
w 4 CARD32 right-vol-scale
w 4 FORMAT format
w 4 CARD32 sample-length
last in series
w 4 CARD32 0
w 36 ARRAY8(36) unused
//subscribe: undefined
// 4 18 opcode
//unsubjcribe: undefined
// 4 19 opcode
stream-pan:
4 20 opcode
4 CARD32 stream-id
4 CARD32 left-scale
4 CARD32 right-scale
w 4 BOOLEAN 0 or 1
sample-pan:
4 21 opcode
4 CARD32 sample-id
4 CARD32 left-scale
4 CARD32 right-scale
w 4 BOOLEAN 0 or 1
standby-mode:
4 22 opcode
4 0 version
w 4 MODE mode
w 4 BOOLEAN 0 or 1
latency:
4 23 opcode
w 4 CARD32 latency
@@ -0,0 +1,20 @@
SubDir HAIKU_TOP src add-ons media media-add-ons esound_sink ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if $(TARGET_PLATFORM) != haiku {
SubDirC++Flags -fmultiple-symbol-spaces ;
}
Addon ESDSink.media_addon : media :
ESDEndpoint.cpp
ESDSinkAddOn.cpp
ESDSinkNode.cpp
: false
: be media
;
#Package haiku-multi_audio-cvs
# : hmulti_audio.media_addon
# : boot home config add-ons media ;
@@ -0,0 +1,26 @@
#ifndef _COMPAT_H
#define _COMPAT_H
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#if IPPROTO_TCP != 6
/* net_server */
#else
# define closesocket close
# ifdef BONE_VERSION
/* BONE */
# else
/* Haiku ? */
# endif
#endif
#endif /* _COMPAT_H */
@@ -0,0 +1,34 @@
#include <stdio.h>
#ifndef NDEBUG
#ifndef DEBUG
#define DEBUG 2
#endif
#if DEBUG >= 1
#define UNIMPLEMENTED() printf("UNIMPLEMENTED %s\n",__PRETTY_FUNCTION__)
#else
#define UNIMPLEMENTED() ((void)0)
#endif
#if DEBUG >= 2
#define BROKEN() printf("BROKEN %s\n",__PRETTY_FUNCTION__)
#else
#define BROKEN() ((void)0)
#endif
#if DEBUG >= 3
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
#else
#define CALLED() ((void)0)
#endif
#else
#define UNIMPLEMENTED() ((void)0)
#define BROKEN() ((void)0)
#define CALLED() ((void)0)
#endif
@@ -0,0 +1,131 @@
/*
* ESounD media addon for BeOS
*
* Copyright (c) 2006 François Revol (revol@free.fr)
*
* Based on Multi Audio addon for Haiku,
* 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,
* 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 _ESDPROTO_H
#define _ESDPROTO_H
/*
* ESounD protocol
* cf. http://www.jcraft.com/jesd/EsounD-protocol.txt
*/
#include <inttypes.h>
/* limits */
#define ESD_MAX_BUF (4 * 1024)
#define ESD_MAX_KEY 16
#define ESD_MAX_NAME 128
typedef uint32_t esd_rate_t;
typedef uint32_t esd_format_t;
typedef uint32_t esd_command_t;
typedef char esd_key_t[ESD_MAX_KEY];
typedef char esd_name_t[ESD_MAX_NAME];
/* defaults */
//#define ESD_PORT 5001
#define ESD_PORT 16001
#define ESD_DEFAULT_RATE 44100
//#define ESD_DEFAULT_RATE 22050
#define ESD_ENDIAN_TAG 'ENDN'
enum {
/* init */
ESD_CMD_CONNECT = 0,
/* security */
ESD_CMD_LOCK,
ESD_CMD_UNLOCK,
ESD_CMD_STREAM_PLAY,
ESD_CMD_STREAM_REC,
ESD_CMD_STREAM_MON,
ESD_CMD_SAMPLE_CACHE,
ESD_CMD_SAMPLE_FREE,
ESD_CMD_SAMPLE_PLAY,
ESD_CMD_SAMPLE_LOOP,
ESD_CMD_SAMPLE_STOP,
ESD_CMD_SAMPLE_KILL,
ESD_CMD_STANDBY,
ESD_CMD_RESUME,
ESD_CMD_SAMPLE_GETID,
ESD_CMD_STREAM_FILTER,
ESD_CMD_SERVER_INFO,
ESD_CMD_SERVER_ALL_INFO,
_ESD_CMD_SUBSCRIBE,
_ESD_CMD_UNSUBSCRIBE,
ESD_CMD_STREAM_PAN,
ESD_CMD_SAMPLE_PAN,
ESD_CMD_STANDBY_MODE,
ESD_CMD_LATENCY
};
#define ESD_MASK_BITS 0x000F
#define ESD_MASK_CHAN 0x00F0
#define ESD_MASK_MODE 0x0F00
#define ESD_MASK_FUNC 0xF000
/* sample size */
#define ESD_BITS8 0x0000
#define ESD_BITS16 0x0001
/* channel count */
#define ESD_MONO 0x0010
#define ESD_STEREO 0x0020
/* mode */
#define ESD_STREAM 0x0000
#define ESD_SAMPLE 0x0100
#define ESD_ADPCM 0x0200
/* functions */
#define ESD_FUNC_PLAY 0x1000
#define ESD_FUNC_MONITOR 0x0000
#define ESD_FUNC_RECORD 0x2000
#define ESD_FUNC_STOP 0x0000
#define ESD_FUNC_LOOP 0x2000
/* errors */
#define ESD_OK 0
#define ESD_ERROR_STANDBY 1
#define ESD_ERROR_AUTOSTANDBY 2
#define ESD_ERROR_RUNNING 3
#define ESD_FALSE 0
#define ESD_TRUE 1
#endif /* _ESDPROTO_H */
@@ -0,0 +1,128 @@
## BeOS Generic Makefile v2.2 ##
## Fill in this file to specify the project being created, and the referenced
## makefile-engine will do all of the hard work for you. This handles both
## Intel and PowerPC builds of the BeOS.
# check for net_server vs BONE
ifeq ($(findstring headers/be/bone,$(BEINCLUDES)),)
NETLIBS=net
else
NETLIBS=socket bind
endif
## Application Specific Settings ---------------------------------------------
# specify the name of the binary
NAME= ESDSink.media_addon
# specify the type of binary
# APP: Application
# SHARED: Shared library or add-on
# STATIC: Static library archive
# DRIVER: Kernel Driver
TYPE= SHARED
# add support for new Pe and Eddie features
# to fill in generic makefile
#%{
# @src->@
# specify the source files to use
# full paths or paths relative to the makefile can be included
# all files, regardless of directory, will have their object
# files created in the common object directory.
# Note that this means this makefile will not work correctly
# if two source files with the same name (source.c or source.cpp)
# are included from different directories. Also note that spaces
# in folder names do not work well with this makefile.
SRCS= $(wildcard *.cpp)
# specify the resource files to use
# full path or a relative path to the resource file can be used.
RSRCS=
# @<-src@
#%}
# end support for Pe and Eddie
# specify additional libraries to link against
# there are two acceptable forms of library specifications
# - if your library follows the naming pattern of:
# libXXX.so or libXXX.a you can simply specify XXX
# library: libbe.so entry: be
#
# - if your library does not follow the standard library
# naming scheme you need to specify the path to the library
# and it's name
# library: my_lib.a entry: my_lib.a or path/my_lib.a
LIBS= be media $(NETLIBS)
# specify additional paths to directories following the standard
# libXXX.so or libXXX.a naming scheme. You can specify full paths
# or paths relative to the makefile. The paths included may not
# be recursive, so include all of the paths where libraries can
# be found. Directories where source files are found are
# automatically included.
LIBPATHS=
# additional paths to look for system headers
# thes use the form: #include <header>
# source file directories are NOT auto-included here
SYSTEM_INCLUDE_PATHS =
# additional paths to look for local headers
# thes use the form: #include "header"
# source file directories are automatically included
LOCAL_INCLUDE_PATHS =
# specify the level of optimization that you desire
# NONE, SOME, FULL
OPTIMIZE=
# specify any preprocessor symbols to be defined. The symbols will not
# have their values set automatically; you must supply the value (if any)
# to use. For example, setting DEFINES to "DEBUG=1" will cause the
# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG"
# would pass "-DDEBUG" on the compiler's command line.
DEFINES=
# specify special warning levels
# if unspecified default warnings will be used
# NONE = supress all warnings
# ALL = enable all warnings
WARNINGS =
# specify whether image symbols will be created
# so that stack crawls in the debugger are meaningful
# if TRUE symbols will be created
SYMBOLS =
# specify debug settings
# if TRUE will allow application to be run from a source-level
# debugger. Note that this will disable all optimzation.
DEBUGGER =
# specify additional compiler flags for all files
COMPILER_FLAGS =
# specify additional linker flags
LINKER_FLAGS =
# specify the version of this particular item
# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL")
# This may also be specified in a resource.
APP_VERSION =
# (for TYPE == DRIVER only) Specify desired location of driver in the /dev
# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will
# instruct the driverinstall rule to place a symlink to your driver's binary in
# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at
# /dev/video/usb when loaded. Default is "misc".
DRIVER_PATH =
## include the makefile-engine
include $(BUILDHOME)/etc/makefile-engine