changed allocation scheme
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1064 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
59e1220c9b
commit
45ed7b19fd
@ -297,7 +297,7 @@ status_t AbstractFileInterfaceNode::GetNextFileFormat(
|
||||
// so next time they won't get the same format again
|
||||
*cookie = 1;
|
||||
}
|
||||
*out_format = *GetFileFormat();
|
||||
GetFileFormat(out_format);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -822,6 +822,9 @@ status_t AbstractFileInterfaceNode::HandleParameter(
|
||||
void AbstractFileInterfaceNode::GetFlavor(flavor_info * info, int32 id)
|
||||
{
|
||||
fprintf(stderr,"AbstractFileInterfaceNode::GetFlavor\n");
|
||||
if (info == 0) {
|
||||
return;
|
||||
}
|
||||
info->name = "AbstractFileInterfaceNode";
|
||||
info->info = "A AbstractFileInterfaceNode node handles a file.";
|
||||
info->kinds = B_FILE_INTERFACE | B_CONTROLLABLE;
|
||||
@ -835,42 +838,41 @@ void AbstractFileInterfaceNode::GetFlavor(flavor_info * info, int32 id)
|
||||
return;
|
||||
}
|
||||
|
||||
media_format * AbstractFileInterfaceNode::GetFormat()
|
||||
void AbstractFileInterfaceNode::GetFormat(media_format * outFormat)
|
||||
{
|
||||
fprintf(stderr,"AbstractFileInterfaceNode::GetFormat\n");
|
||||
static bool initialized = false;
|
||||
static media_format format;
|
||||
if (initialized == false) {
|
||||
format.type = B_MEDIA_MULTISTREAM;
|
||||
format.require_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
|
||||
format.deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
|
||||
format.u.multistream = media_multistream_format::wildcard;
|
||||
initialized = true;
|
||||
if (outFormat == 0) {
|
||||
return;
|
||||
}
|
||||
return &format;
|
||||
outFormat->type = B_MEDIA_MULTISTREAM;
|
||||
outFormat->require_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
|
||||
outFormat->deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
|
||||
outFormat->u.multistream = media_multistream_format::wildcard;
|
||||
}
|
||||
|
||||
media_file_format * AbstractFileInterfaceNode::GetFileFormat()
|
||||
void AbstractFileInterfaceNode::GetFileFormat(media_file_format * outFileFormat)
|
||||
{
|
||||
fprintf(stderr,"AbstractFileInterfaceNode::GetFileFormat\n");
|
||||
static bool initialized = false;
|
||||
static media_file_format file_format;
|
||||
if (initialized == false) {
|
||||
file_format.capabilities =
|
||||
media_file_format::B_PERFECTLY_SEEKABLE
|
||||
| media_file_format::B_IMPERFECTLY_SEEKABLE
|
||||
| media_file_format::B_KNOWS_ANYTHING;
|
||||
/* I don't know what to initialize this to. (or if I should) */
|
||||
// format.id =
|
||||
file_format.family = B_ANY_FORMAT_FAMILY;
|
||||
file_format.version = 100;
|
||||
strcpy(file_format.mime_type,"");
|
||||
strcpy(file_format.pretty_name,"any media file format");
|
||||
strcpy(file_format.short_name,"any");
|
||||
strcpy(file_format.file_extension,"");
|
||||
initialized = true;
|
||||
if (outFileFormat == 0) {
|
||||
return;
|
||||
}
|
||||
return &file_format;
|
||||
outFileFormat->capabilities =
|
||||
media_file_format::B_PERFECTLY_SEEKABLE
|
||||
| media_file_format::B_IMPERFECTLY_SEEKABLE
|
||||
| media_file_format::B_KNOWS_ANYTHING;
|
||||
/* I don't know what to initialize this to. (or if I should) */
|
||||
// format.id =
|
||||
outFileFormat->family = B_ANY_FORMAT_FAMILY;
|
||||
outFileFormat->version = 100;
|
||||
// see media_file_format in <MediaDefs.h> for limits
|
||||
strncpy(outFileFormat->mime_type,"",63);
|
||||
outFileFormat->mime_type[63]='\0';
|
||||
strncpy(outFileFormat->pretty_name,"any media file format",63);
|
||||
outFileFormat->pretty_name[63]='\0';
|
||||
strncpy(outFileFormat->short_name,"any",31);
|
||||
outFileFormat->short_name[31]='\0';
|
||||
strncpy(outFileFormat->file_extension,"",7);
|
||||
outFileFormat->file_extension[7]='\0';
|
||||
}
|
||||
|
||||
// protected:
|
||||
|
@ -260,9 +260,9 @@ virtual status_t HandleParameter(
|
||||
|
||||
public:
|
||||
|
||||
static void GetFlavor(flavor_info * info, int32 id);
|
||||
static media_format * GetFormat();
|
||||
static media_file_format * GetFileFormat();
|
||||
static void GetFlavor(flavor_info * outInfo, int32 id);
|
||||
static void GetFormat(media_format * outFormat);
|
||||
static void GetFileFormat(media_file_format * outFileFormat);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -67,7 +67,7 @@ MediaReader::MediaReader(
|
||||
output.node = media_node::null; // until registration
|
||||
output.source = media_source::null; // until registration
|
||||
output.destination = media_destination::null;
|
||||
output.format = *GetFormat();
|
||||
GetFormat(&output.format);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
@ -130,7 +130,7 @@ status_t MediaReader::SetRef(
|
||||
return status;
|
||||
}
|
||||
// reset the format, and set the requirements imposed by this file
|
||||
output.format = *GetFormat();
|
||||
GetFormat(&output.format);
|
||||
AddRequirements(&output.format);
|
||||
// if we are connected we have to re-negotiate the connection
|
||||
if (output.destination != media_destination::null) {
|
||||
@ -161,7 +161,7 @@ status_t MediaReader::FormatSuggestionRequested(
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_FORMAT\n");
|
||||
return B_MEDIA_BAD_FORMAT;
|
||||
}
|
||||
*format = *GetFormat();
|
||||
GetFormat(format);
|
||||
AddRequirements(format);
|
||||
return B_OK;
|
||||
}
|
||||
@ -308,7 +308,9 @@ status_t MediaReader::FormatProposal(
|
||||
fprintf(stderr,"\n"); */
|
||||
// Be's format_is_compatible doesn't work.
|
||||
// if (!format_is_compatible(*format,*myFormat)) {
|
||||
if (!format_is_acceptible(*format,*GetFormat())) {
|
||||
media_format myFormat;
|
||||
GetFormat(&myFormat);
|
||||
if (!format_is_acceptible(*format,myFormat)) {
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_FORMAT\n");
|
||||
return B_MEDIA_BAD_FORMAT;
|
||||
}
|
||||
@ -338,7 +340,7 @@ status_t MediaReader::FormatChangeRequested(
|
||||
status_t status = FormatProposal(source,io_format);
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr," error returned by FormatProposal\n");
|
||||
*io_format = *GetFormat();
|
||||
GetFormat(io_format);
|
||||
return status;
|
||||
}
|
||||
return ResolveWildcards(io_format);
|
||||
@ -503,13 +505,13 @@ void MediaReader::Connect(
|
||||
if (error != B_OK) {
|
||||
fprintf(stderr,"<- error already\n");
|
||||
output.destination = media_destination::null;
|
||||
output.format = *GetFormat();
|
||||
GetFormat(&output.format);
|
||||
return;
|
||||
}
|
||||
if (output.source != source) {
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_SOURCE\n");
|
||||
output.destination = media_destination::null;
|
||||
output.format = *GetFormat();
|
||||
GetFormat(&output.format);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -534,7 +536,7 @@ void MediaReader::Connect(
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr,"<- SetBufferGroup failed\n");
|
||||
output.destination = media_destination::null;
|
||||
output.format = *GetFormat();
|
||||
GetFormat(&output.format);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -591,7 +593,7 @@ void MediaReader::Disconnect(
|
||||
return;
|
||||
}
|
||||
output.destination = media_destination::null;
|
||||
output.format = *GetFormat();
|
||||
GetFormat(&output.format);
|
||||
if (fBufferGroup != 0) {
|
||||
BBufferGroup * group = fBufferGroup;
|
||||
fBufferGroup = 0;
|
||||
@ -743,35 +745,42 @@ status_t MediaReader::HandleDataStatus(
|
||||
|
||||
// static:
|
||||
|
||||
void MediaReader::GetFlavor(flavor_info * info, int32 id)
|
||||
void MediaReader::GetFlavor(flavor_info * outInfo, int32 id)
|
||||
{
|
||||
fprintf(stderr,"MediaReader::GetFlavor\n");
|
||||
AbstractFileInterfaceNode::GetFlavor(info,id);
|
||||
info->name = "OpenBeOS Media Reader";
|
||||
info->info = "The OpenBeOS Media Reader reads a file and produces a multistream.";
|
||||
info->kinds |= B_BUFFER_PRODUCER;
|
||||
info->out_format_count = 1; // 1 output
|
||||
info->out_formats = GetFormat();
|
||||
if (outInfo == 0) {
|
||||
return;
|
||||
}
|
||||
AbstractFileInterfaceNode::GetFlavor(outInfo,id);
|
||||
outInfo->name = "OpenBeOS Media Reader";
|
||||
outInfo->info = "The OpenBeOS Media Reader reads a file and produces a multistream.";
|
||||
outInfo->kinds |= B_BUFFER_PRODUCER;
|
||||
outInfo->out_format_count = 1; // 1 output
|
||||
media_format * formats = new media_format[outInfo->out_format_count];
|
||||
GetFormat(&formats[0]);
|
||||
outInfo->out_formats = formats;
|
||||
return;
|
||||
}
|
||||
|
||||
media_format * MediaReader::GetFormat()
|
||||
void MediaReader::GetFormat(media_format * outFormat)
|
||||
{
|
||||
fprintf(stderr,"MediaReader::GetFormat\n");
|
||||
return AbstractFileInterfaceNode::GetFormat();
|
||||
if (outFormat == 0) {
|
||||
return;
|
||||
}
|
||||
AbstractFileInterfaceNode::GetFormat(outFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
media_file_format * MediaReader::GetFileFormat()
|
||||
void MediaReader::GetFileFormat(media_file_format * outFileFormat)
|
||||
{
|
||||
fprintf(stderr,"MediaReader::GetFileFormat\n");
|
||||
static bool initialized = false;
|
||||
static media_file_format * file_format;
|
||||
if (initialized == false) {
|
||||
file_format = AbstractFileInterfaceNode::GetFileFormat();
|
||||
file_format->capabilities |= media_file_format::B_READABLE;
|
||||
initialized = true;
|
||||
if (outFileFormat == 0) {
|
||||
return;
|
||||
}
|
||||
return file_format;
|
||||
AbstractFileInterfaceNode::GetFileFormat(outFileFormat);
|
||||
outFileFormat->capabilities |= media_file_format::B_READABLE;
|
||||
return;
|
||||
}
|
||||
|
||||
// protected:
|
||||
|
@ -201,9 +201,9 @@ virtual status_t HandleDataStatus(
|
||||
|
||||
public:
|
||||
|
||||
static void GetFlavor(flavor_info * info, int32 id);
|
||||
static media_format * GetFormat();
|
||||
static media_file_format * GetFileFormat();
|
||||
static void GetFlavor(flavor_info * outInfo, int32 id);
|
||||
static void GetFormat(media_format * outFormat);
|
||||
static void GetFileFormat(media_file_format * outFileFormat);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -149,7 +149,7 @@ status_t MediaReaderAddOn::GetFileFormatList(
|
||||
if (out_readable_formats != 0) {
|
||||
// don't go off the end
|
||||
if (in_read_items > 0) {
|
||||
out_readable_formats[0] = *MediaReader::GetFileFormat();
|
||||
MediaReader::GetFileFormat(&out_readable_formats[0]);
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
|
@ -67,7 +67,7 @@ MediaWriter::MediaWriter(
|
||||
input.node = media_node::null; // until registration
|
||||
input.source = media_source::null;
|
||||
input.destination = media_destination::null; // until registration
|
||||
input.format = *GetFormat();
|
||||
GetFormat(&input.format);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
@ -130,7 +130,7 @@ status_t MediaWriter::SetRef(
|
||||
return status;
|
||||
}
|
||||
// reset the format, and set the requirements imposed by this file
|
||||
input.format = *GetFormat();
|
||||
GetFormat(&input.format);
|
||||
AddRequirements(&input.format);
|
||||
// if we are connected we have to re-negotiate the connection
|
||||
if (input.source != media_source::null) {
|
||||
@ -285,7 +285,9 @@ status_t MediaWriter::AcceptFormat(
|
||||
fprintf(stderr,"\n");*/
|
||||
// Be's format_is_compatible doesn't work.
|
||||
// if (!format_is_compatible(*format,*myFormat)) {
|
||||
if (!format_is_acceptible(*format,*GetFormat())) {
|
||||
media_format myFormat;
|
||||
GetFormat(&myFormat);
|
||||
if (!format_is_acceptible(*format,myFormat)) {
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_FORMAT\n");
|
||||
return B_MEDIA_BAD_FORMAT;
|
||||
}
|
||||
@ -442,7 +444,7 @@ void MediaWriter::Disconnected(
|
||||
return;
|
||||
}
|
||||
input.source = media_source::null;
|
||||
input.format = *GetFormat();
|
||||
GetFormat(&input.format);
|
||||
if (fBufferGroup != 0) {
|
||||
BBufferGroup * group = fBufferGroup;
|
||||
fBufferGroup = 0;
|
||||
@ -526,35 +528,42 @@ status_t MediaWriter::HandleDataStatus(
|
||||
|
||||
// static:
|
||||
|
||||
void MediaWriter::GetFlavor(flavor_info * info, int32 id)
|
||||
void MediaWriter::GetFlavor(flavor_info * outInfo, int32 id)
|
||||
{
|
||||
fprintf(stderr,"MediaWriter::GetFlavor\n");
|
||||
AbstractFileInterfaceNode::GetFlavor(info,id);
|
||||
info->name = "OpenBeOS Media Writer";
|
||||
info->info = "The OpenBeOS Media Writer consumes a multistream and writes a file.";
|
||||
info->kinds |= B_BUFFER_CONSUMER;
|
||||
info->in_format_count = 1; // 1 input
|
||||
info->in_formats = GetFormat();
|
||||
if (outInfo == 0) {
|
||||
return;
|
||||
}
|
||||
AbstractFileInterfaceNode::GetFlavor(outInfo,id);
|
||||
outInfo->name = "OpenBeOS Media Writer";
|
||||
outInfo->info = "The OpenBeOS Media Writer consumes a multistream and writes a file.";
|
||||
outInfo->kinds |= B_BUFFER_CONSUMER;
|
||||
outInfo->in_format_count = 1; // 1 input
|
||||
media_format * formats = new media_format[outInfo->in_format_count];
|
||||
GetFormat(&formats[0]);
|
||||
outInfo->in_formats = formats;
|
||||
return;
|
||||
}
|
||||
|
||||
media_format * MediaWriter::GetFormat()
|
||||
void MediaWriter::GetFormat(media_format * outFormat)
|
||||
{
|
||||
fprintf(stderr,"MediaWriter::GetFormat\n");
|
||||
return AbstractFileInterfaceNode::GetFormat();
|
||||
if (outFormat == 0) {
|
||||
return;
|
||||
}
|
||||
AbstractFileInterfaceNode::GetFormat(outFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
media_file_format * MediaWriter::GetFileFormat()
|
||||
void MediaWriter::GetFileFormat(media_file_format * outFileFormat)
|
||||
{
|
||||
fprintf(stderr,"MediaWriter::GetFileFormat\n");
|
||||
static bool initialized = false;
|
||||
static media_file_format * file_format;
|
||||
if (initialized == false) {
|
||||
file_format = AbstractFileInterfaceNode::GetFileFormat();
|
||||
file_format->capabilities |= media_file_format::B_WRITABLE;
|
||||
initialized = true;
|
||||
if (outFileFormat == 0) {
|
||||
return;
|
||||
}
|
||||
return file_format;
|
||||
AbstractFileInterfaceNode::GetFileFormat(outFileFormat);
|
||||
outFileFormat->capabilities |= media_file_format::B_WRITABLE;
|
||||
return;
|
||||
}
|
||||
|
||||
// protected:
|
||||
|
@ -164,9 +164,9 @@ virtual status_t HandleDataStatus(
|
||||
|
||||
public:
|
||||
|
||||
static void GetFlavor(flavor_info * info, int32 id);
|
||||
static media_format * GetFormat();
|
||||
static media_file_format * GetFileFormat();
|
||||
static void GetFlavor(flavor_info * outInfo, int32 id);
|
||||
static void GetFormat(media_format * outFormat);
|
||||
static void GetFileFormat(media_file_format * outFileFormat);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -146,10 +146,10 @@ status_t MediaWriterAddOn::GetFileFormatList(
|
||||
if (out_read_items != 0) {
|
||||
*out_read_items = 1;
|
||||
}
|
||||
if (out_readable_formats != 0) {
|
||||
if (out_writable_formats != 0) {
|
||||
// don't go off the end
|
||||
if (in_write_items > 0) {
|
||||
out_writable_formats[0] = *MediaWriter::GetFileFormat();
|
||||
MediaWriter::GetFileFormat(&out_writable_formats[0]);
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user