summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/avp/win95/frontend/avp_intro.cpp6
-rw-r--r--src/bink.c23
2 files changed, 16 insertions, 13 deletions
diff --git a/src/avp/win95/frontend/avp_intro.cpp b/src/avp/win95/frontend/avp_intro.cpp
index 34cdc4a..2804f44 100644
--- a/src/avp/win95/frontend/avp_intro.cpp
+++ b/src/avp/win95/frontend/avp_intro.cpp
@@ -3,7 +3,7 @@ extern "C"
{
#include "3dc.h"
#include "inline.h"
- //#include "smacker.h"
+ #include "bink.h"
#include "avp_menus.h"
#include "avp_intro.h"
extern int NormalFrameTime;
@@ -23,20 +23,22 @@ void Show_ARebellionGame(void);
void Show_AvPLogo(void);
extern void ShowSplashScreens(void);
extern void Show_WinnerScreen(void);
-extern void PlayBinkedFMV(char *filenamePtr);
extern void DrawMainMenusBackdrop(void);
extern void FadedScreen(int alpha);
void StartMenuMusic(void)
{
+ StartMusicBink("FMVs/IntroSound.smk", true);
}
void PlayMenuMusic(void)
{
+ PlayMusicBink(127);
}
void EndMenuMusic(void)
{
+ EndMusicBink();
}
void WeWantAnIntro(void)
diff --git a/src/bink.c b/src/bink.c
index 6f357b6..2f54be0 100644
--- a/src/bink.c
+++ b/src/bink.c
@@ -280,13 +280,16 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
return 1;
}
+// Return 0 iff we have reached the end of file.
static int ReadPacket(struct binkMovie* aMovie)
{
// Read from file if no packet is buffered.
if (!aMovie->packet.buf && av_read_frame(aMovie->context, &aMovie->packet) < 0) {
// No more packets in file.
if (aMovie->looping) {
- av_seek_frame(aMovie->context, -1, 0, 0);
+ // This needs ffmpeg≄4.4 to work for smacker files.
+ if (avformat_seek_file(aMovie->context, -1, 0, 0, 0, 0) < 0)
+ return 0;
return ReadPacket(aMovie);
} else {
// Drain buffered frames.
@@ -299,7 +302,7 @@ static int ReadPacket(struct binkMovie* aMovie)
}
// Send the (possibly buffered) packet to decoder.
- int ret = AVERROR(EAGAIN);
+ int ret = 0;
if (aMovie->packet.stream_index == aMovie->videoStream)
ret = avcodec_send_packet(aMovie->videoContext, &aMovie->packet);
else if (aMovie->packet.stream_index == aMovie->audioStream)
@@ -349,7 +352,8 @@ static int BinkStartMovie(struct binkMovie* aMovie, const char* aFilename,
continue;
}
- if (aMovie->videoStream < 0 && context->codec_type == AVMEDIA_TYPE_VIDEO) {
+ // Music files may contain a video stream, we just ignore it.
+ if (!aMusicFlag && aMovie->videoStream < 0 && context->codec_type == AVMEDIA_TYPE_VIDEO) {
aMovie->videoContext = context;
aMovie->videoStream = i;
aMovie->videoFrame = av_frame_alloc();
@@ -478,18 +482,15 @@ int PlayMusicBink(int volume)
if (!musicMovie.context)
return 1;
- if (musicMovie.audioStream < 0 || !musicMovie.alInited)
+ if (musicMovie.audioStream < 0)
return 1;
alSourcef(musicMovie.alSource, AL_GAIN, PlatVolumeToGain(volume));
- for (int i = 0; i < musicMovie.context->nb_streams * AUDIO_FRAMES; i++) {
- int processedBuffers = 0;
- alGetSourcei(musicMovie.alSource, AL_BUFFERS_PROCESSED, &processedBuffers);
- if (processedBuffers + musicMovie.alNumFreeBuffers > 0)
- if (!ReadPacket(&musicMovie))
- return 0;
+ if (BinkUpdateMovie(&musicMovie) >= 0) {
+ ProcessAudio(&musicMovie);
+ return 1;
}
- return 1;
+ return 0;
}
void EndMusicBink()