Remove GStreamer audio (replaced by GStreamer# and outdated)

Also some cleanup
This commit is contained in:
Flamefire committed 2014-05-06 21:40:13 +02:00
1 parent 2195af6700
commit cb328c3209
19 files changed
+2 -1117

No files matched your search

-254
View File
@@ -1,254 +0,0 @@
#include "stdafx.h"
#include "GstreamerAudio.h"
#define DllExport extern "C" __declspec(dllexport)
map<int, GstreamerAudioStream*> Streams;
queue<int> IDs;
float GlobalVolume = 1.f;
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
DllExport void SetLogCallback (LogCallback Callback)
{
Log = Callback;
}
DllExport bool Init()
{
for(int i = 0; i < 1000; i++)
{
IDs.push(i);
}
#if _WIN64
SetDllDirectory(L".\\x64\\gstreamer");
#else
SetDllDirectory(L".\\x86\\gstreamer");
#endif
gst_init(NULL, NULL);
GstRegistry* registry = gst_registry_get();
#if _WIN64
gst_registry_scan_path(registry, ".\\x64\\gstreamer");
#else
gst_registry_scan_path(registry, ".\\x86\\gstreamer");
#endif
return true;
}
DllExport void SetGlobalVolume(float Volume)
{
map<int, GstreamerAudioStream*>::iterator p;
for(p = Streams.begin(); p != Streams.end(); p++) {
p->second->SetStreamVolumeMax(Volume);
}
GlobalVolume = Volume;
}
DllExport float GetGlobalVolume(){
return GlobalVolume;
}
DllExport int GetStreamCount(void)
{
return Streams.size();
}
DllExport void CloseAll(void)
{
map<int, GstreamerAudioStream*>::iterator p;
for(p = Streams.begin(); p != Streams.end(); p++) {
p->second->Close();
}
}
DllExport int Load(const wchar_t* Media)
{
GstreamerAudioStream *s = new GstreamerAudioStream(IDs.front());
Streams.insert(pair<int, GstreamerAudioStream*> (IDs.front(), s));
IDs.pop();
int result = s->Load(Media);
s->SetStreamVolume(1.f);
s->SetStreamVolumeMax(GlobalVolume);
return result;
}
DllExport int LoadPrescan(const wchar_t* Media, bool Prescan)
{
GstreamerAudioStream *s = new GstreamerAudioStream(IDs.front());
Streams.insert(pair<int, GstreamerAudioStream*> (IDs.front(), s));
IDs.pop();
int result = s->Load(Media, Prescan);
s->SetStreamVolume(1.f);
s->SetStreamVolumeMax(GlobalVolume);
return result;
}
DllExport void Close(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
delete it->second;
IDs.push(it->first);
Streams.erase(it);
}
}
DllExport void Play(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->Play();
}
}
DllExport void PlayLoop(int Stream, bool Loop)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->Play(Loop);
}
}
DllExport void Pause(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->Pause();
}
}
DllExport void Stop(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->Stop();
}
}
DllExport void Fade(int Stream, float TargetVolume, float Seconds)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->Fade(TargetVolume, Seconds);
}
}
DllExport void FadeAndPause(int Stream, float TargetVolume, float Seconds)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->FadeAndPause(TargetVolume, Seconds);
}
}
DllExport void FadeAndStop(int Stream, float TargetVolume, float Seconds)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
it->second->FadeAndStop(TargetVolume, Seconds);
}
}
DllExport void SetStreamVolume(int Stream, float Volume)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->SetStreamVolume(Volume);
}
}
DllExport float GetLength(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->GetLength();
}
else return -1.0;
}
DllExport float GetPosition(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->GetPosition();
}
else return -1;
}
DllExport bool IsPlaying(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->IsPlaying();
}
else return false;
}
DllExport bool IsPaused(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->IsPaused();
}
else return false;
}
DllExport bool IsFinished(int Stream)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->IsFinished();
}
else return false;
}
DllExport void SetPosition(int Stream, float Position)
{
map<int,GstreamerAudioStream*>::iterator it = Streams.find(Stream);
if(it != Streams.end())
{
return it->second->SetPosition(Position);
}
}
DllExport void Update(void)
{
map<int, GstreamerAudioStream*>::iterator p = Streams.begin();
while(p != Streams.end())
{
if(p->second->Closed)
{
delete p->second;
IDs.push(p->first);
Streams.erase(p++);
}
else {
p->second->Update();
++p;
}
}
}
void LogError(const char* msg)
{
Log(msg);
}
-49
View File
@@ -1,49 +0,0 @@
#pragma once
#include <string>
#include <map>
#include <queue>
#include "gst/gst.h"
#include "GstreamerAudioStream.h"
#include "gst\gst.h"
#define DllExport extern "C" __declspec(dllexport)
using namespace std;
typedef void (__stdcall * LogCallback)(const char* text);
static LogCallback Log;
DllExport void SetLogCallback(LogCallback Callback);
DllExport bool Init();
DllExport void SetGlobalVolume(float Volume);
DllExport float GetGlobalVolume();
DllExport int GetStreamCount(void);
DllExport void CloseAll(void);
//Stream handling
DllExport int Load(const wchar_t* Media);
DllExport int LoadPrescan(const wchar_t* Media, bool Prescan);
DllExport void Close(int Stream);
DllExport void Play(int Stream);
DllExport void PlayLoop(int Stream, bool Loop);
DllExport void Pause(int Stream);
DllExport void Stop(int Stream);
DllExport void Fade(int Stream, float TargetVolume, float Seconds);
DllExport void FadeAndPause(int Stream, float TargetVolume, float Seconds);
DllExport void FadeAndStop(int Stream, float TargetVolume, float Seconds);
DllExport void SetStreamVolume(int Stream, float Volume);
DllExport float GetLength(int Stream);
DllExport float GetPosition(int Stream);
DllExport bool IsPlaying(int Stream);
DllExport bool IsPaused(int Stream);
DllExport bool IsFinished(int Stream);
DllExport void SetPosition(int Stream, float Position);
DllExport void Update();
void LogError(const char* msg);
-338
View File
@@ -1,338 +0,0 @@
#include "stdafx.h"
#include "GstreamerAudioStream.h"
typedef enum {
GST_PLAY_FLAG_VIDEO = (1 << 0),
GST_PLAY_FLAG_AUDIO = (1 << 1),
GST_PLAY_FLAG_TEXT = (1 << 2),
GST_PLAY_FLAG_VIS = (1 << 3),
GST_PLAY_FLAG_SOFT_VOLUME = (1 << 4),
GST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5),
GST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6),
GST_PLAY_FLAG_DOWNLOAD = (1 << 7),
GST_PLAY_FLAG_BUFFERING = (1 << 8),
GST_PLAY_FLAG_DEINTERLACE = (1 << 9),
GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10)
} GstPlayFlags;
GstreamerAudioStream::GstreamerAudioStream(int id)
{
ID = id;
MaxVolume = 1.0;
Volume = 1.0;
Duration = -1;
Loop = false;
Running = true;
Finished = false;
//Fading
FadeTimer = g_timer_new();
FadeTime = 0.0;
TargetVolume = 1.0;
StartVolume = 1.0;
CloseStreamAfterFade = false;
PauseStreamAfterFade = false;
Fading = false;
Closed = false;
}
GstreamerAudioStream::~GstreamerAudioStream(void)
{
Close();
}
// Loads a stream but does not wait for it to get initialized,
// so querying duration or position directly after initialization might
// return strange values! To work around this use the prescan load function!
int GstreamerAudioStream::Load(const wchar_t* Media)
{
Element = gst_element_factory_make("playbin", "playbin");
Convert = gst_element_factory_make("audioconvert", "audioconvert");
Audiosink = gst_element_factory_make("directsoundsink", "directsoundsink");
SinkBin = gst_bin_new("SinkBin");
gst_bin_add_many (GST_BIN (SinkBin), Convert, Audiosink, NULL);
gst_element_link_many (Convert, Audiosink, NULL);
Pad = gst_element_get_static_pad (Convert, "sink");
GhostPad = gst_ghost_pad_new ("sink", Pad);
gst_pad_set_active (GhostPad, TRUE);
gst_element_add_pad (SinkBin, GhostPad);
Bus = gst_element_get_bus(Element);
if(!Element)
{
LogError ("Could not create element!");
return -1;
}
Running = true;
gst_element_set_state(Element, GST_STATE_NULL);
g_object_set(Element, "uri", Media, NULL);
g_object_set(Element, "audio-sink", SinkBin, NULL);
g_object_set(Element, "flags", GST_PLAY_FLAG_AUDIO, NULL);
gst_element_set_state(Element, GST_STATE_PAUSED);
return ID;
}
//Loads a stream and waits for its initialization
int GstreamerAudioStream::Load(const wchar_t* Media, bool Prescan)
{
Load(Media);
if(Prescan){
gst_bus_timed_pop_filtered(Bus, -1, GST_MESSAGE_ASYNC_DONE);
//Workaround: Waiting for the stream to be loaded (Length>0)
for(int i=0;i<40;i++){
if(GetLength()>0.f)
break;
Sleep(5);
}
}
return ID;
}
void GstreamerAudioStream::Close(void)
{
if(Element)
{
gst_element_set_state(Element, GST_STATE_NULL);
gst_object_unref(GST_OBJECT (Element));
}
/* without that there are no crashes any more. but i don't know if there is a memory leak if we do that.
if(Bus)
gst_object_unref(Bus);
if(Message)
gst_message_unref(Message);
if(Convert)
gst_object_unref(Convert);
if(Audiosink)
gst_object_unref(Audiosink);
if(Pad)
gst_object_unref(Pad);
if(GhostPad)
gst_object_unref(GhostPad);
if(SinkBin)
gst_object_unref(SinkBin);
*/
if(FadeTimer)
g_timer_destroy (FadeTimer);
Running = false;
Closed = true;
}
void GstreamerAudioStream::Play(void)
{
if(Element)
{
PauseStreamAfterFade = false;
Running = true;
if(gst_element_set_state(Element, GST_STATE_PLAYING) == GST_STATE_CHANGE_ASYNC)
gst_bus_timed_pop_filtered(Bus, -1, GST_MESSAGE_ASYNC_DONE);
SetStreamVolume(Volume * 100.0);
}
}
void GstreamerAudioStream::Play(bool Loop)
{
this->Loop = Loop;
Play();
}
void GstreamerAudioStream::Pause()
{
Running = true;
if(Element)
gst_element_set_state(Element, GST_STATE_PAUSED);
SetStreamVolume(Volume * 100.0);
}
void GstreamerAudioStream::Stop()
{
if(Element)
{
gst_element_set_state(Element, GST_STATE_NULL);
gst_element_seek_simple(Element, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 0);
}
}
void GstreamerAudioStream::SetStreamVolume(float Volume)
{
this->Volume = Volume / 100.0;
if(Element)
{
g_object_set(this->Element, "volume", (gdouble)(Volume / 100.0) * MaxVolume, NULL);
}
}
void GstreamerAudioStream::SetStreamVolumeMax(float MaxVolume)
{
this->MaxVolume = (gdouble) (MaxVolume / 100.0);
if(Element)
{
g_object_set(this->Element, "volume", Volume * this->MaxVolume, NULL);
}
}
float GstreamerAudioStream::GetLength()
{
if(Duration <= 0.f)
RefreshDuration();
return Duration;
}
void GstreamerAudioStream::RefreshDuration()
{
if(Element)
{
gint64 time = -1000;
if(gst_element_query_duration(Element, GST_FORMAT_TIME, &time))
Duration = (gfloat)((gdouble)time/GST_SECOND);
}
}
float GstreamerAudioStream::GetPosition()
{
if(Element)
{
gint64 time = 0;
if (gst_element_query_position(Element, GST_FORMAT_TIME, &time))
return (float)((gdouble)time/GST_SECOND);
else
return -1;
}
else return -1;
}
void GstreamerAudioStream::SetPosition(float Position)
{
if(Element)
{
//Not sure if we need GST_SEEK_FLAG_ACCURATE
if(!gst_element_seek_simple(Element, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE), Position * GST_SECOND))
LogError("Seek failed");
}
}
void GstreamerAudioStream::Fade(float TargetVolume, float Seconds)
{
Fading = true;
g_timer_stop(FadeTimer);
StartVolume = Volume;
this->TargetVolume = TargetVolume / 100.0;
FadeTime = (gdouble)Seconds;
g_timer_start(FadeTimer);
}
void GstreamerAudioStream::FadeAndPause(float TargetVolume, float Seconds)
{
PauseStreamAfterFade = true;
Fade(TargetVolume, Seconds);
}
void GstreamerAudioStream::FadeAndStop(float TargetVolume, float Seconds)
{
CloseStreamAfterFade = true;
Fade(TargetVolume, Seconds);
}
bool GstreamerAudioStream::IsPlaying()
{
GstStateChangeReturn ret;
GstState current, pending;
//This might block!!!
ret = gst_element_get_state (Element, &current, &pending, GST_CLOCK_TIME_NONE);
return current == GST_STATE_PLAYING && !Finished;
}
bool GstreamerAudioStream::IsPaused()
{
GstStateChangeReturn ret;
GstState current, pending;
//This might block!!!
ret = gst_element_get_state (Element, &current, &pending, GST_CLOCK_TIME_NONE);
return current == GST_STATE_PAUSED && !Finished;
}
bool GstreamerAudioStream::IsFinished()
{
return Finished;
}
void GstreamerAudioStream::UpdateVolume()
{
if (Fading)
{
if (g_timer_elapsed(FadeTimer, NULL) < FadeTime) {
gdouble vol = (StartVolume + (TargetVolume - StartVolume) * (g_timer_elapsed(FadeTimer, NULL) / FadeTime));
SetStreamVolume(100.0 * vol);
}
else
{
SetStreamVolume (TargetVolume * 100.0);
g_timer_stop(FadeTimer);
Fading = false;
if (CloseStreamAfterFade)
{
Closed = true;
}
if (PauseStreamAfterFade)
Pause();
}
}
}
void GstreamerAudioStream::Update()
{
if(Running) {
UpdateVolume();
Message = gst_bus_pop (Bus);
/* Parse message */
if (Message != NULL) {
GError *err;
gchar *debug_info;
string m;
switch (GST_MESSAGE_TYPE (Message)) {
case GST_MESSAGE_ERROR:
gst_message_parse_error (Message, &err, &debug_info);
m = err->message;
LogError(m.c_str());
g_clear_error (&err);
g_free (debug_info);
break;
case GST_MESSAGE_DURATION_CHANGED:
RefreshDuration();
break;
case GST_MESSAGE_STATE_CHANGED:
break;
case GST_MESSAGE_EOS:
if(Loop)
SetPosition(0);
else
Finished = true;
break;
default:
/* We should not reach here */
//LogError ("Unexpected message received.\n");
break;
}
gst_message_unref (Message);
}
}
}
-73
View File
@@ -1,73 +0,0 @@
#pragma once
#pragma warning(disable: 4244) // possible loss of data
#pragma warning(disable: 4267) // possible loss of data
#pragma warning(disable: 4800)
#include <string>
#include "gst/gst.h"
#include "GstreamerAudio.h"
using namespace std;
class GstreamerAudioStream
{
public:
int ID;
bool Closed;
GstreamerAudioStream(int ID);
~GstreamerAudioStream(void);
int Load(const wchar_t* Media);
int Load(const wchar_t* Media, bool Prescan);
void Close();
void Play();
void Play(bool Loop);
void Pause();
void Stop();
void Fade(float TargetVolume, float Seconds);
void FadeAndPause(float TargetVolume, float Seconds);
void FadeAndStop(float TargetVolume, float Seconds);
void SetStreamVolume(float Volume);
void SetStreamVolumeMax(float Volume);
float GetLength();
float GetPosition();
void SetPosition(float Position);
bool IsPlaying();
bool IsPaused();
bool IsFinished();
void Update();
private:
GstElement *Element, *Audiosink, *Convert, *SinkBin;
GstPad *Pad, *GhostPad;
GstBus *Bus;
GstMessage *Message;
gboolean Running;
gboolean Loop;
gboolean Finished;
gdouble MaxVolume;
gdouble Volume;
gfloat Duration;
GTimer *FadeTimer;
gdouble FadeTime;
gdouble TargetVolume;
gdouble StartVolume;
gboolean CloseStreamAfterFade;
gboolean PauseStreamAfterFade;
gboolean Fading;
void RefreshDuration();
void UpdateVolume();
};
+1 -35
View File
@@ -169,7 +169,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugWin|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GSTREAMERHELPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -282,47 +282,13 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="GstreamerAudio.h" />
<ClInclude Include="GstreamerAudioStream.h" />
<ClInclude Include="GstreamerVideo.h" />
<ClInclude Include="GstreamerVideoStream.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="VocaluxeClock.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='DebugWin|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='DebugWin|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugWin|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugWin|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='InstallerWin|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|x64'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='InstallerWin|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='InstallerWin|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|x64'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='InstallerWin|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="GstreamerAudio.cpp" />
<ClCompile Include="GstreamerAudioStream.cpp" />
<ClCompile Include="GstreamerVideo.cpp" />
<ClCompile Include="GstreamerVideoStream.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugWin|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugWin|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='InstallerWin|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='InstallerWin|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="VocaluxeClock.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
@@ -15,18 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="GstreamerAudioStream.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="GstreamerAudio.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="GstreamerVideo.h">
<Filter>Headerdateien</Filter>
</ClInclude>
@@ -38,18 +26,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="GstreamerAudioStream.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="GstreamerAudio.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="GstreamerVideo.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
-1
View File
@@ -1,4 +1,3 @@
#include "stdafx.h"
#include "GstreamerVideo.h"
#include "GstreamerVideoStream.h"
-1
View File
@@ -1,4 +1,3 @@
#include "stdafx.h"
#include "GstreamerVideoStream.h"
typedef enum {
-19
View File
@@ -1,19 +0,0 @@
// dllmain.cpp : Definiert den Einstiegspunkt für die DLL-Anwendung.
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
-8
View File
@@ -1,8 +0,0 @@
// stdafx.cpp : Quelldatei, die nur die Standard-Includes einbindet.
// GstreamerHelper.pch ist der vorkompilierte Header.
// stdafx.obj enthält die vorkompilierten Typinformationen.
#include "stdafx.h"
// TODO: Auf zusätzliche Header verweisen, die in STDAFX.H
// und nicht in dieser Datei erforderlich sind.
-16
View File
@@ -1,16 +0,0 @@
// stdafx.h : Includedatei für Standardsystem-Includedateien
// oder häufig verwendete projektspezifische Includedateien,
// die nur in unregelmäßigen Abständen geändert werden.
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Selten verwendete Teile der Windows-Header nicht einbinden.
// Windows-Headerdateien:
#include <windows.h>
// TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen.
-8
View File
@@ -1,8 +0,0 @@
#pragma once
// Durch Einbeziehen von"SDKDDKVer.h" wird die höchste verfügbare Windows-Plattform definiert.
// Wenn Sie die Anwendung für eine frühere Windows-Plattform erstellen möchten, schließen Sie "WinSDKVer.h" ein, und
// legen Sie das _WIN32_WINNT-Makro auf die zu unterstützende Plattform fest, bevor Sie "SDKDDKVer.h" einschließen.
#include <SDKDDKVer.h>
+1 -1
View File
@@ -95,7 +95,7 @@ namespace Vocaluxe.Base
public static ELyricStyle LyricStyle = ELyricStyle.Slide;
// Sound
public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer;
public static EPlaybackLib PlayBackLib = EPlaybackLib.GstreamerSharp;
public static EBufferSize AudioBufferSize = EBufferSize.B2048;
public static int AudioLatency;
private static int _BackgroundMusicVolume = 30;
-5
View File
@@ -18,7 +18,6 @@
using System;
using System.IO;
using Vocaluxe.Lib.Sound.Playback;
using Vocaluxe.Lib.Sound.Playback.Gstreamer;
using Vocaluxe.Lib.Sound.Playback.GstreamerSharp;
using Vocaluxe.Lib.Sound.Playback.OpenAL;
using Vocaluxe.Lib.Sound.Playback.PortAudio;
@@ -51,10 +50,6 @@ namespace Vocaluxe.Base
_Playback = new COpenALPlay();
break;
case EPlaybackLib.Gstreamer:
_Playback = new CGstreamerAudio();
break;
case EPlaybackLib.GstreamerSharp:
_Playback = new CGstreamerSharpAudio();
break;
@@ -1,162 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Vocaluxe.Base;
namespace Vocaluxe.Lib.Sound.Playback.Gstreamer
{
class CGstreamerAudio : IPlayback
{
private readonly CGstreamerAudioWrapper.LogCallback _LogCallback;
#region log
private static void _LogHandler(string text)
{
CLog.LogError(text);
}
#endregion log
public CGstreamerAudio()
{
_LogCallback = _LogHandler;
CGstreamerAudioWrapper.SetLogCallback(_LogCallback);
}
public bool Init()
{
return CGstreamerAudioWrapper.Init();
}
public void Close()
{
CloseAll();
CGstreamerAudioWrapper.SetLogCallback(null);
}
public float GetGlobalVolume()
{
return CGstreamerAudioWrapper.GetGlobalVolume();
}
public void SetGlobalVolume(float volume)
{
CGstreamerAudioWrapper.SetGlobalVolume(volume);
}
public int GetStreamCount()
{
return CGstreamerAudioWrapper.GetStreamCount();
}
public void CloseAll()
{
CGstreamerAudioWrapper.CloseAll();
}
public int Load(string medium, bool loop = false, bool prescan = false)
{
var u = new Uri(medium);
int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri, prescan);
//Workaround b/c I'm lazy:
CGstreamerAudioWrapper.Play(i, loop);
CGstreamerAudioWrapper.Pause(i);
return i;
}
public void Close(int stream)
{
CGstreamerAudioWrapper.Close(stream);
}
public void Play(int stream)
{
CGstreamerAudioWrapper.Play(stream);
}
public void Pause(int stream)
{
CGstreamerAudioWrapper.Pause(stream);
}
public void Stop(int stream)
{
CGstreamerAudioWrapper.Stop(stream);
}
public void Fade(int streamID, float targetVolume, float seconds, EStreamAction afterFadeAction = EStreamAction.Nothing)
{
switch (afterFadeAction)
{
case EStreamAction.Nothing:
CGstreamerAudioWrapper.Fade(streamID, targetVolume, seconds);
break;
case EStreamAction.Pause:
CGstreamerAudioWrapper.FadeAndPause(streamID, targetVolume, seconds);
break;
case EStreamAction.Stop:
CGstreamerAudioWrapper.FadeAndStop(streamID, targetVolume, seconds);
break;
case EStreamAction.Close:
CGstreamerAudioWrapper.FadeAndStop(streamID, targetVolume, seconds);
break;
default:
throw new ArgumentOutOfRangeException("afterFadeAction");
}
}
public void SetStreamVolume(int stream, float volume)
{
CGstreamerAudioWrapper.SetStreamVolume(stream, volume);
}
public float GetLength(int stream)
{
return CGstreamerAudioWrapper.GetLength(stream);
}
public float GetPosition(int stream)
{
return CGstreamerAudioWrapper.GetPosition(stream);
}
public bool IsPlaying(int stream)
{
return CGstreamerAudioWrapper.IsPlaying(stream);
}
public bool IsPaused(int stream)
{
return CGstreamerAudioWrapper.IsPaused(stream);
}
public bool IsFinished(int stream)
{
return CGstreamerAudioWrapper.IsFinished(stream);
}
public void SetPosition(int stream, float position)
{
CGstreamerAudioWrapper.SetPosition(stream, position);
}
public void Update()
{
CGstreamerAudioWrapper.Update();
}
}
}
@@ -1,119 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Sound.Playback.Gstreamer
{
public static class CGstreamerAudioWrapper
{
#region arch
#if ARCH_X86
#if WIN
private const string _Dll = "x86\\gstreamer\\GstreamerHelper.dll";
#endif
#endif
#if ARCH_X64
#if WIN
private const string _Dll = "x64\\gstreamer\\GstreamerHelper.dll";
#endif
#endif
#endregion arch
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void LogCallback(string message);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetLogCallback(LogCallback c);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool Init();
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetGlobalVolume(float volume);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern float GetGlobalVolume();
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetStreamCount();
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void CloseAll();
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int Load(string media);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "LoadPrescan")]
public static extern int Load(string media,
[MarshalAs(UnmanagedType.U1)] bool prescan);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Close(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Play(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PlayLoop")]
public static extern void Play(int stream,
[MarshalAs(UnmanagedType.U1)] bool loop);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Pause(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Stop(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Fade(int stream, float targetVolume, float seconds);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void FadeAndPause(int stream, float targetVolume, float seconds);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void FadeAndStop(int stream, float targetVolume, float seconds);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetStreamVolume(int stream, float volume);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern float GetLength(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern float GetPosition(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool IsPlaying(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool IsPaused(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool IsFinished(int stream);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetPosition(int stream, float position);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Update();
}
}
-2
View File
@@ -308,14 +308,12 @@
<Compile Include="Lib\Input\WiiMote\WiiMoteLib.cs" />
<Compile Include="Lib\Playlist\CPlaylistFile.cs" />
<Compile Include="Lib\Sound\Record\DirectSound\CDirectSoundRecord.cs" />
<Compile Include="Lib\Sound\Playback\Gstreamer\CGstreamerAudio.cs" />
<Compile Include="Lib\Sound\Playback\OpenAL\COpenALPlay.cs" />
<Compile Include="Base\CSound.cs" />
<Compile Include="Lib\Sound\Playback\PortAudio\CPortAudioPlay.cs" />
<Compile Include="Lib\Sound\Record\PortAudio\CPortAudioRecord.cs" />
<Compile Include="Lib\Sound\Playback\Decoder\CAudioDecoderFFmpeg.cs" />
<Compile Include="Lib\Sound\Playback\Decoder\IAudioDecoder.cs" />
<Compile Include="Lib\Sound\Playback\Gstreamer\CGstreamerAudioWrapper.cs" />
<Compile Include="Lib\Sound\Playback\IPlayback.cs" />
<Compile Include="Lib\Sound\Record\IRecord.cs" />
<Compile Include="Lib\Video\Acinerella\CAcinerella.cs" />
-1
View File
@@ -144,7 +144,6 @@ namespace VocaluxeLib
{
PortAudio,
OpenAL,
Gstreamer,
GstreamerSharp
}
-1
View File
@@ -1,4 +1,3 @@
#include "stdafx.h"
#include "VocaluxeClock.h"
static void vocaluxe_clock_class_init (VocaluxeClockClass * klass);