[haiku-commits] haiku: hrev49353 - in src: bin tests/kits/game/chart apps/cortex/addons/Flanger add-ons/accelerants/matrox/engine

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 2 Jul 2015 22:14:27 +0200 (CEST)

hrev49353 adds 6 changesets to branch 'master'
old head: 926df420ca11a295cadfabcc514de33c1a23ce31
new head: 060bd5ebb90457dadda1dc17d42ada632faa00c6
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=060bd5ebb904+%5E926df420ca11

----------------------------------------------------------------------------

cdec47c9277a: Workaround timing issues in Chart

When run on a VM (VBox, vmware), the timing calculations done were giving
weird
results (< 1ms), messing with the logic (div by zero introduced).

Should take care of ticket #89.

11f43ff1d73f: Cortex: fix copy and paste error

Comparing a format with byte_order and the context indicates a copy and paste
error.

CID 991144

bb4ab4336d4f: Matrox accelerant: assignation to B_OK -> condition never true.

Assignation to B_OK in if condition means it will never be true. Replace with
==.

CID 991072, 991155 and 604410.

e2a8ef11f6f1: CID 702036: catattr: close file descriptor after usage

39ceaa9c285f: eject: close file description after usage

Also reindent the switch statement. CID 702040.

060bd5ebb904: Tracker::BTitleView, Init fPreviousLeftClickTime

CID 1273731

[ Philippe Saint-Pierre <stpere@xxxxxxxxx> ]

----------------------------------------------------------------------------

6 files changed, 87 insertions(+), 68 deletions(-)
src/add-ons/accelerants/matrox/engine/mga_acc.c | 2 +-
src/apps/cortex/addons/Flanger/FlangerNode.cpp | 12 +-
src/bin/catattr.cpp | 9 +-
src/bin/eject.cpp | 121 +++++++++++---------
src/kits/tracker/TitleView.cpp | 1 +
src/tests/kits/game/chart/ChartWindow.cpp | 10 +-

############################################################################

Commit: cdec47c9277ab622dd4c59eb7f91b8134c67f1f3
URL: http://cgit.haiku-os.org/haiku/commit/?id=cdec47c9277a
Author: Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date: Thu Jul 2 15:28:25 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/89

Workaround timing issues in Chart

When run on a VM (VBox, vmware), the timing calculations done were giving weird
results (< 1ms), messing with the logic (div by zero introduced).

Should take care of ticket #89.

----------------------------------------------------------------------------

diff --git a/src/tests/kits/game/chart/ChartWindow.cpp
b/src/tests/kits/game/chart/ChartWindow.cpp
index 7e00e10..0606c6e 100644
--- a/src/tests/kits/game/chart/ChartWindow.cpp
+++ b/src/tests/kits/game/chart/ChartWindow.cpp
@@ -2278,7 +2278,7 @@ ChartWindow::Animation2(void *data)
RefreshStarPacket(w->fSecondThreadBuffer, &w->fSpecials2,
&w->fGeometry);
bigtime_t after = system_time();

- w->fSecondThreadDelay = after-before;
+ w->fSecondThreadDelay = max_c(after-before, 1);

