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 */
#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). */

View File

@ -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);

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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++;

View File

@ -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");
}

View File

@ -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 {

View File

@ -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);
}

View File

@ -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;

View File

@ -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

View File

@ -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);
}
}

View File

@ -51,6 +51,6 @@ Event::SetAutoDelete(bool autoDelete)
void
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)
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)

View File

@ -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);
}