* Implemented ERROR as fprintf(stderr, ...) with tracing turned off as well.

* Fixed all but one compiler warnings in libmedia.so.
* Truncated lines to 80 char width where I looked at code.
* Turned printf()s into TRACE/ERROR calls in MediaExtractor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24478 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-03-19 19:39:07 +00:00
parent d14375b803
commit 4a46d818c9
6 changed files with 75 additions and 43 deletions

View File

@ -44,7 +44,7 @@
#define BROKEN() ((void)0)
#define CALLED() ((void)0)
#define PRINT(l, a...) ((void)0)
#define ERROR(a...) ((void)0)
#define ERROR(a...) fprintf(stderr, a)
#define TRACE(a...) ((void)0)
#endif

View File

@ -544,7 +544,9 @@ ContinuousMessageFilter::ContinuousMessageFilter(BControl *control,
float value[fParameter.CountChannels()];
size_t size = sizeof(value);
if (parameter.GetValue((void *)&value, &size, NULL) < B_OK) {
ERROR("ContinuousMessageFilter: Could not get value for continuous parameter %p (name '%s', node %d)\n", &parameter, parameter.Name(), parameter.Web()->Node().node);
ERROR("ContinuousMessageFilter: Could not get value for continuous "
"parameter %p (name '%s', node %d)\n", &parameter,
parameter.Name(), (int)(parameter.Web()->Node().node));
return;
}
@ -614,7 +616,9 @@ DiscreteMessageFilter::DiscreteMessageFilter(BControl *control,
size_t size = sizeof(int32);
int32 value;
if (parameter.GetValue((void *)&value, &size, NULL) < B_OK) {
ERROR("DiscreteMessageFilter: Could not get value for discrete parameter %p (name '%s', node %d)\n", &parameter, parameter.Name(), parameter.Web()->Node().node);
ERROR("DiscreteMessageFilter: Could not get value for discrete "
"parameter %p (name '%s', node %d)\n", &parameter,
parameter.Name(), (int)(parameter.Web()->Node().node));
return;
}
@ -1033,7 +1037,8 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
}
default:
ERROR("BMediaTheme: Don't know parameter type: 0x%lx\n", parameter->Type());
ERROR("BMediaTheme: Don't know parameter type: 0x%x\n",
parameter->Type());
}
return NULL;
}

View File

