Skip to content

Commit

Permalink
Update for new WAVE api
Browse files Browse the repository at this point in the history
  • Loading branch information
Daft-Freak committed Feb 6, 2021
1 parent 171725e commit f698f9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 8 additions & 9 deletions avi-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ void AVIFile::play(int audioChannel)
return;

blit::channels[channel].waveforms = blit::Waveform::WAVE;
blit::channels[channel].volume = 0xFF;
blit::channels[channel].wave_callback_arg = this;
blit::channels[channel].callback_waveBufferRefresh = staticAudioCallback;
blit::channels[channel].user_data = this;
blit::channels[channel].wave_buffer_callback = staticAudioCallback;
}

void AVIFile::stop()
Expand Down Expand Up @@ -430,16 +429,16 @@ bool AVIFile::parseHeaders(uint32_t offset, uint32_t len)
return true;
}

void AVIFile::staticAudioCallback(void *arg)
void AVIFile::staticAudioCallback(blit::AudioChannel &channel)
{
reinterpret_cast<AVIFile *>(arg)->audioCallback();
reinterpret_cast<AVIFile *>(channel.user_data)->audioCallback(channel);
}

void AVIFile::audioCallback()
void AVIFile::audioCallback(blit::AudioChannel &channel)
{
if(!currentSample)
{
blit::channels[channel].off();
channel.off();
return;
}

Expand All @@ -453,12 +452,12 @@ void AVIFile::audioCallback()
}
else
{
memset(blit::channels[channel].wave_buffer, 0, 64 * sizeof(int16_t));
memset(channel.wave_buffer, 0, 64 * sizeof(int16_t));
return;
}
}

auto out = blit::channels[channel].wave_buffer;
auto out = channel.wave_buffer;

int i = 0;
for(; i < 64 && currentSample != endSample; i++)
Expand Down
5 changes: 3 additions & 2 deletions avi-file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define MINIMP3_ONLY_MP3
#include "minimp3.h"

#include "audio/audio.hpp"
#include "engine/file.hpp"
#include "graphics/jpeg.hpp"

Expand Down Expand Up @@ -96,8 +97,8 @@ class AVIFile
private:
bool parseHeaders(uint32_t offset, uint32_t len);

static void staticAudioCallback(void *arg);
void audioCallback();
static void staticAudioCallback(blit::AudioChannel &channel);
void audioCallback(blit::AudioChannel &channel);

bool playing = false;
bool decodedFirstFrame = false;
Expand Down

0 comments on commit f698f9d

Please sign in to comment.