Skip to content

Commit 19aac7a

Browse files
committed
all working now
1 parent d13cf23 commit 19aac7a

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

src/unix/sysdep/dsp-drivers/sdl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ static int sdl_dsp_write(struct sysdep_dsp_struct *dsp, unsigned char *data,
173173
// get stream from dsp
174174
const struct sdl_info *info = (struct sdl_info *)dsp->_priv;
175175

176-
const int result = SDL_PutAudioStreamData(info->stream, data, len);
177-
if (result != 0) {
176+
const bool success = SDL_PutAudioStreamData(info->stream, data, len);
177+
if (!success) {
178178
fprintf(stderr, "error: SDL_PutAudioStreamData() failed: %s\n", SDL_GetError());
179179
return 0;
180180
}

src/unix/video-drivers/sdl.c

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ void sysdep_close(void)
152152

153153
int sysdep_create_display(int depth)
154154
{
155+
// print all video drivers and mark the one in use
156+
int num_drivers = SDL_GetNumVideoDrivers();
157+
const char *driver_name = SDL_GetCurrentVideoDriver();
158+
fprintf(stderr, "SDL: Info: Found %d video drivers\n", num_drivers);
159+
for (int i = 0; i < num_drivers; i++) {
160+
const char *driver = SDL_GetVideoDriver(i);
161+
fprintf(stderr, "SDL: Info: Video driver %d: %s", i, driver);
162+
if (strcmp(driver, driver_name) == 0) {
163+
fprintf(stderr, " (in use)");
164+
}
165+
fprintf(stderr, "\n");
166+
}
167+
155168
fprintf(stderr, "SDL: Info: Create display with depth %d\n", depth);
156169
int vid_modes_i;
157170
#ifdef DIRECT_HERMES
@@ -160,8 +173,9 @@ int sysdep_create_display(int depth)
160173
#endif /* DIRECT_HERMES */
161174
int vid_mode_flag; /* Flag to set the video mode */
162175

163-
const SDL_DisplayMode *current_mode = SDL_GetCurrentDisplayMode(0);
164-
if (current_mode != NULL) {
176+
const SDL_DisplayID display = SDL_GetPrimaryDisplay();
177+
const SDL_DisplayMode *current_mode = SDL_GetCurrentDisplayMode(display);
178+
if (current_mode == NULL) {
165179
fprintf(stderr, "SDL: Error getting current display mode: %s\n", SDL_GetError());
166180
SDL_Quit();
167181
exit (OSD_NOT_OK);
@@ -189,10 +203,8 @@ int sysdep_create_display(int depth)
189203
// TODO how do we know if hardware acceleration is available?
190204
// hardware = video_info->hw_available;
191205

192-
193-
const int display_index = 0;
194206
int modes_count = 0;
195-
SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(display_index, &modes_count);
207+
SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(display, &modes_count);
196208
/* Best video mode found */
197209
int best_vid_mode = -1;
198210
int best_width = -1;
@@ -212,10 +224,11 @@ int sysdep_create_display(int depth)
212224
#endif
213225

214226

215-
for (int mode_index = 0; mode_index <= modes_count; mode_index++)
227+
// last mode is NULL,
228+
for (int mode_index = 0; mode_index < modes_count; mode_index++)
216229
{
217230
const SDL_DisplayMode mode = *modes[mode_index];
218-
SDL_Log(" %i bpp\t%i x %i @ %iHz",
231+
SDL_Log(" %i bpp\t%i x %i @ %fHz",
219232
SDL_BITSPERPIXEL(mode.format), mode.w, mode.h, mode.refresh_rate);
220233

221234
#ifdef SDL_DEBUG
@@ -259,6 +272,7 @@ int sysdep_create_display(int depth)
259272
Vid_height = best_height;
260273
}
261274
}
275+
SDL_free(modes);
262276

263277
if( depth == 16 )
264278
{
@@ -952,7 +966,13 @@ void sysdep_update_keyboard()
952966
/* added functions */
953967
int sysdep_display_16bpp_capable(void)
954968
{
955-
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(0);
969+
const SDL_DisplayID display = SDL_GetPrimaryDisplay();
970+
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(display);
971+
if (mode == NULL)
972+
{
973+
fprintf(stderr, "SDL: Error getting current display mode: %s\n", SDL_GetError());
974+
return false;
975+
}
956976
const int bpp = SDL_BITSPERPIXEL(mode->format);
957977
return ( bpp >=16);
958978
}
@@ -975,7 +995,7 @@ int list_sdl_modes(struct rc_option *option, const char *arg, int priority)
975995
for (int mode_index = 0; mode_index <= modes_count; mode_index++)
976996
{
977997
const SDL_DisplayMode mode = *modes[mode_index];
978-
printf("\t%d) Mode %d x %d @ %iHz\n",
998+
printf("\t%d) Mode %d x %d @ %fHz\n",
979999
mode_index,
9801000
mode.w,
9811001
mode.h,

0 commit comments

Comments
 (0)