Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
OggSound.cpp
1/*
2Copyright (C) 2017,2018 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#include "OggSound.h"
17#include "vorbis/codec.h"
18#include <fstream>
19#include <algorithm>
20#include <exception>
21#include <stdexcept>
22
23namespace AeonGames
24{
25 bool DecodeOGG ( Sound& aSound, size_t aBufferSize, const void* aBuffer )
26 {
27 return false;
28 }
29 size_t OggSound::Read ( void *ptr, size_t size, size_t nmemb, void *datasource )
30 {
31 auto* ogg_sound = static_cast<OggSound*> ( datasource );
32 ( void ) ogg_sound;
33 return 0;
34 }
35 int OggSound::Seek ( void *datasource, ogg_int64_t offset, int whence )
36 {
37 auto* ogg_sound = static_cast<OggSound*> ( datasource );
38 ( void ) ogg_sound;
39 return 0;
40 }
41 int OggSound::Close ( void *datasource )
42 {
43 auto* ogg_sound = static_cast<OggSound*> ( datasource );
44 ( void ) ogg_sound;
45 return 0;
46 }
47 long OggSound::Tell ( void *datasource )
48 {
49 auto* ogg_sound = static_cast<OggSound*> ( datasource );
50 ( void ) ogg_sound;
51 return 0;
52 }
53
54 const ov_callbacks OggSound::Callbacks
55 {
56 Read,
57 Seek,
58 Close,
59 Tell
60 };
61
62 OggSound::OggSound ( const std::string & aFileName )
63 {
64 //--------------------------------------------------------
65 // File loading code
66 std::ifstream file;
67 file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
68 file.open ( aFileName, std::ios::binary );
69 mData = std::vector<uint8_t> ( ( std::istreambuf_iterator<char> ( file ) ),
70 ( std::istreambuf_iterator<char>() ) );
71 file.close();
72 //--------------------------------------------------------
73 }
74
76 = default;
77}
OggSound(const std::string &aFileName)
Constructs an OggSound by loading from the specified file.
Definition OggSound.cpp:62
~OggSound() final
Destructor.
Abstract base class representing a decoded sound resource.
Definition Sound.hpp:27
<- This is here just for the literals
Definition AABB.hpp:31
bool DecodeOGG(Sound &aSound, size_t aBufferSize, const void *aBuffer)
Decodes OGG Vorbis audio data from a memory buffer into a Sound.
Definition OggSound.cpp:25