MediaPlayer: some 64 bit fixes

This commit is contained in:
Jérôme Duval 2013-05-04 11:15:41 +02:00
parent b01fc26d76
commit 843a122fd9
17 changed files with 60 additions and 48 deletions

View File

@ -146,6 +146,9 @@ typedef generic_addr_t generic_size_t;
/* time_t */ /* time_t */
#define B_PRIdTIME B_PRId32 #define B_PRIdTIME B_PRId32
#define B_PRIiTIME B_PRIi32 #define B_PRIiTIME B_PRIi32
/* bigtime_t */
#define B_PRIdBIGTIME B_PRId64
#define B_PRIiBIGTIME B_PRIi64
/* Printed width of a pointer with the %p format (minus 0x prefix). */ /* Printed width of a pointer with the %p format (minus 0x prefix). */

View File

@ -293,7 +293,7 @@ InfoWin::ResizeToPreferred()
void void
InfoWin::Update(uint32 which) InfoWin::Update(uint32 which)
{ {
printf("InfoWin::Update(0x%08lx)\n", which); printf("InfoWin::Update(0x%08" B_PRIx32 ")\n", which);
fLabelsView->SetText(""); fLabelsView->SetText("");
fContentsView->SetText(""); fContentsView->SetText("");
fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue); fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue);

View File

@ -1529,7 +1529,7 @@ MainWin::_CreateMenu()
fAttributesMenu->AddItem(fRatingMenu); fAttributesMenu->AddItem(fRatingMenu);
for (int32 i = 1; i <= 10; i++) { for (int32 i = 1; i <= 10; i++) {
char label[16]; char label[16];
snprintf(label, sizeof(label), "%ld", i); snprintf(label, sizeof(label), "%" B_PRId32, i);
BMessage* setRatingMsg = new BMessage(M_SET_RATING); BMessage* setRatingMsg = new BMessage(M_SET_RATING);
setRatingMsg->AddInt32("rating", i); setRatingMsg->AddInt32("rating", i);
fRatingMenu->AddItem(new BMenuItem(label, setRatingMsg)); fRatingMenu->AddItem(new BMenuItem(label, setRatingMsg));
@ -1541,7 +1541,7 @@ void
MainWin::_SetupVideoAspectItems(BMenu* menu) MainWin::_SetupVideoAspectItems(BMenu* menu)
{ {
BMenuItem* item; BMenuItem* item;
while ((item = menu->RemoveItem(0L)) != NULL) while ((item = menu->RemoveItem((int32)0)) != NULL)
delete item; delete item;
int width; int width;
@ -2440,7 +2440,7 @@ MainWin::_UpdatePlaylistItemFile()
int32 bitrate = (int32)(format.u.encoded_audio.bit_rate int32 bitrate = (int32)(format.u.encoded_audio.bit_rate
/ 1000); / 1000);
char text[256]; char text[256];
snprintf(text, sizeof(text), "%ld kbit", bitrate); snprintf(text, sizeof(text), "%" B_PRId32 " kbit", bitrate);
node.WriteAttr("Audio:Bitrate", B_STRING_TYPE, 0, text, node.WriteAttr("Audio:Bitrate", B_STRING_TYPE, 0, text,
strlen(text) + 1); strlen(text) + 1);
} }
@ -2457,7 +2457,7 @@ MainWin::_UpdatePlaylistItemFile()
int32 bitrate = (int32)(format.u.encoded_video.avg_bit_rate int32 bitrate = (int32)(format.u.encoded_video.avg_bit_rate
/ 1000); / 1000);
char text[256]; char text[256];
snprintf(text, sizeof(text), "%ld kbit", bitrate); snprintf(text, sizeof(text), "%" B_PRId32 " kbit", bitrate);
node.WriteAttr("Video:Bitrate", B_STRING_TYPE, 0, text, node.WriteAttr("Video:Bitrate", B_STRING_TYPE, 0, text,
strlen(text) + 1); strlen(text) + 1);
} }

View File