@ -517,12 +517,14 @@ multistream_format_specialize(media_multistream_format *format, const media_mult
break;
default:
ERROR("media_format::SpecializeTo can't specialize media_multistream_format of format %d\n", format->format);
ERROR("media_format::SpecializeTo can't specialize "
"media_multistream_format of format %ld\n", format->format);
}
}
static void
encoded_audio_format_specialize(media_encoded_audio_format *format, const media_encoded_audio_format *other)
encoded_audio_format_specialize(media_encoded_audio_format *format,
const media_encoded_audio_format *other)
{
raw_audio_format_specialize(&format->output, &other->output);
if (format->encoding == 0)
@ -535,7 +537,8 @@ encoded_audio_format_specialize(media_encoded_audio_format *format, const media_
}
static void
encoded_video_format_specialize(media_encoded_video_format *format, const media_encoded_video_format *other)
encoded_video_format_specialize(media_encoded_video_format *format,
const media_encoded_video_format *other)
{
raw_video_format_specialize(&format->output, &other->output);
if (format->avg_bit_rate == 0)

View File

@ -42,7 +42,8 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
fStreamInfo[i].infoBuffer = 0;
fStreamInfo[i].infoBufferSize = 0;
fStreamInfo[i].chunkCache = new ChunkCache;
memset(&fStreamInfo[i].encodedFormat, 0, sizeof(fStreamInfo[i].encodedFormat));
memset(&fStreamInfo[i].encodedFormat, 0,
sizeof(fStreamInfo[i].encodedFormat));
}
// create all stream cookies
@ -51,7 +52,8 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
fStreamInfo[i].cookie = 0;
fStreamInfo[i].hasCookie = false;
fStreamInfo[i].status = B_ERROR;
printf("MediaExtractor::MediaExtractor: AllocateCookie for stream %ld failed\n", i);
ERROR("MediaExtractor::MediaExtractor: AllocateCookie for stream "
"%ld failed\n", i);
}
}
@ -61,19 +63,20 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
continue;
int64 frameCount;
bigtime_t duration;
if (B_OK != fReader->GetStreamInfo(fStreamInfo[i].cookie, &frameCount, &duration,
&fStreamInfo[i].encodedFormat,
&fStreamInfo[i].infoBuffer,
&fStreamInfo[i].infoBufferSize)) {
if (B_OK != fReader->GetStreamInfo(fStreamInfo[i].cookie, &frameCount,
&duration, &fStreamInfo[i].encodedFormat,
&fStreamInfo[i].infoBuffer, &fStreamInfo[i].infoBufferSize)) {
fStreamInfo[i].status = B_ERROR;
printf("MediaExtractor::MediaExtractor: GetStreamInfo for stream %ld failed\n", i);
ERROR("MediaExtractor::MediaExtractor: GetStreamInfo for "
"stream %ld failed\n", i);
}
}
#if DISABLE_CHUNK_CACHE == 0
// start extractor thread
fExtractorWaitSem = create_sem(1, "media extractor thread sem");
fExtractorThread = spawn_thread(extractor_thread, "media extractor thread", 10, this);
fExtractorThread = spawn_thread(extractor_thread, "media extractor thread",
10, this);
resume_thread(fExtractorThread);
#endif
}
@ -146,7 +149,8 @@ MediaExtractor::CountFrames(int32 stream) const
const void *infoBuffer;
size_t infoSize;
fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration, &format, &infoBuffer, &infoSize);
fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration,
&format, &infoBuffer, &infoSize);
return frameCount;
}
@ -162,7 +166,8 @@ MediaExtractor::Duration(int32 stream) const
const void *infoBuffer;
size_t infoSize;
fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration, &format, &infoBuffer, &infoSize);
fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration,
&format, &infoBuffer, &infoSize);
return duration;
}
@ -200,18 +205,19 @@ MediaExtractor::GetNextChunk(int32 stream,
#if DISABLE_CHUNK_CACHE > 0
static BLocker locker;
BAutolock lock(locker);
return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer, chunkSize, mediaHeader);
return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer,
chunkSize, mediaHeader);
#endif
status_t err;
err = fStreamInfo[stream].chunkCache->GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
err = fStreamInfo[stream].chunkCache->GetNextChunk(chunkBuffer, chunkSize,
mediaHeader);
release_sem(fExtractorWaitSem);
return err;
}
class MediaExtractorChunkProvider : public ChunkProvider
{
class MediaExtractorChunkProvider : public ChunkProvider {
private:
MediaExtractor * fExtractor;
int32 fStream;
@ -225,13 +231,15 @@ public:
virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
media_header *mediaHeader)
{
return fExtractor->GetNextChunk(fStream, chunkBuffer, chunkSize, mediaHeader);
return fExtractor->GetNextChunk(fStream, chunkBuffer, chunkSize,
mediaHeader);
}
};
status_t
MediaExtractor::CreateDecoder(int32 stream, Decoder **out_decoder, media_codec_info *mci)
MediaExtractor::CreateDecoder(int32 stream, Decoder **out_decoder,
media_codec_info *mci)
{
CALLED();
status_t res;
@ -239,36 +247,44 @@ MediaExtractor::CreateDecoder(int32 stream, Decoder **out_decoder, media_codec_i
res = fStreamInfo[stream].status;
if (res != B_OK) {
printf("MediaExtractor::CreateDecoder can't create decoder for stream %ld\n", stream);
ERROR("MediaExtractor::CreateDecoder can't create decoder for "
"stream %ld\n", stream);
return res;
}
res = _plugin_manager.CreateDecoder(&decoder, fStreamInfo[stream].encodedFormat);
res = _plugin_manager.CreateDecoder(&decoder,
fStreamInfo[stream].encodedFormat);
if (res != B_OK) {
printf("MediaExtractor::CreateDecoder _plugin_manager.CreateDecoder failed for stream %ld\n", stream);
ERROR("MediaExtractor::CreateDecoder _plugin_manager.CreateDecoder "
"failed for stream %ld\n", stream);
return res;
}
ChunkProvider *chunkProvider = new(std::nothrow) MediaExtractorChunkProvider(this, stream);
ChunkProvider *chunkProvider
= new(std::nothrow) MediaExtractorChunkProvider(this, stream);
if (!chunkProvider) {
_plugin_manager.DestroyDecoder(decoder);
printf("MediaExtractor::CreateDecoder can't create chunk provider for stream %ld\n", stream);
ERROR("MediaExtractor::CreateDecoder can't create chunk provider "
"for stream %ld\n", stream);
return B_NO_MEMORY;
}
decoder->SetChunkProvider(chunkProvider);
res = decoder->Setup(&fStreamInfo[stream].encodedFormat, fStreamInfo[stream].infoBuffer, fStreamInfo[stream].infoBufferSize);
res = decoder->Setup(&fStreamInfo[stream].encodedFormat,
fStreamInfo[stream].infoBuffer, fStreamInfo[stream].infoBufferSize);
if (res != B_OK) {
_plugin_manager.DestroyDecoder(decoder);
printf("MediaExtractor::CreateDecoder Setup failed for stream %ld: %ld (%s)\n", stream, res, strerror(res));
ERROR("MediaExtractor::CreateDecoder Setup failed for stream %ld: "
"%ld (%s)\n", stream, res, strerror(res));
return res;
}
res = _plugin_manager.GetDecoderInfo(decoder, mci);
if (res != B_OK) {
_plugin_manager.DestroyDecoder(decoder);
printf("MediaExtractor::CreateDecoder GetCodecInfo failed for stream %ld: %ld (%s)\n", stream, res, strerror(res));
ERROR("MediaExtractor::CreateDecoder GetCodecInfo failed for stream "
"%ld: %ld (%s)\n", stream, res, strerror(res));
return res;
}
@ -304,8 +320,10 @@ MediaExtractor::ExtractorThread()
const void *chunkBuffer;
size_t chunkSize;
status_t err;
err = fReader->GetNextChunk(fStreamInfo[stream].cookie, &chunkBuffer, &chunkSize, &mediaHeader);
fStreamInfo[stream].chunkCache->PutNextChunk(chunkBuffer, chunkSize, mediaHeader, err);
err = fReader->GetNextChunk(fStreamInfo[stream].cookie,
&chunkBuffer, &chunkSize, &mediaHeader);
fStreamInfo[stream].chunkCache->PutNextChunk(chunkBuffer,
chunkSize, mediaHeader, err);
refill_done = true;
}
}

