Removed superflous NULL pointer checks.
The media kit will always call BMediaNode and BMediaAddOn functions with valid pointers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25232 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,10 +60,6 @@ status_t AbstractFileInterfaceAddOn::GetFlavorAt(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (out_info == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
if (n != 0) {
|
||||
PRINT("\t<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
@@ -81,10 +77,6 @@ status_t AbstractFileInterfaceAddOn::GetConfigurationFor(
|
||||
BMessage * into_message)
|
||||
{
|
||||
CALLED();
|
||||
if (into_message == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
AbstractFileInterfaceNode * node
|
||||
= dynamic_cast<AbstractFileInterfaceNode*>(your_node);
|
||||
if (node == 0) {
|
||||
@@ -124,11 +116,6 @@ status_t AbstractFileInterfaceAddOn::SniffRef(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((io_mime_type == 0) || (out_quality == 0) || (out_internal_id == 0)) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
|
||||
*out_internal_id = 0; // only one flavor
|
||||
char mime_string[B_MIME_TYPE_LENGTH+1];
|
||||
status_t status = AbstractFileInterfaceNode::StaticSniffRef(file,mime_string,out_quality);
|
||||
@@ -146,23 +133,12 @@ status_t AbstractFileInterfaceAddOn::SniffType(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((out_quality == 0) || (out_internal_id == 0)) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
|
||||
*out_quality = 1.0;
|
||||
*out_internal_id = 0;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// This function treats null pointers slightly differently than the others.
|
||||
// This is because a program could reasonably call this function with just
|
||||
// about any junk, get the out_read_items or out_write_items and then use
|
||||
// that to create an array of sufficient size to hold the result, and then
|
||||
// call us again. So we won't punish them if they supply us with null
|
||||
// pointers the first time around.
|
||||
status_t AbstractFileInterfaceAddOn::GetFileFormatList(
|
||||
int32 flavor_id,
|
||||
media_file_format * out_writable_formats,
|
||||
@@ -180,13 +156,9 @@ status_t AbstractFileInterfaceAddOn::GetFileFormatList(
|
||||
PRINT("\t<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_write_items != 0)
|
||||
*out_write_items = 0;
|
||||
|
||||
// see null check comment above
|
||||
if (out_read_items != 0)
|
||||
*out_read_items = 0;
|
||||
*out_write_items = 0;
|
||||
*out_read_items = 0;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -202,10 +174,6 @@ status_t AbstractFileInterfaceAddOn::SniffTypeKind(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((out_quality == 0) || (out_internal_id == 0)) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
if (in_kinds & (io_kind | B_FILE_INTERFACE | B_CONTROLLABLE)) {
|
||||
return SniffType(type,out_quality,out_internal_id);
|
||||
} else {
|
||||
|
||||
@@ -304,23 +304,14 @@ status_t AbstractFileInterfaceNode::GetNextFileFormat(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// avoid crashes
|
||||
if (out_format == 0) {
|
||||
// no place to write!
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
if (cookie != 0) {
|
||||
// it's valid but they already got our 1 file format
|
||||
if (*cookie != 0) {
|
||||
PRINT("\t<- B_ERROR\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
// so next time they won't get the same format again
|
||||
*cookie = 1;
|
||||
// it's valid but they already got our 1 file format
|
||||
if (*cookie != 0) {
|
||||
PRINT("\t<- B_ERROR\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// so next time they won't get the same format again
|
||||
*cookie = 1;
|
||||
GetFileFormat(out_format);
|
||||
return B_OK;
|
||||
}
|
||||
@@ -370,11 +361,6 @@ status_t AbstractFileInterfaceNode::SetRef(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (out_time == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashes today thanks
|
||||
}
|
||||
|
||||
status_t status;
|
||||
f_current_ref = file;
|
||||
if (fCurrentFile == 0) {
|
||||
@@ -402,11 +388,6 @@ status_t AbstractFileInterfaceNode::GetRef(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((out_ref == 0) || (out_mime_type == 0)) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
|
||||
if (fCurrentFile == 0) {
|
||||
PRINT("\t<- B_NO_INIT\n");
|
||||
return B_NO_INIT; // the input_ref isn't valid yet either
|
||||
@@ -427,11 +408,6 @@ status_t AbstractFileInterfaceNode::StaticSniffRef(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((out_mime_type == 0) || (out_quality == 0)) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
|
||||
BNode node(&file);
|
||||
status_t initCheck = node.InitCheck();
|
||||
if (initCheck != B_OK) {
|
||||
@@ -462,9 +438,6 @@ status_t AbstractFileInterfaceNode::GetParameterValue(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((last_change == 0) || (value == 0) || (ioSize == 0))
|
||||
return B_BAD_VALUE; // no crashing
|
||||
|
||||
switch (id) {
|
||||
case DEFAULT_CHUNK_SIZE_PARAM:
|
||||
if (*ioSize < sizeof(size_t)) {
|
||||
|
||||
@@ -62,10 +62,6 @@ status_t MediaDemultiplexerAddOn::GetFlavorAt(
|
||||
const flavor_info ** out_info)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerAddOn::GetFlavorAt\n");
|
||||
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) {
|
||||
fprintf(stderr,"<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
@@ -82,10 +78,6 @@ BMediaNode * MediaDemultiplexerAddOn::InstantiateNodeFor(
|
||||
status_t * out_error)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerAddOn::InstantiateNodeFor\n");
|
||||
if (out_error == 0) {
|
||||
fprintf(stderr,"<- NULL\n");
|
||||
return 0; // we refuse to crash because you were stupid
|
||||
}
|
||||
MediaDemultiplexerNode * node
|
||||
= new MediaDemultiplexerNode(info,config,this);
|
||||
if (node == 0) {
|
||||
@@ -102,10 +94,6 @@ status_t MediaDemultiplexerAddOn::GetConfigurationFor(
|
||||
BMessage * into_message)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerAddOn::GetConfigurationFor\n");
|
||||
if (into_message == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
MediaDemultiplexerNode * node
|
||||
= dynamic_cast<MediaDemultiplexerNode*>(your_node);
|
||||
if (node == 0) {
|
||||
|
||||
@@ -243,10 +243,6 @@ status_t MediaDemultiplexerNode::AcceptFormat(
|
||||
media_format * format)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerNode::AcceptFormat\n");
|
||||
if (format == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
if (input.destination != dest) {
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_DESTINATION");
|
||||
return B_MEDIA_BAD_DESTINATION; // we only have one input so that better be it
|
||||
@@ -268,21 +264,13 @@ status_t MediaDemultiplexerNode::GetNextInput(
|
||||
media_input * out_input)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerNode::GetNextInput\n");
|
||||
// let's not crash even if they are stupid
|
||||
if (out_input == 0) {
|
||||
// no place to write!
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (cookie != 0) {
|
||||
// it's valid but they already got our 1 input
|
||||
if (*cookie != 0) {
|
||||
fprintf(stderr,"<- B_ERROR (no more inputs)\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
// so next time they won't get the same input again
|
||||
*cookie = 1;
|
||||
if (*cookie != 0) {
|
||||
fprintf(stderr,"<- B_ERROR (no more inputs)\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// so next time they won't get the same input again
|
||||
*cookie = 1;
|
||||
*out_input = input;
|
||||
return B_OK;
|
||||
}
|
||||
@@ -372,10 +360,6 @@ status_t MediaDemultiplexerNode::Connected(
|
||||
media_input * out_input)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerNode::Connected\n");
|
||||
if (out_input == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
if (input.destination != where) {
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_DESTINATION\n");
|
||||
return B_MEDIA_BAD_DESTINATION;
|
||||
@@ -473,10 +457,6 @@ status_t MediaDemultiplexerNode::FormatSuggestionRequested(
|
||||
media_format * format)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerNode::FormatSuggestionRequested\n");
|
||||
if (format == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
// XXX: how do I pick which stream to supply here?....
|
||||
// answer?: get the first compatible stream that is available
|
||||
fprintf(stderr," format suggestion requested not implemented\n");
|
||||
@@ -544,12 +524,6 @@ status_t MediaDemultiplexerNode::GetNextOutput( /* cookie starts as 0 */
|
||||
media_output * out_output)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerNode::GetNextOutput\n");
|
||||
// let's not crash even if they are stupid
|
||||
if ((out_output == 0) || (cookie == 0)) {
|
||||
// no place to write!
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
// they want a clean start
|
||||
if (*cookie == 0) {
|
||||
*cookie = (int32)outputs.begin();
|
||||
@@ -637,10 +611,6 @@ status_t MediaDemultiplexerNode::PrepareToConnect(
|
||||
char * out_name)
|
||||
{
|
||||
fprintf(stderr,"MediaDemultiplexerNode::PrepareToConnect\n");
|
||||
if ((format == 0) || (out_source == 0) || (out_name == 0)) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashes...
|
||||
}
|
||||
// find the information for this output
|
||||
vector<MediaOutputInfo>::iterator itr;
|
||||
for(itr = outputs.begin() ; (itr != outputs.end()) ; itr++) {
|
||||
|
||||
@@ -53,10 +53,6 @@ status_t MediaOutputInfo::SetBufferGroup(BBufferGroup * group) {
|
||||
// that. We leave wildcards for anything that we don't care about.
|
||||
status_t MediaOutputInfo::FormatProposal(media_format * format)
|
||||
{
|
||||
if (format == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
// Be's format_is_compatible doesn't work,
|
||||
// so use our format_is_acceptible instead
|
||||
if (!format_is_acceptible(*format,generalFormat)) {
|
||||
@@ -75,10 +71,6 @@ status_t MediaOutputInfo::FormatProposal(media_format * format)
|
||||
status_t MediaOutputInfo::FormatChangeRequested(const media_destination & destination,
|
||||
media_format * io_format)
|
||||
{
|
||||
if (io_format == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
status_t status = FormatProposal(io_format);
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr,"<- MediaOutputInfo::FormatProposal failed\n");
|
||||
@@ -115,10 +107,6 @@ status_t MediaOutputInfo::Connect(const media_destination & destination,
|
||||
char * io_name,
|
||||
bigtime_t _downstreamLatency)
|
||||
{
|
||||
if (io_name == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
output.destination = destination;
|
||||
output.format = format;
|
||||
strncpy(io_name,output.name,B_MEDIA_NAME_LENGTH-1);
|
||||
|
||||
@@ -113,10 +113,6 @@ status_t ESDSinkAddOn::GetFlavorAt(
|
||||
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");
|
||||
@@ -139,14 +135,6 @@ BMediaNode * ESDSinkAddOn::InstantiateNodeFor(
|
||||
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) {
|
||||
@@ -173,7 +161,6 @@ ESDSinkAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_messag
|
||||
{
|
||||
CALLED();
|
||||
#ifdef MULTI_SAVE
|
||||
if (into_message == 0) {
|
||||
into_message = new BMessage();
|
||||
ESDSinkNode * node = dynamic_cast<ESDSinkNode*>(your_node);
|
||||
if (node == 0) {
|
||||
@@ -184,13 +171,9 @@ ESDSinkAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_messag
|
||||
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");
|
||||
|
||||
@@ -267,10 +267,6 @@ status_t ESDSinkNode::AcceptFormat(
|
||||
return B_MEDIA_BAD_DESTINATION; // we only have one input so that better be it
|
||||
}
|
||||
|
||||
if (format == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
/* media_format * myFormat = GetFormat();
|
||||
fprintf(stderr,"proposed format: ");
|
||||
print_media_format(format);
|
||||
@@ -316,12 +312,6 @@ status_t ESDSinkNode::GetNextInput(
|
||||
media_input * out_input)
|
||||
{
|
||||
CALLED();
|
||||
// let's not crash even if they are stupid
|
||||
if (out_input == 0) {
|
||||
// no place to write!
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
if ((*cookie < 1) && (*cookie >= 0)) {
|
||||
*out_input = fInput;
|
||||
@@ -436,10 +426,6 @@ status_t ESDSinkNode::Connected(
|
||||
media_input * out_input)
|
||||
{
|
||||
CALLED();
|
||||
if (out_input == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
|
||||
if(fInput.destination != where) {
|
||||
fprintf(stderr,"<- B_MEDIA_BAD_DESTINATION\n");
|
||||
@@ -1401,9 +1387,6 @@ ESDSinkNode::GetConfigurationFor(BMessage * into_message)
|
||||
bigtime_t last_change;
|
||||
status_t err;
|
||||
|
||||
if(!into_message)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
buffer = malloc(size);
|
||||
|
||||
for(int32 i=0; i<fWeb->CountParameters(); i++) {
|
||||
@@ -1438,9 +1421,6 @@ ESDSinkNode::GetConfigurationFor(BMessage * into_message)
|
||||
void ESDSinkNode::GetFlavor(flavor_info * outInfo, int32 id)
|
||||
{
|
||||
CALLED();
|
||||
if (outInfo == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
outInfo->flavor_flags = B_FLAVOR_IS_GLOBAL;
|
||||
// outInfo->possible_count = 0; // any number
|
||||
@@ -1475,9 +1455,7 @@ void ESDSinkNode::GetFlavor(flavor_info * outInfo, int32 id)
|
||||
void ESDSinkNode::GetFormat(media_format * outFormat)
|
||||
{
|
||||
CALLED();
|
||||
if (outFormat == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
outFormat->type = B_MEDIA_RAW_AUDIO;
|
||||
outFormat->require_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
|
||||
outFormat->deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
|
||||
|
||||
@@ -84,8 +84,6 @@ status_t
|
||||
MultiAudioAddOn::GetFlavorAt(int32 index, const flavor_info** _info)
|
||||
{
|
||||
CALLED();
|
||||
if (_info == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
MultiAudioDevice* device = (MultiAudioDevice*)fDevices.ItemAt(index);
|
||||
if (device == NULL)
|
||||
@@ -108,8 +106,6 @@ MultiAudioAddOn::InstantiateNodeFor(const flavor_info* info, BMessage* config,
|
||||
status_t* _error)
|
||||
{
|
||||
CALLED();
|
||||
if (_error == NULL)
|
||||
return NULL;
|
||||
|
||||
MultiAudioDevice* device = (MultiAudioDevice*)fDevices.ItemAt(
|
||||
info->internal_id);
|
||||
@@ -155,8 +151,6 @@ MultiAudioAddOn::GetConfigurationFor(BMediaNode* _node, BMessage* message)
|
||||
#endif
|
||||
|
||||
// currently never called by the media kit. Seems it is not implemented.
|
||||
if (message == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return node->GetConfigurationFor(message);
|
||||
}
|
||||
|
||||
@@ -98,10 +98,6 @@ status_t OpenSoundAddOn::GetFlavorAt(
|
||||
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) {
|
||||
fprintf(stderr, "<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
@@ -122,17 +118,7 @@ BMediaNode * OpenSoundAddOn::InstantiateNodeFor(
|
||||
status_t * out_error)
|
||||
{
|
||||
CALLED();
|
||||
if (out_error == 0) {
|
||||
fprintf(stderr, "<- NULL\n");
|
||||
return 0; // we refuse to crash because you were stupid
|
||||
}
|
||||
|
||||
BMessage fakeConfig;
|
||||
if (config == 0) {
|
||||
fprintf(stderr, "<- config == NULL\n");
|
||||
config = &fakeConfig; // we refuse to crash because you were stupid
|
||||
}
|
||||
|
||||
OpenSoundDevice *device = (OpenSoundDevice*)fDevices.ItemAt(info->internal_id);
|
||||
if (device == NULL) {
|
||||
*out_error = B_ERROR;
|
||||
@@ -165,7 +151,7 @@ OpenSoundAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_mess
|
||||
{
|
||||
CALLED();
|
||||
#ifdef MULTI_SAVE
|
||||
if (into_message == 0) {
|
||||
{
|
||||
into_message = new BMessage();
|
||||
OpenSoundNode * node = dynamic_cast<OpenSoundNode*>(your_node);
|
||||
if (node == 0) {
|
||||
@@ -179,10 +165,6 @@ OpenSoundAddOn::GetConfigurationFor(BMediaNode * your_node, BMessage * into_mess
|
||||
}
|
||||
#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
|
||||
}
|
||||
OpenSoundNode * node = dynamic_cast<OpenSoundNode*>(your_node);
|
||||
if (node == 0) {
|
||||
fprintf(stderr, "<- B_BAD_TYPE\n");
|
||||
|
||||
@@ -221,11 +221,6 @@ status_t MediaReader::FormatSuggestionRequested(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (format == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
|
||||
if ((type != B_MEDIA_MULTISTREAM) && (type != B_MEDIA_UNKNOWN_TYPE)) {
|
||||
PRINT("\t<- B_MEDIA_BAD_FORMAT\n");
|
||||
return B_MEDIA_BAD_FORMAT;
|
||||
@@ -246,10 +241,6 @@ status_t MediaReader::FormatProposal(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (format == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
if (output.source != output_source) {
|
||||
PRINT("\t<- B_MEDIA_BAD_SOURCE\n");
|
||||
return B_MEDIA_BAD_SOURCE; // we only have one output so that better be it
|
||||
@@ -286,10 +277,6 @@ status_t MediaReader::FormatChangeRequested(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (io_format == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashing
|
||||
}
|
||||
if (output.source != source) {
|
||||
PRINT("\t<- B_MEDIA_BAD_SOURCE\n");
|
||||
return B_MEDIA_BAD_SOURCE;
|
||||
@@ -311,21 +298,13 @@ status_t MediaReader::GetNextOutput( /* cookie starts as 0 */
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// let's not crash even if they are stupid
|
||||
if (out_output == 0) {
|
||||
// no place to write!
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (cookie != 0) {
|
||||
// it's valid but they already got our 1 output
|
||||
if (*cookie != 0) {
|
||||
PRINT("\t<- B_ERROR (no more outputs)\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
// so next time they won't get the same output again
|
||||
*cookie = 1;
|
||||
if (*cookie != 0) {
|
||||
PRINT("\t<- B_ERROR (no more outputs)\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// so next time they won't get the same output again
|
||||
*cookie = 1;
|
||||
*out_output = output;
|
||||
return B_OK;
|
||||
}
|
||||
@@ -417,10 +396,6 @@ status_t MediaReader::GetLatency(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (out_latency == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
*out_latency = EventLatency() + SchedulingLatency();
|
||||
return B_OK;
|
||||
}
|
||||
@@ -435,11 +410,6 @@ status_t MediaReader::PrepareToConnect(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if ((format == 0) || (out_source == 0) || (out_name == 0)) {
|
||||
PRINT("\ŧ<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // no crashes...
|
||||
}
|
||||
|
||||
if (output.source != what) {
|
||||
PRINT("\t<- B_MEDIA_BAD_SOURCE\n");
|
||||
return B_MEDIA_BAD_SOURCE;
|
||||
@@ -773,9 +743,6 @@ void MediaReader::GetFormat(media_format * outFormat)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (outFormat == 0)
|
||||
return;
|
||||
|
||||
AbstractFileInterfaceNode::GetFormat(outFormat);
|
||||
return;
|
||||
}
|
||||
@@ -785,9 +752,6 @@ void MediaReader::GetFileFormat(media_file_format * outFileFormat)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (outFileFormat == 0)
|
||||
return;
|
||||
|
||||
AbstractFileInterfaceNode::GetFileFormat(outFileFormat);
|
||||
outFileFormat->capabilities |= media_file_format::B_READABLE;
|
||||
return;
|
||||
|
||||
@@ -51,10 +51,6 @@ status_t MediaReaderAddOn::GetFlavorAt(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (out_info == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
if (n != 0) {
|
||||
PRINT("\t<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
@@ -74,11 +70,6 @@ BMediaNode * MediaReaderAddOn::InstantiateNodeFor(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (out_error == 0) {
|
||||
PRINT("\t<- NULL\n");
|
||||
return 0; // avoid crash
|
||||
}
|
||||
|
||||
// XXX: read from add-on's attributes
|
||||
size_t defaultChunkSize = size_t(8192); // 8192 bytes = 8 Kilobytes
|
||||
// = 2048 kilobits/millisec = 256000 Kilobytes/sec
|
||||
@@ -103,11 +94,6 @@ status_t MediaReaderAddOn::GetConfigurationFor(
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (into_message == 0) {
|
||||
PRINT("\t<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // avoid crash
|
||||
}
|
||||
|
||||
MediaReader * node
|
||||
= dynamic_cast<MediaReader*>(your_node);
|
||||
if (node == 0) {
|
||||
@@ -122,17 +108,6 @@ status_t MediaReaderAddOn::GetConfigurationFor(
|
||||
// BMediaAddOn impl for B_FILE_INTERFACE nodes
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
// This function treats null pointers slightly differently than the others.
|
||||
// This is because a program could reasonably call this function with just
|
||||
// about any junk, get the out_read_items or out_write_items and then use
|
||||
// that to create an array of sufficient size to hold the result, and then
|
||||
// call us again. So we won't punish them if they supply us with null
|
||||
// pointers the first time around.
|
||||
//
|
||||
// A stupid program might not supply an out_read_items, but actually supply
|
||||
// an out_readable_formats and then try to do something useful with it. As
|
||||
// an extreme gesture of nicety we will fill the out_readable_formats with
|
||||
// a valid entry, although they could easily read into garbage after that...
|
||||
status_t MediaReaderAddOn::GetFileFormatList(
|
||||
int32 flavor_id,
|
||||
media_file_format * out_writable_formats,
|
||||
@@ -150,20 +125,10 @@ status_t MediaReaderAddOn::GetFileFormatList(
|
||||
PRINT("\t<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_write_items != 0) {
|
||||
*out_write_items = 0;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_read_items != 0) {
|
||||
*out_read_items = 1;
|
||||
}
|
||||
if (out_readable_formats != 0) {
|
||||
// don't go off the end
|
||||
if (in_read_items > 0) {
|
||||
MediaReader::GetFileFormat(&out_readable_formats[0]);
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,6 @@ status_t MediaWriterAddOn::GetFlavorAt(
|
||||
const flavor_info ** out_info)
|
||||
{
|
||||
fprintf(stderr,"MediaWriterAddOn::GetFlavorAt\n");
|
||||
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) {
|
||||
fprintf(stderr,"<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
@@ -70,10 +66,6 @@ BMediaNode * MediaWriterAddOn::InstantiateNodeFor(
|
||||
status_t * out_error)
|
||||
{
|
||||
fprintf(stderr,"MediaWriterAddOn::InstantiateNodeFor\n");
|
||||
if (out_error == 0) {
|
||||
fprintf(stderr,"<- NULL\n");
|
||||
return 0; // we refuse to crash because you were stupid
|
||||
}
|
||||
size_t defaultChunkSize = size_t(8192); // XXX: read from add-on's attributes
|
||||
float defaultBitRate = 800000;
|
||||
MediaWriter * node
|
||||
@@ -94,10 +86,6 @@ status_t MediaWriterAddOn::GetConfigurationFor(
|
||||
BMessage * into_message)
|
||||
{
|
||||
fprintf(stderr,"MediaWriterAddOn::GetConfigurationFor\n");
|
||||
if (into_message == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
MediaWriter * node
|
||||
= dynamic_cast<MediaWriter*>(your_node);
|
||||
if (node == 0) {
|
||||
@@ -111,17 +99,6 @@ status_t MediaWriterAddOn::GetConfigurationFor(
|
||||
// BMediaAddOn impl for B_FILE_INTERFACE nodes
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
// This function treats null pointers slightly differently than the others.
|
||||
// This is because a program could reasonably call this function with just
|
||||
// about any junk, get the out_read_items or out_write_items and then use
|
||||
// that to create an array of sufficient size to hold the result, and then
|
||||
// call us again. So we won't punish them if they supply us with null
|
||||
// pointers the first time around.
|
||||
//
|
||||
// A stupid program might not supply an out_read_items, but actually supply
|
||||
// an out_readable_formats and then try to do something useful with it. As
|
||||
// an extreme gesture of nicety we will fill the out_readable_formats with
|
||||
// a valid entry, although they could easily read into garbage after that...
|
||||
status_t MediaWriterAddOn::GetFileFormatList(
|
||||
int32 flavor_id,
|
||||
media_file_format * out_writable_formats,
|
||||
@@ -138,20 +115,10 @@ status_t MediaWriterAddOn::GetFileFormatList(
|
||||
fprintf(stderr,"<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_write_items != 0) {
|
||||
*out_write_items = 0;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_read_items != 0) {
|
||||
*out_read_items = 1;
|
||||
}
|
||||
if (out_writable_formats != 0) {
|
||||
// don't go off the end
|
||||
if (in_write_items > 0) {
|
||||
MediaWriter::GetFileFormat(&out_writable_formats[0]);
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user