@ -118,8 +118,8 @@ NodeManager::SetPlayMode(int32 mode, bool continuePlaying)
status_t ret = fMediaRoster->SetRunModeNode(fVideoConnection.consumer, status_t ret = fMediaRoster->SetRunModeNode(fVideoConnection.consumer,
runMode); runMode);
if (ret != B_OK) { if (ret != B_OK) {
printf("NodeManager::SetPlayMode(%ld), setting run mode failed: " printf("NodeManager::SetPlayMode(%" B_PRId32 "), setting run mode "
"%s\n", mode, strerror(ret)); "failed: %s\n", mode, strerror(ret));
} }
fMediaRoster->Unlock(); fMediaRoster->Unlock();
} }

View File

@ -817,7 +817,7 @@ AudioProducer::_FillNextBuffer(bigtime_t eventTime)
static bool errorPrinted = false; static bool errorPrinted = false;
if (!errorPrinted) { if (!errorPrinted) {
ERROR("AudioProducer::_FillNextBuffer() - no buffer " ERROR("AudioProducer::_FillNextBuffer() - no buffer "
"(size: %ld, duration: %lld)\n", "(size: %" B_PRIuSIZE ", duration: %" B_PRIiBIGTIME ")\n",
fOutput.format.u.raw_audio.buffer_size, BufferDuration()); fOutput.format.u.raw_audio.buffer_size, BufferDuration());
errorPrinted = true; errorPrinted = true;
} }

View File

@ -86,7 +86,7 @@ VideoConsumer::~VideoConsumer()
BMediaAddOn* BMediaAddOn*
VideoConsumer::AddOn(long* cookie) const VideoConsumer::AddOn(int32* cookie) const
{ {
FUNCTION("VideoConsumer::AddOn\n"); FUNCTION("VideoConsumer::AddOn\n");
// do the right thing if we're ever used with an add-on // do the right thing if we're ever used with an add-on
@ -239,7 +239,7 @@ VideoConsumer::CreateBuffers(const media_format& format)
BBuffer* buffer = NULL; BBuffer* buffer = NULL;
if ((status = fBuffers->AddBuffer(info, &buffer)) != B_OK) { if ((status = fBuffers->AddBuffer(info, &buffer)) != B_OK) {
ERROR("VideoConsumer::CreateBuffers - ERROR ADDING BUFFER " ERROR("VideoConsumer::CreateBuffers - ERROR ADDING BUFFER "
"TO GROUP (%ld): %s\n", i, strerror(status)); "TO GROUP (%" B_PRId32 "): %s\n", i, strerror(status));
return status; return status;
} else { } else {
PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD " PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD "
@ -248,8 +248,9 @@ VideoConsumer::CreateBuffers(const media_format& format)
fBufferMap[i] = buffer; fBufferMap[i] = buffer;
} else { } else {
ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING " ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING "
"BUFFER (Index %ld Width %ld Height %ld Colorspace %d: %s\n", "BUFFER (Index %" B_PRId32 " Width %" B_PRId32 " Height %"
i, width, height, colorSpace, strerror(status)); B_PRId32 " Colorspace %d: %s\n", i, width, height, colorSpace,
strerror(status));
return status; return status;
} }
} }

View File

@ -36,7 +36,7 @@ public:
// BMediaNode interface // BMediaNode interface
public: public:
virtual BMediaAddOn* AddOn(long* cookie) const; virtual BMediaAddOn* AddOn(int32* cookie) const;
protected: protected:
virtual void NodeRegistered(); virtual void NodeRegistered();
@ -100,7 +100,7 @@ private:
void _UnsetTargetBuffer(); void _UnsetTargetBuffer();
private: private:
uint32 fInternalID; int32 fInternalID;
BMediaAddOn* fAddOn; BMediaAddOn* fAddOn;
bool fConnectionActive; bool fConnectionActive;

View File

