aboutsummaryrefslogtreecommitdiff
path: root/Src/libvp6/include/MP3.hpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/libvp6/include/MP3.hpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/libvp6/include/MP3.hpp')
-rw-r--r--Src/libvp6/include/MP3.hpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/Src/libvp6/include/MP3.hpp b/Src/libvp6/include/MP3.hpp
new file mode 100644
index 00000000..1ac9ede0
--- /dev/null
+++ b/Src/libvp6/include/MP3.hpp
@@ -0,0 +1,109 @@
+#ifndef MP3_HPP
+#define MP3_HPP
+//______________________________________________________________________________
+//
+// MP3.hpp
+//
+
+//______________________________________________________________________________
+//
+
+#pragma warning(disable:4786)
+
+#include "mp3header.hpp"
+#include <windows.h>
+#include <string>
+#include <exception>
+#include <iosfwd>
+
+namespace MP3
+{
+
+//______________________________________________________________________________
+//
+
+ typedef __int64 offset_t;
+
+ //--------------------------------------
+ class Exception : public std::exception
+ {
+ public:
+ Exception(DWORD dwMessage);
+ Exception(const char* szMessage);
+ const char* what() const;
+ private:
+ std::string m_strMessage;
+ };
+
+ //--------------------------------------
+ struct Header
+ {
+ unsigned long m_ulChannels;
+ unsigned long m_ulSamplesPerSecond;
+ unsigned long m_ulSamplesPerBlock;
+ unsigned long m_ulBytesPerBlock;
+ unsigned long m_ulBlocks;
+
+ void clear();
+ };
+
+ std::ostream& operator<<(std::ostream& os, const Header& h);
+
+ //--------------------------------------
+ class File
+ {
+ public:
+
+ enum mode_t {in, out, inout};
+
+ File();
+ File(const char* szName, mode_t mode);
+
+ ~File();
+
+ void open(const char* szName, mode_t mode, DWORD dwFlags = 0);
+ void close();
+
+ bool isOpen() const;
+ bool eof() const;
+
+ const char* name() const;
+ mode_t mode() const;
+
+ unsigned long channels() const;
+ unsigned long samplesPerSecond() const;
+ unsigned long samplesPerBlock() const;
+ unsigned long bytesPerBlock() const;
+ unsigned long blocks() const;
+
+ const Header& header() const;
+
+ void read(void* pBuffer, size_t size) const;
+ void write(const void* pBuffer, size_t size);
+
+ void seek(offset_t) const;
+
+ private:
+
+ File(const File& f); // Not implemented
+ File& operator=(const File& f); // Not implemented
+
+ int readHeader();
+
+ offset_t size() const;
+ offset_t tell() const;
+
+ HANDLE m_handle;
+
+ std::string m_strName;
+ mode_t m_mode;
+
+ Header m_header;
+
+ offset_t m_fileSize;
+ offset_t m_fileOffset;
+ };
+
+} // namespace MP3
+
+#endif // MP3_HPP