Skip to content

Commit

Permalink
[nogpu] Various fixes to make Mac build possible (audio included) [dj…
Browse files Browse the repository at this point in the history
…fumberger]
  • Loading branch information
antonioginer committed Jan 17, 2024
1 parent 38d6689 commit 80e7d9a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions scripts/src/3rdparty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,12 @@ if _OPTIONS["targetos"]=="linux" then
backtick("pkg-config --cflags sdl2"),
}

if _OPTIONS["gcc"]~=nil and string.find(_OPTIONS["gcc"], "clang") then
buildoptions {
"-Wno-unused-private-field",
}
end

links {
"Xrandr",
}
Expand Down
10 changes: 5 additions & 5 deletions src/osd/modules/render/drawnogpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class renderer_nogpu : public osd_renderer
virtual void save() override {}
virtual void record() override {}
virtual void toggle_fsfx() override {}
virtual void add_audio_to_recording(const int16_t *buffer, int samples_this_frame) override;

private:
#if defined(OSD_WINDOWS)
Expand Down Expand Up @@ -228,7 +229,6 @@ class renderer_nogpu : public osd_renderer
bool nogpu_wait_ack(double timeout);
bool nogpu_wait_status(nogpu_blit_status *status, double timeout);
void nogpu_register_frametime(osd_ticks_t frametime);
void add_audio_to_recording(const int16_t *buffer, int samples_this_frame);
};

inline double get_ms(osd_ticks_t ticks) { return (double) ticks / osd_ticks_per_second() * 1000; };
Expand Down Expand Up @@ -439,7 +439,7 @@ int renderer_nogpu::draw(const int update)

// Wait raster position
if (video_config.syncrefresh)
valid_status = nogpu_wait_status(&m_blit_status, std::max(0.0d, m_period - get_ms(time_blit - time_exit)));
valid_status = nogpu_wait_status(&m_blit_status, std::max(0.0, m_period - get_ms(time_blit - time_exit)));

if (video_config.syncrefresh && valid_status)
m_frame = m_blit_status.frame_req + 1;
Expand Down Expand Up @@ -872,15 +872,15 @@ void renderer_nogpu::nogpu_blit(uint32_t frame, uint16_t width, uint16_t height)
// Calculate frame delay factor
if (m_is_internal_fe)
// Internal frontend needs fd > 0
m_frame_delay = .5d;
m_frame_delay = .5;

else if (video_config.framedelay == 0)
// automatic
m_frame_delay = std::max((double)(m_period - std::max(m_fd_margin, get_ms(time_frame_dm))) / m_period, 0.0d);
m_frame_delay = std::max((double)(m_period - std::max(m_fd_margin, get_ms(time_frame_dm))) / m_period, 0.0);
else
{
// user defined
m_frame_delay = (double)(video_config.framedelay) / 10.0d;
m_frame_delay = (double)(video_config.framedelay) / 10.0;
vsync_offset = window().machine().video().vsync_offset();
}

Expand Down
3 changes: 3 additions & 0 deletions src/osd/sdl/osdsdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class sdl_osd_interface : public osd_common_t, public sdl_event_manager
// input overridables
virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) override;

// video overridables
virtual void add_audio_to_recording(const int16_t *buffer, int samples_this_frame) override;

virtual bool video_init() override;
virtual bool window_init() override;

Expand Down
7 changes: 7 additions & 0 deletions src/osd/sdl/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ void sdl_osd_interface::build_slider_list()
}
}

void sdl_osd_interface::add_audio_to_recording(const int16_t *buffer, int samples_this_frame)
{
auto const &window = osd_common_t::window_list().front(); // We only record on the first window
if (window)
window->renderer().add_audio_to_recording(buffer, samples_this_frame);
}

//============================================================
// sdlwindow_exit
// (main thread)
Expand Down

0 comments on commit 80e7d9a

Please sign in to comment.