Skip to content

Commit 0ec6618

Browse files
committed
eepp: Updated mojoal, dr_mp3, dr_flac. Fixed various mojoal bugs. Added SoundFileFactory::isKnownFileExtension. SoundFileFactory::isValidAudio, SoundFileFactory::isValidAudioFile.
ecode: Added audio player support (SpartanJ/ecode#96).
1 parent 9d2aec8 commit 0ec6618

39 files changed

+2298
-814
lines changed

.ecode/project_build.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@
306306
"command": "${project_root}/bin/eterm-debug",
307307
"name": "eterm-debug",
308308
"working_dir": "${project_root}/bin"
309+
},
310+
{
311+
"args": "",
312+
"command": "${project_root}/bin/eepp-sound-debug",
313+
"name": "eepp-sound-debug",
314+
"working_dir": "${project_root}/bin"
309315
}
310316
],
311317
"var": {

include/eepp/audio/soundfilefactory.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ class SoundFileWriter;
2222
////////////////////////////////////////////////////////////
2323
class EE_API SoundFileFactory {
2424
public:
25+
// @return True if the file path or extension passed is a known sound file extension
26+
static bool isKnownFileExtension( const std::string& pathOrExtension );
27+
28+
// @return True if the file path contains a valid sound file
29+
static bool isValidAudioFile( const std::string& path );
30+
31+
// @return True if the stream contains a valid sound file
32+
static bool isValidAudio( IOStream& stream );
33+
2534
/// \brief Register a new reader
2635
/// \see unregisterReader
2736
template <typename T> static void registerReader();
@@ -100,6 +109,7 @@ class EE_API SoundFileFactory {
100109
private:
101110
struct ReaderFactory {
102111
bool ( *check )( IOStream& );
112+
bool ( *usesFileExtension )( std::string_view );
103113
SoundFileReader* ( *create )();
104114
};
105115
typedef std::vector<ReaderFactory> ReaderFactoryArray;

include/eepp/audio/soundfilefactory.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void SoundFileFactory::registerReader()
1616
// Create a new factory with the functions provided by the class
1717
ReaderFactory factory;
1818
factory.check = &T::check;
19+
factory.usesFileExtension = &T::usesFileExtension;
1920
factory.create = &priv::createReader<T>;
2021

2122
// Add it

include/eepp/ui.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@
7373
#include <eepp/ui/doc/textdocument.hpp>
7474

7575
#include <eepp/ui/tools/textureatlaseditor.hpp>
76+
#include <eepp/ui/tools/uiaudioplayer.hpp>
7677
#include <eepp/ui/tools/uicodeeditorsplitter.hpp>
7778
#include <eepp/ui/tools/uicolorpicker.hpp>
7879
#include <eepp/ui/tools/uidocfindreplace.hpp>
80+
#include <eepp/ui/tools/uiimageviewer.hpp>
7981
#include <eepp/ui/tools/uiwidgetinspector.hpp>
8082

8183
#include <eepp/ui/models/csspropertiesmodel.hpp>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#ifndef EE_UI_TOOLS_UIAUDIOPLAYER_HPP
2+
#define EE_UI_TOOLS_UIAUDIOPLAYER_HPP
3+
4+
#include <eepp/ui/uirelativelayout.hpp>
5+
6+
namespace EE::Audio {
7+
class Music;
8+
}
9+
10+
namespace EE::UI {
11+
class UIProgressBar;
12+
class UITextView;
13+
} // namespace EE::UI
14+
15+
using namespace EE::UI;
16+
using namespace EE::Audio;
17+
18+
namespace EE::UI::Tools {
19+
20+
class EE_API UIAudioPlayer : public UIRelativeLayout {
21+
public:
22+
static UIAudioPlayer* New();
23+
24+
virtual ~UIAudioPlayer();
25+
26+
virtual Uint32 getType() const override;
27+
28+
virtual bool isType( const Uint32& type ) const override;
29+
30+
Music* getAudio() const;
31+
32+
virtual void scheduledUpdate( const Time& time ) override;
33+
34+
void loadFromPath( const std::string& path, bool autoPlay = true );
35+
36+
const std::string& getFilePath() const;
37+
38+
void play();
39+
40+
void pause();
41+
42+
void stop();
43+
44+
UIProgressBar* getProgressBar() const { return mProgressBar; }
45+
46+
UIWidget* getStatusBtn() const { return mStatusBtn; }
47+
48+
UIWidget* getVolumeBtn() const { return mVolumeBtn; }
49+
50+
UITextView* getTimeView() const { return mTimeView; }
51+
52+
protected:
53+
UIAudioPlayer();
54+
55+
Music* mMusic{ nullptr };
56+
UIProgressBar* mProgressBar{ nullptr };
57+
UIWidget* mStatusBtn{ nullptr };
58+
UIWidget* mVolumeBtn{ nullptr };
59+
UITextView* mTimeView{ nullptr };
60+
std::string mFilePath;
61+
};
62+
63+
} // namespace EE::UI::Tools
64+
65+
#endif

include/eepp/ui/tools/uiimageviewer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class EE_API UIImageViewer : public UIWidget {
3434

3535
static UIImageViewer* New();
3636

37-
UIImageViewer();
38-
3937
virtual ~UIImageViewer();
4038

4139
virtual Uint32 getType() const override;
@@ -97,6 +95,8 @@ class EE_API UIImageViewer : public UIWidget {
9795
Image::Format mCurFileType;
9896
Uint32 mDisplayOptions{ 0 };
9997

98+
UIImageViewer();
99+
100100
virtual void onSizeChange() override;
101101

102102
virtual Uint32 onMessage( const NodeMessage* ) override;
@@ -110,4 +110,4 @@ class EE_API UIImageViewer : public UIWidget {
110110

111111
} // namespace EE::UI::Tools
112112

113-
#endif
113+
#endif

include/eepp/ui/uihelper.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ enum UINodeType {
104104
UI_TYPE_CONSOLE,
105105
UI_TYPE_STACK_LAYOUT,
106106
UI_TYPE_IMAGE_VIEWER,
107+
UI_TYPE_AUDIO_PLAYER,
107108
UI_TYPE_MODULES = 10000,
108109
UI_TYPE_TERMINAL = 10001,
109110
UI_TYPE_USER = 200000

include/eepp/ui/uiprogressbar.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@
77

88
namespace EE { namespace UI {
99

10-
class UIProgressBarFiller;
10+
class UIProgressBar;
11+
12+
class EE_API UIProgressBarFiller : public UIWidget {
13+
public:
14+
static UIProgressBarFiller* New( UIProgressBar* parent );
15+
16+
UIProgressBarFiller( UIProgressBar* parent );
17+
18+
void draw() override;
19+
20+
UIProgressBar* mProgressBar;
21+
UISkin* mFillerSkin;
22+
};
1123

1224
class EE_API UIProgressBar : public UIWidget {
1325
public:
@@ -63,6 +75,8 @@ class EE_API UIProgressBar : public UIWidget {
6375

6476
const StyleConfig& getStyleConfig() const;
6577

78+
UIProgressBarFiller* getFiller() const;
79+
6680
protected:
6781
friend class UIProgressBarFiller;
6882
StyleConfig mStyleConfig;

premake4.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ function build_eepp( build_name )
960960
defines { "PCRE2_STATIC", "PCRE2_CODE_UNIT_WIDTH=8", "ONIG_STATIC" }
961961

962962
if not _OPTIONS["without-mojoal"] then
963-
defines( "AL_LIBTYPE_STATIC" )
963+
defines { "AL_LIBTYPE_STATIC", "EE_MOJOAL" }
964964
includedirs { "src/thirdparty/mojoAL" }
965965
end
966966

@@ -1291,7 +1291,7 @@ solution "eepp"
12911291
project "mojoal-static"
12921292
kind "StaticLib"
12931293
language "C"
1294-
defines( "AL_LIBTYPE_STATIC" )
1294+
defines {"AL_LIBTYPE_STATIC", "EE_MOJOAL" }
12951295
set_targetdir("libs/" .. os.get_real() .. "/thirdparty/")
12961296
includedirs { "include/eepp/thirdparty/mojoAL" }
12971297
files { "src/thirdparty/mojoAL/*.c" }

premake5.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ function build_eepp( build_name )
814814
files { "src/eepp/network/platform/unix/*.cpp" }
815815

816816
filter "options:not without-mojoal"
817-
defines( "AL_LIBTYPE_STATIC" )
817+
defines { "AL_LIBTYPE_STATIC", "EE_MOJOAL" }
818818
incdirs { "src/thirdparty/mojoAL" }
819819

820820
filter "options:windows-vc-build"
@@ -1159,7 +1159,7 @@ workspace "eepp"
11591159
kind "StaticLib"
11601160
language "C"
11611161
incdirs { "include/eepp/thirdparty/mojoAL" }
1162-
defines( "AL_LIBTYPE_STATIC" )
1162+
defines { "AL_LIBTYPE_STATIC", "EE_MOJOAL" }
11631163
files { "src/thirdparty/mojoAL/*.c" }
11641164
build_base_cpp_configuration( "mojoal" )
11651165
target_dir_thirdparty()

0 commit comments

Comments
 (0)