* 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:
@@ -44,7 +44,7 @@
|
|||||||
#define BROKEN() ((void)0)
|
#define BROKEN() ((void)0)
|
||||||
#define CALLED() ((void)0)
|
#define CALLED() ((void)0)
|
||||||
#define PRINT(l, a...) ((void)0)
|
#define PRINT(l, a...) ((void)0)
|
||||||
#define ERROR(a...) ((void)0)
|
#define ERROR(a...) fprintf(stderr, a)
|
||||||
#define TRACE(a...) ((void)0)
|
#define TRACE(a...) ((void)0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -544,7 +544,9 @@ ContinuousMessageFilter::ContinuousMessageFilter(BControl *control,
|
|||||||
float value[fParameter.CountChannels()];
|
float value[fParameter.CountChannels()];
|
||||||
size_t size = sizeof(value);
|
size_t size = sizeof(value);
|
||||||
if (parameter.GetValue((void *)&value, &size, NULL) < B_OK) {
|
if (parameter.GetValue((void *)&value, &size, NULL) < B_OK) {
|
||||||
ERROR("ContinuousMessageFilter: Could not get value for continuous parameter %p (name '%s', node %d)\n", ¶meter, parameter.Name(), parameter.Web()->Node().node);
|
ERROR("ContinuousMessageFilter: Could not get value for continuous "
|
||||||
|
"parameter %p (name '%s', node %d)\n", ¶meter,
|
||||||
|
parameter.Name(), (int)(parameter.Web()->Node().node));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +616,9 @@ DiscreteMessageFilter::DiscreteMessageFilter(BControl *control,
|
|||||||
size_t size = sizeof(int32);
|
size_t size = sizeof(int32);
|
||||||
int32 value;
|
int32 value;
|
||||||
if (parameter.GetValue((void *)&value, &size, NULL) < B_OK) {
|
if (parameter.GetValue((void *)&value, &size, NULL) < B_OK) {
|
||||||
ERROR("DiscreteMessageFilter: Could not get value for discrete parameter %p (name '%s', node %d)\n", ¶meter, parameter.Name(), parameter.Web()->Node().node);
|
ERROR("DiscreteMessageFilter: Could not get value for discrete "
|
||||||
|
"parameter %p (name '%s', node %d)\n", ¶meter,
|
||||||
|
parameter.Name(), (int)(parameter.Web()->Node().node));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1033,7 +1037,8 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -517,12 +517,14 @@ multistream_format_specialize(media_multistream_format *format, const media_mult
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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
|
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);
|
raw_audio_format_specialize(&format->output, &other->output);
|
||||||
if (format->encoding == 0)
|
if (format->encoding == 0)
|
||||||
@@ -535,7 +537,8 @@ encoded_audio_format_specialize(media_encoded_audio_format *format, const media_
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
raw_video_format_specialize(&format->output, &other->output);
|
||||||
if (format->avg_bit_rate == 0)
|
if (format->avg_bit_rate == 0)
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
|
|||||||
fStreamInfo[i].infoBuffer = 0;
|
fStreamInfo[i].infoBuffer = 0;
|
||||||
fStreamInfo[i].infoBufferSize = 0;
|
fStreamInfo[i].infoBufferSize = 0;
|
||||||
fStreamInfo[i].chunkCache = new ChunkCache;
|
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
|
// create all stream cookies
|
||||||
@@ -51,7 +52,8 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
|
|||||||
fStreamInfo[i].cookie = 0;
|
fStreamInfo[i].cookie = 0;
|
||||||
fStreamInfo[i].hasCookie = false;
|
fStreamInfo[i].hasCookie = false;
|
||||||
fStreamInfo[i].status = B_ERROR;
|
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;
|
continue;
|
||||||
int64 frameCount;
|
int64 frameCount;
|
||||||
bigtime_t duration;
|
bigtime_t duration;
|
||||||
if (B_OK != fReader->GetStreamInfo(fStreamInfo[i].cookie, &frameCount, &duration,
|
if (B_OK != fReader->GetStreamInfo(fStreamInfo[i].cookie, &frameCount,
|
||||||
&fStreamInfo[i].encodedFormat,
|
&duration, &fStreamInfo[i].encodedFormat,
|
||||||
&fStreamInfo[i].infoBuffer,
|
&fStreamInfo[i].infoBuffer, &fStreamInfo[i].infoBufferSize)) {
|
||||||
&fStreamInfo[i].infoBufferSize)) {
|
|
||||||
fStreamInfo[i].status = B_ERROR;
|
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
|
#if DISABLE_CHUNK_CACHE == 0
|
||||||
// start extractor thread
|
// start extractor thread
|
||||||
fExtractorWaitSem = create_sem(1, "media extractor thread sem");
|
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);
|
resume_thread(fExtractorThread);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -146,7 +149,8 @@ MediaExtractor::CountFrames(int32 stream) const
|
|||||||
const void *infoBuffer;
|
const void *infoBuffer;
|
||||||
size_t infoSize;
|
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;
|
return frameCount;
|
||||||
}
|
}
|
||||||
@@ -162,7 +166,8 @@ MediaExtractor::Duration(int32 stream) const
|
|||||||
const void *infoBuffer;
|
const void *infoBuffer;
|
||||||
size_t infoSize;
|
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;
|
return duration;
|
||||||
}
|
}
|
||||||
@@ -200,18 +205,19 @@ MediaExtractor::GetNextChunk(int32 stream,
|
|||||||
#if DISABLE_CHUNK_CACHE > 0
|
#if DISABLE_CHUNK_CACHE > 0
|
||||||
static BLocker locker;
|
static BLocker locker;
|
||||||
BAutolock lock(locker);
|
BAutolock lock(locker);
|
||||||
return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer, chunkSize, mediaHeader);
|
return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer,
|
||||||
|
chunkSize, mediaHeader);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status_t err;
|
status_t err;
|
||||||
err = fStreamInfo[stream].chunkCache->GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
|
err = fStreamInfo[stream].chunkCache->GetNextChunk(chunkBuffer, chunkSize,
|
||||||
|
mediaHeader);
|
||||||
release_sem(fExtractorWaitSem);
|
release_sem(fExtractorWaitSem);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MediaExtractorChunkProvider : public ChunkProvider
|
class MediaExtractorChunkProvider : public ChunkProvider {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
MediaExtractor * fExtractor;
|
MediaExtractor * fExtractor;
|
||||||
int32 fStream;
|
int32 fStream;
|
||||||
@@ -225,13 +231,15 @@ public:
|
|||||||
virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
|
virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
|
||||||
media_header *mediaHeader)
|
media_header *mediaHeader)
|
||||||
{
|
{
|
||||||
return fExtractor->GetNextChunk(fStream, chunkBuffer, chunkSize, mediaHeader);
|
return fExtractor->GetNextChunk(fStream, chunkBuffer, chunkSize,
|
||||||
|
mediaHeader);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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();
|
CALLED();
|
||||||
status_t res;
|
status_t res;
|
||||||
@@ -239,36 +247,44 @@ MediaExtractor::CreateDecoder(int32 stream, Decoder **out_decoder, media_codec_i
|
|||||||
|
|
||||||
res = fStreamInfo[stream].status;
|
res = fStreamInfo[stream].status;
|
||||||
if (res != B_OK) {
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _plugin_manager.CreateDecoder(&decoder, fStreamInfo[stream].encodedFormat);
|
res = _plugin_manager.CreateDecoder(&decoder,
|
||||||
|
fStreamInfo[stream].encodedFormat);
|
||||||
if (res != B_OK) {
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkProvider *chunkProvider = new(std::nothrow) MediaExtractorChunkProvider(this, stream);
|
ChunkProvider *chunkProvider
|
||||||
|
= new(std::nothrow) MediaExtractorChunkProvider(this, stream);
|
||||||
if (!chunkProvider) {
|
if (!chunkProvider) {
|
||||||
_plugin_manager.DestroyDecoder(decoder);
|
_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;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder->SetChunkProvider(chunkProvider);
|
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) {
|
if (res != B_OK) {
|
||||||
_plugin_manager.DestroyDecoder(decoder);
|
_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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _plugin_manager.GetDecoderInfo(decoder, mci);
|
res = _plugin_manager.GetDecoderInfo(decoder, mci);
|
||||||
if (res != B_OK) {
|
if (res != B_OK) {
|
||||||
_plugin_manager.DestroyDecoder(decoder);
|
_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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,8 +320,10 @@ MediaExtractor::ExtractorThread()
|
|||||||
const void *chunkBuffer;
|
const void *chunkBuffer;
|
||||||
size_t chunkSize;
|
size_t chunkSize;
|
||||||
status_t err;
|
status_t err;
|
||||||
err = fReader->GetNextChunk(fStreamInfo[stream].cookie, &chunkBuffer, &chunkSize, &mediaHeader);
|
err = fReader->GetNextChunk(fStreamInfo[stream].cookie,
|
||||||
fStreamInfo[stream].chunkCache->PutNextChunk(chunkBuffer, chunkSize, mediaHeader, err);
|
&chunkBuffer, &chunkSize, &mediaHeader);
|
||||||
|
fStreamInfo[stream].chunkCache->PutNextChunk(chunkBuffer,
|
||||||
|
chunkSize, mediaHeader, err);
|
||||||
refill_done = true;
|
refill_done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,17 +370,20 @@ BMediaFormats::GetFormatFor(const media_format_description &description,
|
|||||||
|
|
||||||
status_t status = update_media_formats();
|
status_t status = update_media_formats();
|
||||||
if (status < B_OK) {
|
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;
|
return status;
|
||||||
}
|
}
|
||||||
printf("search for description family = %d, a = 0x%lx, b = 0x%lx\n",
|
TRACE("search for description family = %d, a = 0x%lx, b = 0x%lx\n",
|
||||||
description.family, description.u.misc.file_format, description.u.misc.codec);
|
description.family, description.u.misc.file_format,
|
||||||
|
description.u.misc.codec);
|
||||||
|
|
||||||
// search for a matching format description
|
// search for a matching format description
|
||||||
|
|
||||||
meta_format other(description);
|
meta_format other(description);
|
||||||
const meta_format *metaFormat = sFormats.BinarySearch(other, meta_format::CompareDescriptions);
|
const meta_format *metaFormat = sFormats.BinarySearch(other,
|
||||||
printf("meta format == %p\n", metaFormat);
|
meta_format::CompareDescriptions);
|
||||||
|
TRACE("meta format == %p\n", metaFormat);
|
||||||
if (metaFormat == NULL) {
|
if (metaFormat == NULL) {
|
||||||
memset(_format, 0, sizeof(*_format)); // clear to widlcard
|
memset(_format, 0, sizeof(*_format)); // clear to widlcard
|
||||||
return B_MEDIA_BAD_FORMAT;
|
return B_MEDIA_BAD_FORMAT;
|
||||||
|
|||||||
@@ -1256,13 +1256,15 @@ BParameterGroup::MakeControl(int32 type)
|
|||||||
return new BNullParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL);
|
return new BNullParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL);
|
||||||
|
|
||||||
case BParameter::B_DISCRETE_PARAMETER:
|
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:
|
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:
|
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:
|
default:
|
||||||
ERROR("BParameterGroup::MakeControl unknown type %ld\n", type);
|
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)
|
if (_when != NULL)
|
||||||
*_when = reply.last_change;
|
*_when = reply.last_change;
|
||||||
} else
|
} else
|
||||||
ERROR("BParameter::GetValue parameter '%s' querying node %d, port %d failed: %s\n",
|
ERROR("BParameter::GetValue parameter '%s' querying node %d, "
|
||||||
mName, node.node, node.port, strerror(status));
|
"port %d failed: %s\n", mName, (int)node.node, (int)node.port,
|
||||||
|
strerror(status));
|
||||||
|
|
||||||
if (area >= B_OK)
|
if (area >= B_OK)
|
||||||
delete_area(area);
|
delete_area(area);
|
||||||
|
|||||||
Reference in New Issue
Block a user