release_sem(w->fSecondThreadRelease);
}
@@ -2763,6 +2763,7 @@ ChartWindow::RefreshStars(buffer *buf, float time_step)
dynamic load split between the two threads, when
needed. */
if (fCurrentSettings.second_thread) {
+
int32 star_threshold = (int32)((float)fStars.count *
fSecondThreadThreshold + 0.5);
int32 special_threshold = (int32)((float)fSpecials.count *
fSecondThreadThreshold + 0.5);

@@ -2814,9 +2815,10 @@ ChartWindow::RefreshStars(buffer *buf, float time_step)
/* calculate the new optimal split ratio depending
of the previous one and the time used by both
threads to do their work. */
- float ratio = ((float)fSecondThreadDelay/(float)(after-before))
*
-
(fSecondThreadThreshold/(1.0-fSecondThreadThreshold));
- fSecondThreadThreshold = ratio / (1.0+ratio);
+ float ratio = ((float)fSecondThreadDelay /
+ (float)max_c(after - before, 1))
+ * (fSecondThreadThreshold / (1.0 -
fSecondThreadThreshold));
+ fSecondThreadThreshold = ratio / (1.0 + ratio);

} else {
/* In single-threaded mode, nothing fancy to be done. */

############################################################################

Commit: 11f43ff1d73f1540deed2dfe87773971f1083e38
URL: http://cgit.haiku-os.org/haiku/commit/?id=11f43ff1d73f
Author: Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date: Thu Jul 2 17:14:41 2015 UTC

Cortex: fix copy and paste error

Comparing a format with byte_order and the context indicates a copy and paste
error.

CID 991144

----------------------------------------------------------------------------

diff --git a/src/apps/cortex/addons/Flanger/FlangerNode.cpp
b/src/apps/cortex/addons/Flanger/FlangerNode.cpp
index 0af06dc..d162d93 100644
--- a/src/apps/cortex/addons/Flanger/FlangerNode.cpp
+++ b/src/apps/cortex/addons/Flanger/FlangerNode.cpp
@@ -1210,20 +1210,20 @@ void FlangerNode::specializeOutputFormat(
media_raw_audio_format& f = ioFormat.u.raw_audio;
media_raw_audio_format& w = media_raw_audio_format::wildcard;

- if(f.frame_rate == w.frame_rate)
+ if (f.frame_rate == w.frame_rate)
f.frame_rate = 44100.0;
- if(f.channel_count == w.channel_count) {
+ if (f.channel_count == w.channel_count) {
//+++++ tweaked 15sep99
- if(m_input.source != media_source::null)
+ if (m_input.source != media_source::null)
f.channel_count =
m_input.format.u.raw_audio.channel_count;
else
f.channel_count = 1;
}
- if(f.format == w.format)
+ if (f.format == w.format)
f.format = media_raw_audio_format::B_AUDIO_FLOAT;
- if(f.byte_order == w.format)
+ if (f.byte_order == w.byte_order)
f.byte_order = (B_HOST_IS_BENDIAN) ? B_MEDIA_BIG_ENDIAN :
B_MEDIA_LITTLE_ENDIAN;
- if(f.buffer_size == w.buffer_size)
+ if (f.buffer_size == w.buffer_size)
f.buffer_size = 2048;

string_for_format(ioFormat, formatStr, 255);

############################################################################

Commit: bb4ab4336d4f6be66639058e70ac73de1f6d646e
URL: http://cgit.haiku-os.org/haiku/commit/?id=bb4ab4336d4f
Author: Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date: Thu Jul 2 17:20:44 2015 UTC

Matrox accelerant: assignation to B_OK -> condition never true.

Assignation to B_OK in if condition means it will never be true. Replace with
==.

CID 991072, 991155 and 604410.

----------------------------------------------------------------------------

diff --git a/src/add-ons/accelerants/matrox/engine/mga_acc.c
b/src/add-ons/accelerants/matrox/engine/mga_acc.c
index 74c1ecb..eaf726d 100644
--- a/src/add-ons/accelerants/matrox/engine/mga_acc.c
+++ b/src/add-ons/accelerants/matrox/engine/mga_acc.c
@@ -44,7 +44,7 @@ status_t gx00_acc_init()
/* used for convenience: MACCESS is a write only register! */
uint32 maccess = 0x00000000;
/* if we were unable to read PINS, we have to assume something (keeping
bit6 zero) */
- if ((si->ps.card_type >= G450) && (si->ps.pins_status = B_OK))
+ if ((si->ps.card_type >= G450) && (si->ps.pins_status == B_OK))
{
/* b7 v5_mem_type = done by Mark Watson. fixme: still confirm!
(unknown bits) */
maccess |= ((((uint32)si->ps.v5_mem_type) & 0x80) >> 1);

############################################################################

Commit: e2a8ef11f6f129d3718647f1045b7cd3a78cace9
URL: http://cgit.haiku-os.org/haiku/commit/?id=e2a8ef11f6f1
Author: Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date: Thu Jul 2 19:13:32 2015 UTC

CID 702036: catattr: close file descriptor after usage

----------------------------------------------------------------------------

diff --git a/src/bin/catattr.cpp b/src/bin/catattr.cpp
index eab474f..73387c6 100644
--- a/src/bin/catattr.cpp
+++ b/src/bin/catattr.cpp
@@ -142,8 +142,10 @@ catAttr(const char *attribute, const char *fileName, bool
keepRaw,
return errno;

attr_info info;
- if (fs_stat_attr(fd, attribute, &info) < 0)
+ if (fs_stat_attr(fd, attribute, &info) < 0) {
+ close(fd);
return errno;
+ }

// limit size of the attribute, only the first 64k will make it on
screen
off_t size = info.size;
@@ -156,12 +158,14 @@ catAttr(const char *attribute, const char *fileName, bool
keepRaw,
char* buffer = (char*)malloc(size);
if (!buffer) {
fprintf(stderr, "Could not allocate read buffer!\n");
+ close(fd);
return B_NO_MEMORY;
}

ssize_t bytesRead = fs_read_attr(fd, attribute, info.type, 0, buffer,
size);
if (bytesRead < 0) {
free(buffer);
+ close(fd);
return errno;
}

@@ -169,6 +173,7 @@ catAttr(const char *attribute, const char *fileName, bool
keepRaw,
fprintf(stderr, "Could only read %ld bytes from attribute!\n",
bytesRead);
free(buffer);
+ close(fd);
return B_ERROR;
}

@@ -210,6 +215,7 @@ catAttr(const char *attribute, const char *fileName, bool
keepRaw,
free(buffer);
if (written > 0)
written = B_OK;
+ close(fd);
return written;
}

@@ -275,6 +281,7 @@ catAttr(const char *attribute, const char *fileName, bool
keepRaw,
}

free(buffer);
+ close(fd);
return B_OK;
}


############################################################################

Commit: 39ceaa9c285f09dbead1de9946b57fdd8c09a5ae
URL: http://cgit.haiku-os.org/haiku/commit/?id=39ceaa9c285f
Author: Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date: Thu Jul 2 19:36:13 2015 UTC

eject: close file description after usage

Also reindent the switch statement. CID 702040.

----------------------------------------------------------------------------

diff --git a/src/bin/eject.cpp b/src/bin/eject.cpp
index 3ea2a47..52f17cd 100644
--- a/src/bin/eject.cpp
+++ b/src/bin/eject.cpp
@@ -151,73 +151,82 @@ static int do_eject(char operation, char *device)
return 1;
}
switch (operation) {
- case 'h':
- return usage("eject");
- case 'e':
- if (ioctl(fd, B_EJECT_DEVICE, NULL, 0) < 0) {
- perror(device);
- return 1;
- }
- break;
- case 'l':
- if (ioctl(fd, B_LOAD_MEDIA, NULL, 0) < 0) {
- perror(device);
- return 1;
- }
- break;
- case 'b':
- bval = true;
- if (ioctl(fd, B_SCSI_PREVENT_ALLOW, &bval, sizeof(bval)) < 0) {
- perror(device);
- return 1;
- }
- break;
- case 'u':
- bval = false;
- if (ioctl(fd, B_SCSI_PREVENT_ALLOW, &bval, sizeof(bval)) < 0) {
- perror(device);
- return 1;
- }
- break;
- case 'q':
- if (ioctl(fd, B_GET_MEDIA_STATUS, &devstatus,
sizeof(devstatus)) < 0) {
- perror(device);
- return 1;
- }
- switch (devstatus) {
- case B_NO_ERROR:
- puts("Media present");
- break;
- default:
- puts(strerror(devstatus));
- }
- break;
- case 's':
- if (ioctl(fd, B_GET_MEDIA_STATUS, &devstatus,
sizeof(devstatus)) < 0) {
- perror(device);
- return 1;
- }
- switch (devstatus) {
- case B_NO_ERROR:
- case B_DEV_NO_MEDIA:
+ case 'e':
if (ioctl(fd, B_EJECT_DEVICE, NULL, 0) < 0) {
perror(device);
+ close(fd);
return 1;
}
break;
- case B_DEV_DOOR_OPEN:
+ case 'l':
if (ioctl(fd, B_LOAD_MEDIA, NULL, 0) < 0) {
perror(device);
+ close(fd);
+ return 1;
+ }
+ break;
+ case 'b':
+ bval = true;
+ if (ioctl(fd, B_SCSI_PREVENT_ALLOW, &bval,
sizeof(bval)) < 0) {
+ perror(device);
+ close(fd);
+ return 1;
+ }
+ break;
+ case 'u':
+ bval = false;
+ if (ioctl(fd, B_SCSI_PREVENT_ALLOW, &bval,
sizeof(bval)) < 0) {
+ perror(device);
+ close(fd);
+ return 1;
+ }
+ break;
+ case 'q':
+ if (ioctl(fd, B_GET_MEDIA_STATUS, &devstatus,
sizeof(devstatus))
+ < 0) {
+ perror(device);
+ close(fd);
return 1;
}
+ switch (devstatus) {
+ case B_NO_ERROR:
+ puts("Media present");
+ break;
+ default:
+ puts(strerror(devstatus));
+ }
break;
+ case 's':
+ if (ioctl(fd, B_GET_MEDIA_STATUS, &devstatus,
sizeof(devstatus))
+ < 0) {
+ perror(device);
+ close(fd);
+ return 1;
+ }
+ switch (devstatus) {
+ case B_NO_ERROR:
+ case B_DEV_NO_MEDIA:
+ if (ioctl(fd, B_EJECT_DEVICE, NULL, 0)
< 0) {
+ perror(device);
+ close(fd);
+ return 1;
+ }
+ break;
+ case B_DEV_DOOR_OPEN:
+ if (ioctl(fd, B_LOAD_MEDIA, NULL, 0) <
0) {
+ perror(device);
+ close(fd);
+ return 1;
+ }
+ break;
+ default:
+ perror(device);
+ }
+ break;
+ case 'h':
default:
- perror(device);
- }
- break;
- default:
- usage("eject");
- return 1;
+ close(fd);
+ return usage("eject");
}
close(fd);
return 0;

############################################################################

Revision: hrev49353
Commit: 060bd5ebb90457dadda1dc17d42ada632faa00c6
URL: http://cgit.haiku-os.org/haiku/commit/?id=060bd5ebb904
Author: Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date: Thu Jul 2 20:10:20 2015 UTC

Tracker::BTitleView, Init fPreviousLeftClickTime

CID 1273731

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/TitleView.cpp b/src/kits/tracker/TitleView.cpp
index f7a771b..bf9adb0 100644
--- a/src/kits/tracker/TitleView.cpp
+++ b/src/kits/tracker/TitleView.cpp
@@ -104,6 +104,7 @@ BTitleView::BTitleView(BPoseView* view)
fTitleList(10, true),
fHorizontalResizeCursor(B_CURSOR_ID_RESIZE_EAST_WEST),
fPreviouslyClickedColumnTitle(0),
+ fPreviousLeftClickTime(0),
fTrackingState(NULL)
{
sTitleBackground = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
0.88f);


Other related posts:

  • » [haiku-commits] haiku: hrev49353 - in src: bin tests/kits/game/chart apps/cortex/addons/Flanger add-ons/accelerants/matrox/engine - stpere