1 // Copyright 2008 Brian Caine
3 // This file is part of Potpourri.
5 // Potpourri is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Potpourri is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTIBILITY of FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Potpourri. If not, see <http://www.gnu.org/licenses/>.
20 // machinery..blahblahblah
22 #include "SDLMixerPlugin.h"
23 #include "../../include/plugins/audio/AudioSample.h"
26 using namespace fragrant
;
28 AudioSample
* makeAudioSample(std::string path
, MediaLoader
& loader
)
34 data
= loader
.loadMedia(path
);
37 catch (std::runtime_error
& e
)
39 std::cerr
<< "make_image(): Error loading image\n\t"
40 << e
.what() << std::endl
;
44 SDL_RWops
* const_mem_sauce
= SDL_RWFromConstMem(
45 (const void*)data
.c_str(), data
.size());
46 Mix_Chunk
* chunk
= Mix_LoadWAV_RW(const_mem_sauce
, 1);
48 SDLMixerSample
* sample
= new SDLMixerSample(chunk
);
50 return dynamic_cast<AudioSample
*>(sample
);
53 AudioDevice
* makeDevice()
55 return dynamic_cast<AudioDevice
*>(new SDLMixerDevice
);
58 PluginData
queryPlugin()
62 data
.name
= "SDL_mixer Audio Plugin";
65 data
.authors
.push_back("Brian Caine");
70 Variant
* loadPluginPayload()
72 Variant
* payload
= new Variant
;
75 results
.device_function
= makeDevice
;
76 results
.sample_function
= makeAudioSample
;