diff options
author | 2025-04-14 11:31:53 +0200 | |
---|---|---|
committer | 2025-04-27 22:23:20 +0200 | |
commit | d0f1c15a0f6df2dd51a754cb46e6175b7079c8f2 (patch) | |
tree | be35c94340442af08c316a8679089ee68e119fac /src/osd/modules/sound/coreaudio_sound.cpp | |
parent | ec636faeba5c5841c5a4a35b7c9dc2f06a00f538 (diff) |
New sound infrastructure.
Should be added soon:
- mute
- speaker/microphone resampling
To be added a little later:
- compression
- reverb
Needs to be added by someone else:
- coreaudio
- direct
- portaudio
- xaudio2
- js
Diffstat (limited to 'src/osd/modules/sound/coreaudio_sound.cpp')
-rw-r--r-- | src/osd/modules/sound/coreaudio_sound.cpp | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp index 3e5de546bcf..7e9814af117 100644 --- a/src/osd/modules/sound/coreaudio_sound.cpp +++ b/src/osd/modules/sound/coreaudio_sound.cpp @@ -46,7 +46,6 @@ public: m_playpos(0), m_writepos(0), m_in_underrun(false), - m_scale(128), m_overflows(0), m_underflows(0) { @@ -60,8 +59,7 @@ public: // sound_module - virtual void update_audio_stream(bool is_throttled, int16_t const *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; + virtual void stream_sink_update(uint32_t, int16_t const *buffer, int samples_this_frame) override; private: struct node_detail @@ -83,14 +81,6 @@ private: uint32_t buffer_avail() const { return ((m_writepos >= m_playpos) ? m_buffer_size : 0) + m_playpos - m_writepos; } uint32_t buffer_used() const { return ((m_playpos > m_writepos) ? m_buffer_size : 0) + m_writepos - m_playpos; } - void copy_scaled(void *dst, void const *src, uint32_t bytes) const - { - bytes /= sizeof(int16_t); - int16_t const *s = (int16_t const *)src; - for (int16_t *d = (int16_t *)dst; bytes > 0; bytes--, s++, d++) - *d = (*s * m_scale) >> 7; - } - bool create_graph(osd_options const &options); bool add_output(char const *name); bool add_device_output(char const *name); @@ -178,7 +168,6 @@ private: uint32_t m_playpos; uint32_t m_writepos; bool m_in_underrun; - int32_t m_scale; unsigned m_overflows; unsigned m_underflows; }; @@ -240,7 +229,6 @@ int sound_coreaudio::init(osd_interface &osd, const osd_options &options) m_playpos = 0; m_writepos = m_headroom; m_in_underrun = false; - m_scale = 128; m_overflows = m_underflows = 0; // Initialise and start @@ -290,7 +278,7 @@ void sound_coreaudio::exit() } -void sound_coreaudio::update_audio_stream(bool is_throttled, int16_t const *buffer, int samples_this_frame) +void sound_coreaudio::stream_sink_update(uint32_t, int16_t const *buffer, int samples_this_frame) { if ((m_sample_rate == 0) || !m_buffer) return; @@ -318,13 +306,6 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, int16_t const *buff } -void sound_coreaudio::set_mastervolume(int attenuation) -{ - int const clamped_attenuation = std::clamp(attenuation, -32, 0); - m_scale = (-32 == clamped_attenuation) ? 0 : (int32_t)(pow(10.0, clamped_attenuation / 20.0) * 128); -} - - bool sound_coreaudio::create_graph(osd_options const &options) { OSStatus err; @@ -984,7 +965,7 @@ OSStatus sound_coreaudio::render( } uint32_t const chunk = std::min(m_buffer_size - m_playpos, number_bytes); - copy_scaled((int8_t *)data->mBuffers[0].mData, &m_buffer[m_playpos], chunk); + memcpy((int8_t *)data->mBuffers[0].mData, &m_buffer[m_playpos], chunk); m_playpos += chunk; if (m_playpos >= m_buffer_size) m_playpos = 0; @@ -993,7 +974,7 @@ OSStatus sound_coreaudio::render( { assert(0U == m_playpos); assert(m_writepos >= (number_bytes - chunk)); - copy_scaled((int8_t *)data->mBuffers[0].mData + chunk, &m_buffer[0], number_bytes - chunk); + memcpy((int8_t *)data->mBuffers[0].mData + chunk, &m_buffer[0], number_bytes - chunk); m_playpos += number_bytes - chunk; } |