View File

@ -370,17 +370,20 @@ BMediaFormats::GetFormatFor(const media_format_description &description,
status_t status = update_media_formats();
if (status < B_OK) {
printf("BMediaFormats: updating formats from server failed: %s!\n", strerror(status));
ERROR("BMediaFormats: updating formats from server failed: %s!\n",
strerror(status));
return status;
}
printf("search for description family = %d, a = 0x%lx, b = 0x%lx\n",
description.family, description.u.misc.file_format, description.u.misc.codec);
TRACE("search for description family = %d, a = 0x%lx, b = 0x%lx\n",
description.family, description.u.misc.file_format,
description.u.misc.codec);
// search for a matching format description
meta_format other(description);
const meta_format *metaFormat = sFormats.BinarySearch(other, meta_format::CompareDescriptions);
printf("meta format == %p\n", metaFormat);
const meta_format *metaFormat = sFormats.BinarySearch(other,
meta_format::CompareDescriptions);
TRACE("meta format == %p\n", metaFormat);
if (metaFormat == NULL) {
memset(_format, 0, sizeof(*_format)); // clear to widlcard
return B_MEDIA_BAD_FORMAT;

View File

@ -1256,13 +1256,15 @@ BParameterGroup::MakeControl(int32 type)
return new BNullParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL);
case BParameter::B_DISCRETE_PARAMETER:
return new BDiscreteParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL);
return new BDiscreteParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL,
NULL);
case BParameter::B_CONTINUOUS_PARAMETER:
return new BContinuousParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL, NULL, 0, 0, 0);
return new BContinuousParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL,
NULL, NULL, 0, 0, 0);
case BParameter::B_TEXT_PARAMETER:
return new BTextParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL, NULL);
return new BTextParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL, 0);
default:
ERROR("BParameterGroup::MakeControl unknown type %ld\n", type);
@ -1401,8 +1403,9 @@ BParameter::GetValue(void *buffer, size_t *_ioSize, bigtime_t *_when)
if (_when != NULL)
*_when = reply.last_change;
} else
ERROR("BParameter::GetValue parameter '%s' querying node %d, port %d failed: %s\n",
mName, node.node, node.port, strerror(status));
ERROR("BParameter::GetValue parameter '%s' querying node %d, "
"port %d failed: %s\n", mName, (int)node.node, (int)node.port,
strerror(status));
if (area >= B_OK)
delete_area(area);