From 843a122fd9a17bfde0f01db2c5660c33524bf40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 4 May 2013 11:15:41 +0200 Subject: [PATCH] MediaPlayer: some 64 bit fixes --- headers/os/support/SupportDefs.h | 3 +++ src/apps/mediaplayer/InfoWin.cpp | 2 +- src/apps/mediaplayer/MainWin.cpp | 8 ++++---- .../media_node_framework/NodeManager.cpp | 4 ++-- .../audio/AudioProducer.cpp | 2 +- .../video/VideoConsumer.cpp | 9 +++++---- .../media_node_framework/video/VideoConsumer.h | 4 ++-- .../video/VideoProducer.cpp | 6 ++++-- src/apps/mediaplayer/playlist/Playlist.cpp | 6 ++++-- .../supplier/MediaTrackAudioSupplier.cpp | 16 ++++++++-------- .../supplier/MediaTrackVideoSupplier.cpp | 8 +++++--- .../mediaplayer/supplier/ProxyAudioSupplier.cpp | 7 ++++--- src/apps/mediaplayer/supplier/SubTitlesSRT.cpp | 17 +++++++++-------- .../mediaplayer/support/DurationToString.cpp | 6 +++--- src/apps/mediaplayer/support/Event.cpp | 2 +- src/apps/mediaplayer/support/EventQueue.cpp | 4 ++-- src/apps/mediaplayer/support/Notifier.cpp | 4 ++-- 17 files changed, 60 insertions(+), 48 deletions(-) diff --git a/headers/os/support/SupportDefs.h b/headers/os/support/SupportDefs.h index e4f0c24e53..a37bd7d141 100644 --- a/headers/os/support/SupportDefs.h +++ b/headers/os/support/SupportDefs.h @@ -146,6 +146,9 @@ typedef generic_addr_t generic_size_t; /* time_t */ #define B_PRIdTIME B_PRId32 #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). */ diff --git a/src/apps/mediaplayer/InfoWin.cpp b/src/apps/mediaplayer/InfoWin.cpp index 2316481d6f..b9d6c30750 100644 --- a/src/apps/mediaplayer/InfoWin.cpp +++ b/src/apps/mediaplayer/InfoWin.cpp @@ -293,7 +293,7 @@ InfoWin::ResizeToPreferred() void InfoWin::Update(uint32 which) { -printf("InfoWin::Update(0x%08lx)\n", which); +printf("InfoWin::Update(0x%08" B_PRIx32 ")\n", which); fLabelsView->SetText(""); fContentsView->SetText(""); fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue); diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index bdce0485db..d2754a84b1 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -1529,7 +1529,7 @@ MainWin::_CreateMenu() fAttributesMenu->AddItem(fRatingMenu); for (int32 i = 1; i <= 10; i++) { char label[16]; - snprintf(label, sizeof(label), "%ld", i); + snprintf(label, sizeof(label), "%" B_PRId32, i); BMessage* setRatingMsg = new BMessage(M_SET_RATING); setRatingMsg->AddInt32("rating", i); fRatingMenu->AddItem(new BMenuItem(label, setRatingMsg)); @@ -1541,7 +1541,7 @@ void MainWin::_SetupVideoAspectItems(BMenu* menu) { BMenuItem* item; - while ((item = menu->RemoveItem(0L)) != NULL) + while ((item = menu->RemoveItem((int32)0)) != NULL) delete item; int width; @@ -2440,7 +2440,7 @@ MainWin::_UpdatePlaylistItemFile() int32 bitrate = (int32)(format.u.encoded_audio.bit_rate / 1000); 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, strlen(text) + 1); } @@ -2457,7 +2457,7 @@ MainWin::_UpdatePlaylistItemFile() int32 bitrate = (int32)(format.u.encoded_video.avg_bit_rate / 1000); 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, strlen(text) + 1); } diff --git a/src/apps/mediaplayer/media_node_framework/NodeManager.cpp b/src/apps/mediaplayer/media_node_framework/NodeManager.cpp index a6ec1417db..8809fb4888 100644 --- a/src/apps/mediaplayer/media_node_framework/NodeManager.cpp +++ b/src/apps/mediaplayer/media_node_framework/NodeManager.cpp @@ -118,8 +118,8 @@ NodeManager::SetPlayMode(int32 mode, bool continuePlaying) status_t ret = fMediaRoster->SetRunModeNode(fVideoConnection.consumer, runMode); if (ret != B_OK) { - printf("NodeManager::SetPlayMode(%ld), setting run mode failed: " - "%s\n", mode, strerror(ret)); + printf("NodeManager::SetPlayMode(%" B_PRId32 "), setting run mode " + "failed: %s\n", mode, strerror(ret)); } fMediaRoster->Unlock(); } diff --git a/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp b/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp index 253e695266..d870dfefef 100644 --- a/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp +++ b/src/apps/mediaplayer/media_node_framework/audio/AudioProducer.cpp @@ -817,7 +817,7 @@ AudioProducer::_FillNextBuffer(bigtime_t eventTime) static bool errorPrinted = false; if (!errorPrinted) { 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()); errorPrinted = true; } diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp b/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp index 8d04b1509f..5dad0ad49a 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp +++ b/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp @@ -86,7 +86,7 @@ VideoConsumer::~VideoConsumer() BMediaAddOn* -VideoConsumer::AddOn(long* cookie) const +VideoConsumer::AddOn(int32* cookie) const { FUNCTION("VideoConsumer::AddOn\n"); // 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; if ((status = fBuffers->AddBuffer(info, &buffer)) != B_OK) { 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; } else { PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD " @@ -248,8 +248,9 @@ VideoConsumer::CreateBuffers(const media_format& format) fBufferMap[i] = buffer; } else { ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING " - "BUFFER (Index %ld Width %ld Height %ld Colorspace %d: %s\n", - i, width, height, colorSpace, strerror(status)); + "BUFFER (Index %" B_PRId32 " Width %" B_PRId32 " Height %" + B_PRId32 " Colorspace %d: %s\n", i, width, height, colorSpace, + strerror(status)); return status; } } diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h b/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h index 7140b18d19..e52f5c307d 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h +++ b/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.h @@ -36,7 +36,7 @@ public: // BMediaNode interface public: - virtual BMediaAddOn* AddOn(long* cookie) const; + virtual BMediaAddOn* AddOn(int32* cookie) const; protected: virtual void NodeRegistered(); @@ -100,7 +100,7 @@ private: void _UnsetTargetBuffer(); private: - uint32 fInternalID; + int32 fInternalID; BMediaAddOn* fAddOn; bool fConnectionActive; diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp index a8a28befb5..48b5c9186d 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp +++ b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp @@ -697,8 +697,10 @@ VideoProducer::_FrameGeneratorThread() && nextWaitUntil < system_time() - fBufferLatency && droppedFrames < kMaxDroppedFrames) { // Drop frame if it's at least a frame late. - if (playingDirection > 0) - printf("VideoProducer: dropped frame (%Ld)\n", fFrame); + if (playingDirection > 0) { + printf("VideoProducer: dropped frame (%" B_PRId64 + ")\n", fFrame); + } // next frame droppedFrames++; fFrame++; diff --git a/src/apps/mediaplayer/playlist/Playlist.cpp b/src/apps/mediaplayer/playlist/Playlist.cpp index 35fabad63d..18e17227c9 100644 --- a/src/apps/mediaplayer/playlist/Playlist.cpp +++ b/src/apps/mediaplayer/playlist/Playlist.cpp @@ -559,8 +559,10 @@ Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist) = new (std::nothrow) FilePlaylistItem(refPath); if (item == NULL || !playlist->AddItem(item)) delete item; - } else - printf("Error - %s: [%lx]\n", strerror(err), (int32) err); + } else { + printf("Error - %s: [%" B_PRIx32 "]\n", strerror(err), + err); + } } else printf("Error - No File Found in playlist\n"); } diff --git a/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp b/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp index 973f3d9d5f..200cf76834 100644 --- a/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp +++ b/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp @@ -143,7 +143,7 @@ MediaTrackAudioSupplier::Read(void* buffer, int64 pos, int64 frames) pos += fOutOffset; // Fill the frames after the end of the track with silence. 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); frames = size; } @@ -276,10 +276,10 @@ MediaTrackAudioSupplier::_InitFromTrack() // get the length of the track fCountFrames = fMediaTrack->CountFrames(); - TRACE("_InitFromTrack(): keyframes: %d, frame count: %lld\n", - fHasKeyFrames, fCountFrames); - printf("_InitFromTrack(): keyframes: %d, frame count: %lld\n", - fHasKeyFrames, fCountFrames); + TRACE("_InitFromTrack(): keyframes: %" B_PRId16 ", frame count: %" B_PRId64 + "\n", fHasKeyFrames, fCountFrames); + printf("_InitFromTrack(): keyframes: %" B_PRId16 ", frame count: %" + B_PRId64 "\n", fHasKeyFrames, fCountFrames); } // _FramesPerBuffer @@ -698,9 +698,9 @@ MediaTrackAudioSupplier::_SeekToKeyFrameBackward(int64& position) if (error != B_OK) { position = fMediaTrack->CurrentFrame(); // if (fReportSeekError) { - printf(" seek to key frame backward: %lld -> %lld (%lld) " - "- %s\n", wantedPosition, position, - fMediaTrack->CurrentFrame(), strerror(error)); + printf(" seek to key frame backward: %" B_PRId64 " -> %" + B_PRId64 " (%" B_PRId64 ") - %s\n", wantedPosition, + position, fMediaTrack->CurrentFrame(), strerror(error)); fReportSeekError = false; // } } else { diff --git a/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp b/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp index c136958e6d..e83c09e0c2 100644 --- a/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp +++ b/src/apps/mediaplayer/supplier/MediaTrackVideoSupplier.cpp @@ -169,8 +169,10 @@ bigtime_t _performanceTime = *performanceTime; ret = fVideoTrack->SeekToTime(performanceTime); if (ret == B_OK) { -if (_performanceTime != *performanceTime) -printf("seeked by time: %lld -> %lld\n", _performanceTime, *performanceTime); + if (_performanceTime != *performanceTime) { + printf("seeked by time: %" B_PRIdBIGTIME " -> %" B_PRIdBIGTIME + "\n", _performanceTime, *performanceTime); + } fPerformanceTime = *performanceTime; fCurrentFrame = fVideoTrack->CurrentFrame(); } @@ -333,7 +335,7 @@ MediaTrackVideoSupplier::_SwitchFormat(color_space format, uint32 bytesPerRow) } 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); } diff --git a/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp b/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp index df566c2018..cbeb5ad818 100644 --- a/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp +++ b/src/apps/mediaplayer/supplier/ProxyAudioSupplier.cpp @@ -90,7 +90,8 @@ status_t ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount, 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); // Create a list of playing intervals which compose the supplied @@ -114,7 +115,7 @@ ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount, delete interval; error = B_ERROR; ERROR("GetFrames() - zero duration audio interval! start " - "time: %lld\n", intervalStartTime); + "time: %" B_PRIdBIGTIME "\n", intervalStartTime); break; } if (!playingIntervals.AddItem(interval)) { @@ -144,7 +145,7 @@ ProxyAudioSupplier::GetFrames(void* buffer, int64 frameCount, int64 framesRead = 0; while (!playingIntervals.IsEmpty()) { PlayingInterval* interval - = (PlayingInterval*)playingIntervals.RemoveItem(0L); + = (PlayingInterval*)playingIntervals.RemoveItem((int32)0); if (error != B_OK) { delete interval; continue; diff --git a/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp b/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp index af3dcb2554..55eb48a565 100644 --- a/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp +++ b/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp @@ -52,8 +52,9 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name) int32 sequenceNumber = atoi(line.String()); if (sequenceNumber != lastSequenceNumber + 1) { fprintf(stderr, "Warning: Wrong sequence number in SRT " - "file: %ld, expected: %ld, line %ld\n", sequenceNumber, - lastSequenceNumber + 1, currentLine); + "file: %" B_PRId32 ", expected: %" B_PRId32 ", line %" + B_PRId32 "\n", sequenceNumber, lastSequenceNumber + 1, + currentLine); } state = EXPECT_TIME_CODE; lastSequenceNumber = sequenceNumber; @@ -65,14 +66,14 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name) line.Trim(); int32 separatorPos = line.FindFirst(" --> "); if (separatorPos < 0) { - fprintf(stderr, "Error: Time code expected on line %ld, " - "got '%s'\n", currentLine, line.String()); + fprintf(stderr, "Error: Time code expected on line %" + B_PRId32 ", got '%s'\n", currentLine, line.String()); return; } BString timeCode(line.String(), separatorPos); if (separatorPos != 12) { - fprintf(stderr, "Warning: Time code broken on line %ld " - "(%s)?\n", currentLine, timeCode.String()); + fprintf(stderr, "Warning: Time code broken on line %" + B_PRId32 " (%s)?\n", currentLine, timeCode.String()); } int hours; int minutes; @@ -81,7 +82,7 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name) if (sscanf(timeCode.String(), "%d:%d:%d,%d", &hours, &minutes, &seconds, &milliSeconds) != 4) { fprintf(stderr, "Error: Failed to parse start time on " - "line %ld\n", currentLine); + "line %" B_PRId32 "\n", currentLine); return; } 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, &seconds, &milliSeconds) != 4) { fprintf(stderr, "Error: Failed to parse end time on " - "line %ld\n", currentLine); + "line %" B_PRId32 "\n", currentLine); return; } bigtime_t endTime = (bigtime_t)hours * 60 * 60 * 1000000LL diff --git a/src/apps/mediaplayer/support/DurationToString.cpp b/src/apps/mediaplayer/support/DurationToString.cpp index 1f1d0b4316..d3da3e0877 100644 --- a/src/apps/mediaplayer/support/DurationToString.cpp +++ b/src/apps/mediaplayer/support/DurationToString.cpp @@ -22,10 +22,10 @@ duration_to_string(int32 seconds, char* string, size_t stringSize) seconds = seconds % 60; if (hours > 0) { - snprintf(string, stringSize, "%s%ld:%02ld:%02ld", - negative ? "-" : "", hours, minutes, seconds); + snprintf(string, stringSize, "%s%" B_PRId32 ":%02" B_PRId32 ":%02" + B_PRId32, negative ? "-" : "", hours, minutes, seconds); } else { - snprintf(string, stringSize, "%s%ld:%02ld", + snprintf(string, stringSize, "%s%" B_PRId32 ":%02" B_PRId32, negative ? "-" : "", minutes, seconds); } } diff --git a/src/apps/mediaplayer/support/Event.cpp b/src/apps/mediaplayer/support/Event.cpp index 91d887b8c0..e20fc4dcde 100644 --- a/src/apps/mediaplayer/support/Event.cpp +++ b/src/apps/mediaplayer/support/Event.cpp @@ -51,6 +51,6 @@ Event::SetAutoDelete(bool autoDelete) void Event::Execute() { - printf("Event::Execute() - %Ld\n", fTime); + printf("Event::Execute() - %" B_PRIdBIGTIME "\n", fTime); } diff --git a/src/apps/mediaplayer/support/EventQueue.cpp b/src/apps/mediaplayer/support/EventQueue.cpp index 030a8c9f19..2d8acf5787 100644 --- a/src/apps/mediaplayer/support/EventQueue.cpp +++ b/src/apps/mediaplayer/support/EventQueue.cpp @@ -42,7 +42,7 @@ EventQueue::~EventQueue() { if (delete_sem(fThreadControl) == B_OK) wait_for_thread(fEventExecutor, &fEventExecutor); - while (Event *event = (Event*)fEvents.RemoveItem(0L)) { + while (Event *event = (Event*)fEvents.RemoveItem((int32)0)) { if (event->AutoDelete()) delete event; } @@ -174,7 +174,7 @@ EventQueue::_ExecuteEvents() if (Lock()) { while (!fEvents.IsEmpty() && system_time() >= _EventAt(0)->Time()) { - Event* event = (Event*)fEvents.RemoveItem(0L); + Event* event = (Event*)fEvents.RemoveItem((int32)0); bool deleteEvent = event->AutoDelete(); event->Execute(); if (deleteEvent) diff --git a/src/apps/mediaplayer/support/Notifier.cpp b/src/apps/mediaplayer/support/Notifier.cpp index 40d0e95391..80b487ae90 100644 --- a/src/apps/mediaplayer/support/Notifier.cpp +++ b/src/apps/mediaplayer/support/Notifier.cpp @@ -29,8 +29,8 @@ Notifier::~Notifier() if (fListeners.CountItems() > 0) { char message[256]; Listener* o = (Listener*)fListeners.ItemAt(0); - sprintf(message, "Notifier::~Notifier() - %ld " - "listeners still watching, first: %s\n", + sprintf(message, "Notifier::~Notifier() - %" B_PRId32 + " listeners still watching, first: %s\n", fListeners.CountItems(), typeid(*o).name()); debugger(message); }