@ -697,8 +697,10 @@ VideoProducer::_FrameGeneratorThread()
&& nextWaitUntil < system_time() - fBufferLatency && nextWaitUntil < system_time() - fBufferLatency
&& droppedFrames < kMaxDroppedFrames) { && droppedFrames < kMaxDroppedFrames) {
// Drop frame if it's at least a frame late. // Drop frame if it's at least a frame late.
if (playingDirection > 0) if (playingDirection > 0) {
printf("VideoProducer: dropped frame (%Ld)\n", fFrame); printf("VideoProducer: dropped frame (%" B_PRId64
")\n", fFrame);
}
// next frame // next frame
droppedFrames++; droppedFrames++;
fFrame++; fFrame++;

View File

@ -559,8 +559,10 @@ Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist)
= new (std::nothrow) FilePlaylistItem(refPath); = new (std::nothrow) FilePlaylistItem(refPath);
if (item == NULL || !playlist->AddItem(item)) if (item == NULL || !playlist->AddItem(item))
delete item; delete item;
} else } else {
printf("Error - %s: [%lx]\n", strerror(err), (int32) err); printf("Error - %s: [%" B_PRIx32 "]\n", strerror(err),
err);
}
} else } else
printf("Error - No File Found in playlist\n"); printf("Error - No File Found in playlist\n");
} }

View File

@ -143,7 +143,7 @@ MediaTrackAudioSupplier::Read(void* buffer, int64 pos, int64 frames)
pos += fOutOffset; pos += fOutOffset;
// Fill the frames after the end of the track with silence. // Fill the frames after the end of the track with silence.
if (fCountFrames > 0 && pos + frames > fCountFrames) { if (fCountFrames > 0 && pos + frames > fCountFrames) {
int64 size = max(0LL, fCountFrames - pos); int64 size = max((int64)0, fCountFrames - pos);
ReadSilence(SkipFrames(buffer, size), frames - size); ReadSilence(SkipFrames(buffer, size), frames - size);
frames = size; frames = size;
} }
@ -276,10 +276,10 @@ MediaTrackAudioSupplier::_InitFromTrack()
// get the length of the track // get the length of the track
fCountFrames = fMediaTrack->CountFrames(); fCountFrames = fMediaTrack->CountFrames();
TRACE("_InitFromTrack(): keyframes: %d, frame count: %lld\n", TRACE("_InitFromTrack(): keyframes: %" B_PRId16 ", frame count: %" B_PRId64
fHasKeyFrames, fCountFrames); "\n", fHasKeyFrames, fCountFrames);
printf("_InitFromTrack(): keyframes: %d, frame count: %lld\n", printf("_InitFromTrack(): keyframes: %" B_PRId16 ", frame count: %"
fHasKeyFrames, fCountFrames); B_PRId64 "\n", fHasKeyFrames, fCountFrames);
} }
// _FramesPerBuffer // _FramesPerBuffer
@ -698,9 +698,9 @@ MediaTrackAudioSupplier::_SeekToKeyFrameBackward(int64& position)
if (error != B_OK) { if (error != B_OK) {
position = fMediaTrack->CurrentFrame(); position = fMediaTrack->CurrentFrame();
// if (fReportSeekError) { // if (fReportSeekError) {
printf(" seek to key frame backward: %lld -> %lld (%lld) " printf(" seek to key frame backward: %" B_PRId64 " -> %"
"- %s\n", wantedPosition, position, B_PRId64 " (%" B_PRId64 ") - %s\n", wantedPosition,
fMediaTrack->CurrentFrame(), strerror(error)); position, fMediaTrack->CurrentFrame(), strerror(error));
fReportSeekError = false; fReportSeekError = false;
// } // }
} else { } else {

View File

@ -169,8 +169,10 @@ bigtime_t _performanceTime = *performanceTime;
ret = fVideoTrack->SeekToTime(performanceTime); ret = fVideoTrack->SeekToTime(performanceTime);
if (ret == B_OK) { if (ret == B_OK) {
if (_performanceTime != *performanceTime) if (_performanceTime != *performanceTime) {
printf("seeked by time: %lld -> %lld\n", _performanceTime, *performanceTime); printf("seeked by time: %" B_PRIdBIGTIME " -> %" B_PRIdBIGTIME
"\n", _performanceTime, *performanceTime);
}
fPerformanceTime = *performanceTime; fPerformanceTime = *performanceTime;
fCurrentFrame = fVideoTrack->CurrentFrame(); fCurrentFrame = fVideoTrack->CurrentFrame();
} }
@ -333,7 +335,7 @@ MediaTrackVideoSupplier::_SwitchFormat(color_space format, uint32 bytesPerRow)
} }
if (fFormat.u.raw_video.last_active != height - 1) { if (fFormat.u.raw_video.last_active != height - 1) {
printf("should skip %ld lines at bottom!\n", printf("should skip %" B_PRId32 " lines at bottom!\n",
(height - 1) - fFormat.u.raw_video.last_active); (height - 1) - fFormat.u.raw_video.last_active);
} }

