Debian Codegraph @

components/output/winamp/winamp.cpp

raw symbols SCIP
1 /* BoCA - BonkEnc Component Architecture
2 * Copyright (C) 2007-2017 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include <smooth.h>
14 #include <smooth/dll.h>
15
16 #include "winamp.h"
17 #include "config.h"
18
19 const String &BoCA::OutputWinamp::GetComponentSpecs()
20 {
21 static String componentSpecs;
22
23 if (winamp_out_plugins.Length() > 0)
24 {
25 componentSpecs = " \
26 \
27 <?xml version=\"1.0\" encoding=\"UTF-8\"?> \
28 <component> \
29 <name>Winamp Output Plug-In Adapter</name> \
30 <version>1.0</version> \
31 <id>winamp-out</id> \
32 <type>output</type> \
33 <input bits=\"8\" signed=\"false\"/> \
34 <input bits=\"16-32\"/> \
35 </component> \
36 \
37 ";
38 }
39
40 return componentSpecs;
41 }
42
43 Void smooth::AttachDLL(Void *instance)
44 {
45 LoadWinampDLLs();
46 }
47
48 Void smooth::DetachDLL()
49 {
50 FreeWinampDLLs();
51 }
52
53 BoCA::OutputWinamp::OutputWinamp()
54 {
55 configLayer = NIL;
56
57 module = NIL;
58 }
59
60 BoCA::OutputWinamp::~OutputWinamp()
61 {
62 if (configLayer != NIL) Object::DeleteObject(configLayer);
63 }
64
65 Bool BoCA::OutputWinamp::Activate()
66 {
67 const Config *config = GetConfiguration();
68 const Format &format = track.GetFormat();
69
70 module = winamp_out_modules.GetNth(config->GetIntValue(ConfigureWinamp::ConfigID, "OutputPlugin", 0));
71
72 return (module->Open(format.rate, format.channels, format.bits, 0, 0) >= 0);
73 }
74
75 Bool BoCA::OutputWinamp::Deactivate()
76 {
77 module->Close();
78
79 return True;
80 }
81
82 Int BoCA::OutputWinamp::WriteData(Buffer<UnsignedByte> &data)
83 {
84 module->Write((char *) (UnsignedByte *) data, data.Size());
85
86 return data.Size();
87 }
88
89 ConfigLayer *BoCA::OutputWinamp::GetConfigurationLayer()
90 {
91 if (configLayer == NIL) configLayer = new ConfigureWinamp();
92
93 return configLayer;
94 }
95
96 Int BoCA::OutputWinamp::CanWrite()
97 {
98 return module->CanWrite();
99 }
100
101 Int BoCA::OutputWinamp::SetPause(Bool pause)
102 {
103 module->Pause(pause);
104
105 return Success();
106 }
107
108 Bool BoCA::OutputWinamp::IsPlaying()
109 {
110 return module->IsPlaying();
111 }