View File

@ -90,7 +90,8 @@ status_t
ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount, ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount,
bigtime_t startTime, bigtime_t endTime) bigtime_t startTime, bigtime_t endTime)
{ {
TRACE("GetFrames(%p, frameCount: %lld, time interval: %lld - %lld)\n", TRACE("GetFrames(%p, frameCount: %" B_PRId64 ", time interval: %"
B_PRIdBIGTIME " - %" B_PRIdBIGTIME ")\n",
buffer, frameCount, startTime, endTime); buffer, frameCount, startTime, endTime);
// Create a list of playing intervals which compose the supplied // Create a list of playing intervals which compose the supplied
@ -114,7 +115,7 @@ ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount,
delete interval; delete interval;
error = B_ERROR; error = B_ERROR;
ERROR("GetFrames() - zero duration audio interval! start " ERROR("GetFrames() - zero duration audio interval! start "
"time: %lld\n", intervalStartTime); "time: %" B_PRIdBIGTIME "\n", intervalStartTime);
break; break;
} }
if (!playingIntervals.AddItem(interval)) { if (!playingIntervals.AddItem(interval)) {
@ -144,7 +145,7 @@ ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount,
int64 framesRead = 0; int64 framesRead = 0;
while (!playingIntervals.IsEmpty()) { while (!playingIntervals.IsEmpty()) {
PlayingInterval* interval PlayingInterval* interval
= (PlayingInterval*)playingIntervals.RemoveItem(0L); = (PlayingInterval*)playingIntervals.RemoveItem((int32)0);
if (error != B_OK) { if (error != B_OK) {
delete interval; delete interval;
continue; continue;

View File

@ -52,8 +52,9 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
int32 sequenceNumber = atoi(line.String()); int32 sequenceNumber = atoi(line.String());
if (sequenceNumber != lastSequenceNumber + 1) { if (sequenceNumber != lastSequenceNumber + 1) {
fprintf(stderr, "Warning: Wrong sequence number in SRT " fprintf(stderr, "Warning: Wrong sequence number in SRT "
"file: %ld, expected: %ld, line %ld\n", sequenceNumber, "file: %" B_PRId32 ", expected: %" B_PRId32 ", line %"
lastSequenceNumber + 1, currentLine); B_PRId32 "\n", sequenceNumber, lastSequenceNumber + 1,
currentLine);
} }
state = EXPECT_TIME_CODE; state = EXPECT_TIME_CODE;
lastSequenceNumber = sequenceNumber; lastSequenceNumber = sequenceNumber;
@ -65,14 +66,14 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
line.Trim(); line.Trim();
int32 separatorPos = line.FindFirst(" --> "); int32 separatorPos = line.FindFirst(" --> ");
if (separatorPos < 0) { if (separatorPos < 0) {
fprintf(stderr, "Error: Time code expected on line %ld, " fprintf(stderr, "Error: Time code expected on line %"
"got '%s'\n", currentLine, line.String()); B_PRId32 ", got '%s'\n", currentLine, line.String());
return; return;
} }
BString timeCode(line.String(), separatorPos); BString timeCode(line.String(), separatorPos);
if (separatorPos != 12) { if (separatorPos != 12) {
fprintf(stderr, "Warning: Time code broken on line %ld " fprintf(stderr, "Warning: Time code broken on line %"
"(%s)?\n", currentLine, timeCode.String()); B_PRId32 " (%s)?\n", currentLine, timeCode.String());
} }
int hours; int hours;
int minutes; int minutes;
@ -81,7 +82,7 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
if (sscanf(timeCode.String(), "%d:%d:%d,%d", &hours, &minutes, if (sscanf(timeCode.String(), "%d:%d:%d,%d", &hours, &minutes,
&seconds, &milliSeconds) != 4) { &seconds, &milliSeconds) != 4) {
fprintf(stderr, "Error: Failed to parse start time on " fprintf(stderr, "Error: Failed to parse start time on "
"line %ld\n", currentLine); "line %" B_PRId32 "\n", currentLine);
return; return;
} }
subTitle.startTime = (bigtime_t)hours * 60 * 60 * 1000000LL subTitle.startTime = (bigtime_t)hours * 60 * 60 * 1000000LL
@ -94,7 +95,7 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
if (sscanf(timeCode.String(), "%d:%d:%d,%d", &hours, &minutes, if (sscanf(timeCode.String(), "%d:%d:%d,%d", &hours, &minutes,
&seconds, &milliSeconds) != 4) { &seconds, &milliSeconds) != 4) {
fprintf(stderr, "Error: Failed to parse end time on " fprintf(stderr, "Error: Failed to parse end time on "
"line %ld\n", currentLine); "line %" B_PRId32 "\n", currentLine);
return; return;
} }
bigtime_t endTime = (bigtime_t)hours * 60 * 60 * 1000000LL bigtime_t endTime = (bigtime_t)hours * 60 * 60 * 1000000LL

View File

@ -22,10 +22,10 @@ duration_to_string(int32 seconds, char* string, size_t stringSize)
seconds = seconds % 60; seconds = seconds % 60;
if (hours > 0) { if (hours > 0) {
snprintf(string, stringSize, "%s%ld:%02ld:%02ld", snprintf(string, stringSize, "%s%" B_PRId32 ":%02" B_PRId32 ":%02"
negative ? "-" : "", hours, minutes, seconds); B_PRId32, negative ? "-" : "", hours, minutes, seconds);
} else { } else {
snprintf(string, stringSize, "%s%ld:%02ld", snprintf(string, stringSize, "%s%" B_PRId32 ":%02" B_PRId32,
negative ? "-" : "", minutes, seconds); negative ? "-" : "", minutes, seconds);
} }
} }

View File

@ -51,6 +51,6 @@ Event::SetAutoDelete(bool autoDelete)
void void
Event::Execute() Event::Execute()
{ {
printf("Event::Execute() - %Ld\n", fTime); printf("Event::Execute() - %" B_PRIdBIGTIME "\n", fTime);
} }

View File

@ -42,7 +42,7 @@ EventQueue::~EventQueue()
{ {
if (delete_sem(fThreadControl) == B_OK) if (delete_sem(fThreadControl) == B_OK)
wait_for_thread(fEventExecutor, &fEventExecutor); wait_for_thread(fEventExecutor, &fEventExecutor);
while (Event *event = (Event*)fEvents.RemoveItem(0L)) { while (Event *event = (Event*)fEvents.RemoveItem((int32)0)) {
if (event->AutoDelete()) if (event->AutoDelete())
delete event; delete event;
} }
@ -174,7 +174,7 @@ EventQueue::_ExecuteEvents()
if (Lock()) { if (Lock()) {
while (!fEvents.IsEmpty() while (!fEvents.IsEmpty()
&& system_time() >= _EventAt(0)->Time()) { && system_time() >= _EventAt(0)->Time()) {
Event* event = (Event*)fEvents.RemoveItem(0L); Event* event = (Event*)fEvents.RemoveItem((int32)0);
bool deleteEvent = event->AutoDelete(); bool deleteEvent = event->AutoDelete();
event->Execute(); event->Execute();
if (deleteEvent) if (deleteEvent)

View File

@ -29,8 +29,8 @@ Notifier::~Notifier()
if (fListeners.CountItems() > 0) { if (fListeners.CountItems() > 0) {
char message[256]; char message[256];
Listener* o = (Listener*)fListeners.ItemAt(0); Listener* o = (Listener*)fListeners.ItemAt(0);
sprintf(message, "Notifier::~Notifier() - %ld " sprintf(message, "Notifier::~Notifier() - %" B_PRId32
"listeners still watching, first: %s\n", " listeners still watching, first: %s\n",
fListeners.CountItems(), typeid(*o).name()); fListeners.CountItems(), typeid(*o).name());
debugger(message); debugger(message);
} }