Kolja Strohm 3 лет назад
Родитель
Сommit
a49c216714
10 измененных файлов с 497 добавлено и 540 удалено
  1. 2 2
      GSL Linux/GSL Linux.vcxproj
  2. BIN
      GSL Linux/dbggsl.so
  3. BIN
      GSL Linux/gsl.so
  4. 19 19
      GSL/Einstieg.cpp
  5. 387 402
      GSL/GSLDatei.cpp
  6. 36 40
      GSL/GSLDatei.h
  7. 1 4
      GSL/Include/GSLDateiV.h
  8. 0 3
      GSL/Include/GSLSoundV.h
  9. 2 17
      GSL/Sound.cpp
  10. 50 53
      GSL/Sound.h

+ 2 - 2
GSL Linux/GSL Linux.vcxproj

@@ -50,7 +50,7 @@
   <ImportGroup Label="PropertySheets" />
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <IncludePath>..\..\Framework;../../Framework/release;$(IncludePath);$(ISenseIncludePath);../GSL/Include</IncludePath>
+    <IncludePath>..\..\Framework;../../../Framework/release;$(IncludePath);$(ISenseIncludePath);../GSL/Include</IncludePath>
     <TargetName>gsl</TargetName>
     <TargetExt>.so</TargetExt>
     <RemoteProjectDir>$(RemoteRootDir)/gsl/release</RemoteProjectDir>
@@ -61,7 +61,7 @@
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <IncludePath>..\..\Framework;../../Framework/debug;$(IncludePath);$(ISenseIncludePath);../GSL/Include</IncludePath>
+    <IncludePath>..\..\Framework;../../../Framework/debug;$(IncludePath);$(ISenseIncludePath);../GSL/Include</IncludePath>
     <TargetName>dbggsl</TargetName>
     <TargetExt>.so</TargetExt>
     <RemoteProjectDir>$(RemoteRootDir)/gsl/debug</RemoteProjectDir>

BIN
GSL Linux/dbggsl.so


BIN
GSL Linux/gsl.so


+ 19 - 19
GSL/Einstieg.cpp

@@ -9,29 +9,29 @@ static int numInits = 0;
 
 int WINAPI DllMain( HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved )
 {
-	switch( fdwReason )
-	{
-	case DLL_PROCESS_DETACH:
-		delete _player;
-		_player = 0;
-		break;
-	case DLL_PROCESS_ATTACH:
-		_player = new GSLPlayer();
-		return 1;
-	}
-	return 0;
+    switch( fdwReason )
+    {
+    case DLL_PROCESS_DETACH:
+        delete _player;
+        _player = 0;
+        break;
+    case DLL_PROCESS_ATTACH:
+        _player = new GSLPlayer();
+        return 1;
+    }
+    return 0;
 }
 #endif
 
 extern "C"
 {
-	__declspec( dllexport ) GSLSoundV *getSound( SoundKopf &kpf )
-	{
-		return new GSLSound( kpf );
-	}
+    __declspec( dllexport ) GSLSoundV *getSound( SoundKopf &kpf )
+    {
+        return new GSLSound( kpf );
+    }
 
-	__declspec( dllexport ) GSLDateiV *getGSLDatei()
-	{
-		return new GSLDatei();
-	}
+    __declspec( dllexport ) GSLDateiV *getGSLDatei()
+    {
+        return new GSLDatei();
+    }
 }

+ 387 - 402
GSL/GSLDatei.cpp

@@ -10,487 +10,472 @@ using namespace GSL;
 // Inhalt der GSLDatei Klasse aus GSLDatei.h
 // Konstruktor
 GSLDatei::GSLDatei()
+    : ReferenceCounter()
 {
-	sounds = new Array< SoundKopf >();
-	pfad = new Text();
-	ref = 1;
+    sounds = new Array< SoundKopf >();
+    pfad = new Text();
 }
 
 // Destruktor
 GSLDatei::~GSLDatei()
 {
-	sounds->release();
-	pfad->release();
+    sounds->release();
+    pfad->release();
 }
 
 // Datei open
 void GSLDatei::setDatei( Framework::Text *txt )
 {
     cs.lock();
-	pfad->setText( txt );
+    pfad->setText( txt );
     cs.unlock();
 }
 
 void GSLDatei::setDatei( char *txt )
 {
     cs.lock();
-	pfad->setText( txt );
+    pfad->setText( txt );
     cs.unlock();
 }
 
 bool GSLDatei::leseDaten()
 {
     cs.lock();
-	sounds->leeren();
-	Datei d;
-	d.setDatei( *pfad );
+    sounds->leeren();
+    Datei d;
+    d.setDatei( *pfad );
     if( !d.getSize() )
     {
         cs.unlock();
         return 1;
     }
-	if( !d.open( Datei::Style::lesen ) )
-	{
+    if( !d.open( Datei::Style::lesen ) )
+    {
         cs.unlock();
-		return 0;
-	}
-	unsigned char sAnz = 0;
-	d.lese( (char*)&sAnz, 1 );
-	// Datei Sound - Köpfe einlesen
-	for( int i = 0; i < sAnz; i++ )
-	{
-		SoundKopf kpf;
-		bool bit = 0;
-		char len = 0;
-		// Namenslänge lesen
-		for( int i = 0; i < 4; i++ )
-		{
-			d.getNextBit( bit );
-			len = (char)( len | ( ( (char)bit << ( 3 - i ) ) & ( 1 << ( 3 - i ) ) ) );
-		}
-		len &= 15;
-		// Name lesen
-		for( int i = 0; i < len; i++ )
-		{
-			char zeichen = 0;
-			for( int j = 0; j < 5; j++ )
-			{
-				d.getNextBit( bit );
-				zeichen = (char)( zeichen | ( ( (char)bit << ( 4 - j ) ) & ( 1 << ( 4 - j ) ) ) );
-			}
-			zeichen &= 31;
-			if( zeichen == 27 )
-				zeichen = 'ü';
-			if( zeichen == 28 )
-				zeichen = 'ö';
-			if( zeichen == 29 )
-				zeichen = 'ä';
-			if( zeichen == 30 )
-				zeichen = 'ß';
-			if( zeichen == 31 )
-				zeichen = '.';
-			if( zeichen < 27 )
-				zeichen = (char)( zeichen + 'a' );
-			kpf.name.append( &zeichen, 1 );
-		} // Chanel Anzahl lesen
-		d.getNextBit( bit );
-		kpf.channels = (char)( bit + 1 );
-		// Sample Rate lesen
-		d.lese( (char*)&kpf.sampleRate, 4 );
-		// Position des Sounds in der Datei lesen
-		d.lese( (char*)&kpf.datPos, 8 );
-		// Länge des Sounds lesen
-		int sLen = 0;
-		d.lese( (char*)&sLen, 4 );
-		kpf.datEnd = kpf.datPos + sLen;
-		kpf.pfad = pfad->getText();
-		sounds->add( kpf );
-	}
-	d.close();
+        return 0;
+    }
+    unsigned char sAnz = 0;
+    d.lese( (char *)&sAnz, 1 );
+    // Datei Sound - Köpfe einlesen
+    for( int i = 0; i < sAnz; i++ )
+    {
+        SoundKopf kpf;
+        bool bit = 0;
+        char len = 0;
+        // Namenslänge lesen
+        for( int i = 0; i < 4; i++ )
+        {
+            d.getNextBit( bit );
+            len = (char)( len | ( ( (char)bit << ( 3 - i ) ) & ( 1 << ( 3 - i ) ) ) );
+        }
+        len &= 15;
+        // Name lesen
+        for( int i = 0; i < len; i++ )
+        {
+            char zeichen = 0;
+            for( int j = 0; j < 5; j++ )
+            {
+                d.getNextBit( bit );
+                zeichen = (char)( zeichen | ( ( (char)bit << ( 4 - j ) ) & ( 1 << ( 4 - j ) ) ) );
+            }
+            zeichen &= 31;
+            if( zeichen == 27 )
+                zeichen = 'ü';
+            if( zeichen == 28 )
+                zeichen = 'ö';
+            if( zeichen == 29 )
+                zeichen = 'ä';
+            if( zeichen == 30 )
+                zeichen = 'ß';
+            if( zeichen == 31 )
+                zeichen = '.';
+            if( zeichen < 27 )
+                zeichen = (char)( zeichen + 'a' );
+            kpf.name.append( &zeichen, 1 );
+        } // Chanel Anzahl lesen
+        d.getNextBit( bit );
+        kpf.channels = (char)( bit + 1 );
+        // Sample Rate lesen
+        d.lese( (char *)&kpf.sampleRate, 4 );
+        // Position des Sounds in der Datei lesen
+        d.lese( (char *)&kpf.datPos, 8 );
+        // Länge des Sounds lesen
+        int sLen = 0;
+        d.lese( (char *)&sLen, 4 );
+        kpf.datEnd = kpf.datPos + sLen;
+        kpf.pfad = pfad->getText();
+        sounds->add( kpf );
+    }
+    d.close();
     cs.unlock();
-	return 1;
+    return 1;
 }
 
 int GSLDatei::getSoundAnzahl()
 {
-	return sounds->getEintragAnzahl();
+    return sounds->getEintragAnzahl();
 }
 
 Text *GSLDatei::getSoundName( int num )
 {
-	if( !sounds->hat( num ) )
-		return 0;
-	return new Text( sounds->get( num ).name );
+    if( !sounds->hat( num ) )
+        return 0;
+    return new Text( sounds->get( num ).name );
 }
 
 // Laden
 GSLSoundV *GSLDatei::getSound( Framework::Text *name )
 {
-	GSLSoundV *ret = getSound( *name );
-	name->release();
-	return ret;
+    GSLSoundV *ret = getSound( *name );
+    name->release();
+    return ret;
 }
 
 GSLSoundV *GSLDatei::getSound( char *name )
 {
     cs.lock();
-	int anz = sounds->getEintragAnzahl();
-	for( int i = 0; i < anz; i++ )
-	{
-		if( sounds->get( i ).name.istGleich( name ) )
-		{
+    int anz = sounds->getEintragAnzahl();
+    for( int i = 0; i < anz; i++ )
+    {
+        if( sounds->get( i ).name.istGleich( name ) )
+        {
             cs.unlock();
-			return new GSLSound( sounds->get( i ) );
-		}
-	}
+            return new GSLSound( sounds->get( i ) );
+        }
+    }
     cs.unlock();
-	return 0;
+    return 0;
 }
 
 // Speichern
 bool GSLDatei::speicherSound( GSLSoundV *zSound, Framework::Text *name )
 {
-	bool ret = speicherSound( zSound, *name );
-	name->release();
-	return ret;
+    bool ret = speicherSound( zSound, *name );
+    name->release();
+    return ret;
 }
 
 bool GSLDatei::speicherSound( GSLSoundV *zSound, char *name )
 {
-	Text kName;
-	for( char *c = name; *c; ++c )
-	{
-		if( *c >= 'A' && *c <= 'Z' )
-			kName.append( (char)( *c + 32 ) );
-		if( *c >= 'a' && *c <= 'z' )
-			kName.append( *c );
-		if( *c == 'Ü' || *c == 'ü' )
-			kName.append( 'ü' );
-		if( *c == 'Ö' || *c == 'ö' )
-			kName.append( 'ö' );
-		if( *c == 'Ä' || *c == 'ä' )
-			kName.append( 'ä' );
-		if( *c == 'ß' )
-			kName.append( 'ß' );
-		if( *c == '.' )
-			kName.append( '.' );
-		if( kName.getLength() == 15 )
-			break;
-	}
-	name = kName;
+    Text kName;
+    for( char *c = name; *c; ++c )
+    {
+        if( *c >= 'A' && *c <= 'Z' )
+            kName.append( (char)( *c + 32 ) );
+        if( *c >= 'a' && *c <= 'z' )
+            kName.append( *c );
+        if( *c == 'Ü' || *c == 'ü' )
+            kName.append( 'ü' );
+        if( *c == 'Ö' || *c == 'ö' )
+            kName.append( 'ö' );
+        if( *c == 'Ä' || *c == 'ä' )
+            kName.append( 'ä' );
+        if( *c == 'ß' )
+            kName.append( 'ß' );
+        if( *c == '.' )
+            kName.append( '.' );
+        if( kName.getLength() == 15 )
+            break;
+    }
+    name = kName;
     cs.lock();
-	// Prüfen ob bereits vorhanden
-	int anz = sounds->getEintragAnzahl();
-	for( int i = 0; i < anz; i++ )
-	{
-		if( sounds->get( i ).name.istGleich( name ) )
-		{
+    // Prüfen ob bereits vorhanden
+    int anz = sounds->getEintragAnzahl();
+    for( int i = 0; i < anz; i++ )
+    {
+        if( sounds->get( i ).name.istGleich( name ) )
+        {
             cs.unlock();
-			return 0;
-		}
-	}
-	Text tmpPf = pfad->getText();
-	tmpPf += "_";
-	GetFreePfad( &tmpPf );
-	Datei tmp;
-	tmp.setDatei( tmpPf );
-	tmp.erstellen();
-	if( !tmp.open( Datei::Style::schreiben ) )
-	{
+            return 0;
+        }
+    }
+    Text tmpPf = pfad->getText();
+    tmpPf += "_";
+    GetFreePfad( &tmpPf );
+    Datei tmp;
+    tmp.setDatei( tmpPf );
+    tmp.erstellen();
+    if( !tmp.open( Datei::Style::schreiben ) )
+    {
         cs.unlock();
-		return 0;
-	}
-	char *buffer = new char[ 0x4000 ];
-	// Neuen Sound in Temporäre Datei schreiben
-	zSound->open();
-	while( 1 )
-	{
-		int len = 0;
-		if( ( len = zSound->getDaten( buffer, 0x4000 ) ) < 0 )
-			break;
-		tmp.schreibe( buffer, len );
-	}
-	zSound->close();
-	delete buffer;
-	tmp.close();
-	int hLen = 1;
-	unsigned char sAnz = (unsigned char)sounds->getEintragAnzahl();
-	// Sound Kopf Länge errechnen
-	for( int i = 0; i < sAnz; i++ )
-	{
-		SoundKopf kpf = sounds->get( i );
-		hLen += ( 140 + 5 * kpf.name.getLength() ) / 8;
-	}
-	Datei alt;
-	alt.setDatei( *pfad );
-	// Sound Kopf Erstellen
-	SoundKopf kpf;
-	kpf.channels = (char)( !zSound->istMono() + 1 );
-	kpf.name = name;
-	kpf.pfad = pfad->getText();
-	kpf.sampleRate = zSound->getSampleRate();
-	kpf.datPos = ( alt.getSize() <= 0 ? 1 : alt.getSize() );
-	kpf.datEnd = tmp.getSize() + kpf.datPos;
-	sounds->add( kpf );
-	Text neuPf = pfad->getText();
-	neuPf += "_";
-	GetFreePfad( &neuPf );
-	Datei neu;
-	neu.setDatei( neuPf );
-	neu.erstellen();
-	if( !neu.open( Datei::Style::schreiben ) )
-	{
-		sounds->remove( sAnz );
-		tmp.remove();
+        return 0;
+    }
+    char *buffer = new char[ 0x4000 ];
+    // Neuen Sound in Temporäre Datei schreiben
+    zSound->open();
+    while( 1 )
+    {
+        int len = 0;
+        if( ( len = zSound->getDaten( buffer, 0x4000 ) ) < 0 )
+            break;
+        tmp.schreibe( buffer, len );
+    }
+    zSound->close();
+    delete[] buffer;
+    tmp.close();
+    int hLen = 1;
+    unsigned char sAnz = (unsigned char)sounds->getEintragAnzahl();
+    // Sound Kopf Länge errechnen
+    for( int i = 0; i < sAnz; i++ )
+    {
+        SoundKopf kpf = sounds->get( i );
+        hLen += ( 140 + 5 * kpf.name.getLength() ) / 8;
+    }
+    Datei alt;
+    alt.setDatei( *pfad );
+    // Sound Kopf Erstellen
+    SoundKopf kpf;
+    kpf.channels = (char)( !zSound->istMono() + 1 );
+    kpf.name = name;
+    kpf.pfad = pfad->getText();
+    kpf.sampleRate = zSound->getSampleRate();
+    kpf.datPos = ( alt.getSize() <= 0 ? 1 : alt.getSize() );
+    kpf.datEnd = tmp.getSize() + kpf.datPos;
+    sounds->add( kpf );
+    Text neuPf = pfad->getText();
+    neuPf += "_";
+    GetFreePfad( &neuPf );
+    Datei neu;
+    neu.setDatei( neuPf );
+    neu.erstellen();
+    if( !neu.open( Datei::Style::schreiben ) )
+    {
+        sounds->remove( sAnz );
+        tmp.remove();
         cs.unlock();
-		return 0;
-	}
-	sAnz = (unsigned char)sounds->getEintragAnzahl();
-	neu.schreibe( (char*)&sAnz, 1 );
-	// Sound Köpfe speichern
-	for( int i = 0; i < sAnz; i++ )
-	{
-		SoundKopf k = sounds->get( i );
-		k.datPos += ( 140 + 5 * kpf.name.getLength() ) / 8;
-		k.datEnd += ( 140 + 5 * kpf.name.getLength() ) / 8;
-		int l = k.name.getLength();
-		// Namenslänge speichern
-		neu.setNextBit( ( l & 8 ) != 0 );
-		neu.setNextBit( ( l & 4 ) != 0 );
-		neu.setNextBit( ( l & 2 ) != 0 );
-		neu.setNextBit( ( l & 1 ) != 0 );
-		for( int j = 0; j < l; j++ )
-		{ // Name speichern
-			char c = k.name.getText()[ j ];
-			if( c == 'ü' )
-				c = 27;
-			if( c == 'ö' )
-				c = 28;
-			if( c == 'ä' )
-				c = 29;
-			if( c == 'ß' )
-				c = 30;
-			if( c == '.' )
-				c = 31;
-			if( c >= 'a' && c <= 'z' )
-				c = (char)( c - 'a' );
-			neu.setNextBit( ( c & 16 ) != 0 );
-			neu.setNextBit( ( c & 8 ) != 0 );
-			neu.setNextBit( ( c & 4 ) != 0 );
-			neu.setNextBit( ( c & 2 ) != 0 );
-			neu.setNextBit( ( c & 1 ) != 0 );
-		} // Chanels speichern
-		neu.setNextBit( ( k.channels - 1 ) == 1 );
-		// Sample Rate speichern
-		neu.schreibe( (char*)&k.sampleRate, 4 );
-		// Datei Position schreiben
-		neu.schreibe( (char*)&k.datPos, 8 );
-		// Länge des Sounds Speichern
-		int sLen = (int)( k.datEnd - k.datPos );
-		neu.schreibe( (char*)&sLen, 4 );
-	}
-	// alte Sounds kopieren
-	char *byte = new char[ 2048 ];
-	if( sAnz > 1 )
-	{
-		if( !alt.open( Datei::Style::lesen ) )
-		{
-			tmp.remove();
-			neu.close();
-			neu.remove();
-			sounds->remove( sAnz );
+        return 0;
+    }
+    sAnz = (unsigned char)sounds->getEintragAnzahl();
+    neu.schreibe( (char *)&sAnz, 1 );
+    // Sound Köpfe speichern
+    for( int i = 0; i < sAnz; i++ )
+    {
+        SoundKopf k = sounds->get( i );
+        k.datPos += ( 140 + 5 * kpf.name.getLength() ) / 8;
+        k.datEnd += ( 140 + 5 * kpf.name.getLength() ) / 8;
+        int l = k.name.getLength();
+        // Namenslänge speichern
+        neu.setNextBit( ( l & 8 ) != 0 );
+        neu.setNextBit( ( l & 4 ) != 0 );
+        neu.setNextBit( ( l & 2 ) != 0 );
+        neu.setNextBit( ( l & 1 ) != 0 );
+        for( int j = 0; j < l; j++ )
+        { // Name speichern
+            char c = k.name.getText()[ j ];
+            if( c == 'ü' )
+                c = 27;
+            if( c == 'ö' )
+                c = 28;
+            if( c == 'ä' )
+                c = 29;
+            if( c == 'ß' )
+                c = 30;
+            if( c == '.' )
+                c = 31;
+            if( c >= 'a' && c <= 'z' )
+                c = (char)( c - 'a' );
+            neu.setNextBit( ( c & 16 ) != 0 );
+            neu.setNextBit( ( c & 8 ) != 0 );
+            neu.setNextBit( ( c & 4 ) != 0 );
+            neu.setNextBit( ( c & 2 ) != 0 );
+            neu.setNextBit( ( c & 1 ) != 0 );
+        } // Chanels speichern
+        neu.setNextBit( ( k.channels - 1 ) == 1 );
+        // Sample Rate speichern
+        neu.schreibe( (char *)&k.sampleRate, 4 );
+        // Datei Position schreiben
+        neu.schreibe( (char *)&k.datPos, 8 );
+        // Länge des Sounds Speichern
+        int sLen = (int)( k.datEnd - k.datPos );
+        neu.schreibe( (char *)&sLen, 4 );
+    }
+    // alte Sounds kopieren
+    char *byte = new char[ 2048 ];
+    if( sAnz > 1 )
+    {
+        if( !alt.open( Datei::Style::lesen ) )
+        {
+            tmp.remove();
+            neu.close();
+            neu.remove();
+            sounds->remove( sAnz );
             cs.unlock();
-			return 0;
-		}
-		alt.setLPosition( hLen, 0 );
-		for( __int64 i = hLen; i < alt.getSize(); )
-		{
-			int l = 2048;
-			if( l > alt.getSize() - i )
-				l = (int)( alt.getSize() - i );
-			alt.lese( byte, l );
-			neu.schreibe( byte, l );
-			i += l;
-		}
-		alt.close();
-	}
-	// Neuen Sound kopieren
-	if( !tmp.open( Datei::Style::lesen ) )
-	{
-		tmp.remove();
-		neu.close();
-		neu.remove();
-		sounds->remove( sAnz );
+            return 0;
+        }
+        alt.setLPosition( hLen, 0 );
+        for( __int64 i = hLen; i < alt.getSize(); )
+        {
+            int l = 2048;
+            if( l > alt.getSize() - i )
+                l = (int)( alt.getSize() - i );
+            alt.lese( byte, l );
+            neu.schreibe( byte, l );
+            i += l;
+        }
+        alt.close();
+    }
+    // Neuen Sound kopieren
+    if( !tmp.open( Datei::Style::lesen ) )
+    {
+        tmp.remove();
+        neu.close();
+        neu.remove();
+        sounds->remove( sAnz );
         cs.unlock();
-		return 0;
-	}
-	for( int i = 0; i < (int)tmp.getSize(); )
-	{
-		int l = 2048;
-		if( l > tmp.getSize() - i )
-			l = (int)( tmp.getSize() - i );
-		tmp.lese( byte, l );
-		neu.schreibe( byte, l );
-		i += l;
-	}
-	delete[] byte;
-	tmp.close();
-	neu.close();
-	// Dateien Umbenennen und remove
-	tmp.remove();
-	alt.remove();
-	neu.umbenennen( *pfad );
-	leseDaten();
+        return 0;
+    }
+    for( int i = 0; i < (int)tmp.getSize(); )
+    {
+        int l = 2048;
+        if( l > tmp.getSize() - i )
+            l = (int)( tmp.getSize() - i );
+        tmp.lese( byte, l );
+        neu.schreibe( byte, l );
+        i += l;
+    }
+    delete[] byte;
+    tmp.close();
+    neu.close();
+    // Dateien Umbenennen und remove
+    tmp.remove();
+    alt.remove();
+    neu.umbenennen( *pfad );
+    leseDaten();
     cs.unlock();
-	return 1;
+    return 1;
 }
 
 // Löschen
 bool GSLDatei::removeSound( Framework::Text *name )
 {
-	bool ret = removeSound( *name );
-	name->release();
-	return ret;
+    bool ret = removeSound( *name );
+    name->release();
+    return ret;
 }
 
 bool GSLDatei::removeSound( char *name )
 {
     cs.lock();
-	// Prüfen ob vorhanden
-	int anz = sounds->getEintragAnzahl();
-	int num = -1;
-	for( int i = 0; i < anz; i++ )
-	{
-		if( sounds->get( i ).name.istGleich( name ) )
-		{
-			num = i;
-			break;
-		}
-	}
-	if( num < 0 )
-	{
+    // Prüfen ob vorhanden
+    int anz = sounds->getEintragAnzahl();
+    int num = -1;
+    for( int i = 0; i < anz; i++ )
+    {
+        if( sounds->get( i ).name.istGleich( name ) )
+        {
+            num = i;
+            break;
+        }
+    }
+    if( num < 0 )
+    {
         cs.unlock();
-		return 1;
-	}
-	Text neuPf = pfad->getText();
-	neuPf += "_";
-	GetFreePfad( &neuPf );
-	Datei neu;
-	neu.setDatei( neuPf );
-	neu.erstellen();
-	if( !neu.open( Datei::Style::schreiben ) )
-	{
+        return 1;
+    }
+    Text neuPf = pfad->getText();
+    neuPf += "_";
+    GetFreePfad( &neuPf );
+    Datei neu;
+    neu.setDatei( neuPf );
+    neu.erstellen();
+    if( !neu.open( Datei::Style::schreiben ) )
+    {
         cs.unlock();
-		return 0;
-	}
-	SoundKopf kpf = sounds->get( num );
-	unsigned char sAnz = (unsigned char)( anz - 1 );
-	neu.schreibe( (char*)&sAnz, 1 );
-	// Sound Köpfe speichern
-	for( int i = 0; i <= sAnz; i++ )
-	{
-		if( i == num )
-			continue;
-		SoundKopf k = sounds->get( i );
-		k.datPos -= ( 140 + 5 * kpf.name.getLength() ) / 8;
-		k.datEnd -= ( 140 + 5 * kpf.name.getLength() ) / 8;
-		if( i > num )
-		{
-			k.datPos -= kpf.datEnd - kpf.datPos;
-			k.datEnd -= kpf.datEnd - kpf.datPos;
-		}
-		int l = k.name.getLength();
-		// Namenslänge speichern
-		neu.setNextBit( ( l & 8 ) != 0 );
-		neu.setNextBit( ( l & 4 ) != 0 );
-		neu.setNextBit( ( l & 2 ) != 0 );
-		neu.setNextBit( ( l & 1 ) != 0 );
-		for( int j = 0; j < l; j++ )
-		{ // Name speichern
-			char c = k.name.getText()[ j ];
-			if( c == 'ü' )
-				c = 27;
-			if( c == 'ö' )
-				c = 28;
-			if( c == 'ä' )
-				c = 29;
-			if( c == 'ß' )
-				c = 30;
-			if( c == '.' )
-				c = 31;
-			if( c >= 'a' && c <= 'z' )
-				c = (char)( c - 'a' );
-			neu.setNextBit( ( c & 16 ) != 0 );
-			neu.setNextBit( ( c & 8 ) != 0 );
-			neu.setNextBit( ( c & 4 ) != 0 );
-			neu.setNextBit( ( c & 2 ) != 0 );
-			neu.setNextBit( ( c & 1 ) != 0 );
-		} // Chanels speichern
-		neu.setNextBit( ( k.channels - 1 ) == 1 );
-		// Sample Rate speichern
-		neu.schreibe( (char*)&k.sampleRate, 4 );
-		// Datei Position schreiben
-		neu.schreibe( (char*)&k.datPos, 8 );
-		// Länge des Sounds Speichern
-		int sLen = (int)( k.datEnd - k.datPos );
-		neu.schreibe( (char*)&sLen, 4 );
-	}
-	// Alte Sounds kopieren
-	Datei alt;
-	alt.setDatei( *pfad );
-	if( sAnz )
-	{
-		if( !alt.open( Datei::Style::lesen ) )
-		{
-			neu.close();
-			neu.remove();
+        return 0;
+    }
+    SoundKopf kpf = sounds->get( num );
+    unsigned char sAnz = (unsigned char)( anz - 1 );
+    neu.schreibe( (char *)&sAnz, 1 );
+    // Sound Köpfe speichern
+    for( int i = 0; i <= sAnz; i++ )
+    {
+        if( i == num )
+            continue;
+        SoundKopf k = sounds->get( i );
+        k.datPos -= ( 140 + 5 * kpf.name.getLength() ) / 8;
+        k.datEnd -= ( 140 + 5 * kpf.name.getLength() ) / 8;
+        if( i > num )
+        {
+            k.datPos -= kpf.datEnd - kpf.datPos;
+            k.datEnd -= kpf.datEnd - kpf.datPos;
+        }
+        int l = k.name.getLength();
+        // Namenslänge speichern
+        neu.setNextBit( ( l & 8 ) != 0 );
+        neu.setNextBit( ( l & 4 ) != 0 );
+        neu.setNextBit( ( l & 2 ) != 0 );
+        neu.setNextBit( ( l & 1 ) != 0 );
+        for( int j = 0; j < l; j++ )
+        { // Name speichern
+            char c = k.name.getText()[ j ];
+            if( c == 'ü' )
+                c = 27;
+            if( c == 'ö' )
+                c = 28;
+            if( c == 'ä' )
+                c = 29;
+            if( c == 'ß' )
+                c = 30;
+            if( c == '.' )
+                c = 31;
+            if( c >= 'a' && c <= 'z' )
+                c = (char)( c - 'a' );
+            neu.setNextBit( ( c & 16 ) != 0 );
+            neu.setNextBit( ( c & 8 ) != 0 );
+            neu.setNextBit( ( c & 4 ) != 0 );
+            neu.setNextBit( ( c & 2 ) != 0 );
+            neu.setNextBit( ( c & 1 ) != 0 );
+        } // Chanels speichern
+        neu.setNextBit( ( k.channels - 1 ) == 1 );
+        // Sample Rate speichern
+        neu.schreibe( (char *)&k.sampleRate, 4 );
+        // Datei Position schreiben
+        neu.schreibe( (char *)&k.datPos, 8 );
+        // Länge des Sounds Speichern
+        int sLen = (int)( k.datEnd - k.datPos );
+        neu.schreibe( (char *)&sLen, 4 );
+    }
+    // Alte Sounds kopieren
+    Datei alt;
+    alt.setDatei( *pfad );
+    if( sAnz )
+    {
+        if( !alt.open( Datei::Style::lesen ) )
+        {
+            neu.close();
+            neu.remove();
             cs.unlock();
-			return 0;
-		}
-		alt.setLPosition( neu.getSPosition() + ( 140 + 5 * kpf.name.getLength() ) / 8, 0 );
-		char *byte = new char[ 2048 ];
-		for( __int64 i = alt.getLPosition(); i < kpf.datPos; )
-		{
-			int l = 2048;
-			if( l > kpf.datPos - i )
-				l = (int)( kpf.datPos - i );
-			alt.lese( byte, l );
-			neu.schreibe( byte, l );
-			i += l;
-		}
-		alt.setLPosition( kpf.datEnd, 0 );
-		for( __int64 i = alt.getLPosition(); i < alt.getSize(); )
-		{
-			int l = 2048;
-			if( l > alt.getSize() - i )
-				l = (int)( alt.getSize() - i );
-			alt.lese( byte, l );
-			neu.schreibe( byte, l );
-			i += l;
-		}
-		delete[] byte;
-		alt.close();
-	}
-	neu.close();
-	// Dateien Umbenennen und remove
-	alt.remove();
-	neu.umbenennen( *pfad );
-	leseDaten();
+            return 0;
+        }
+        alt.setLPosition( neu.getSPosition() + ( 140 + 5 * kpf.name.getLength() ) / 8, 0 );
+        char *byte = new char[ 2048 ];
+        for( __int64 i = alt.getLPosition(); i < kpf.datPos; )
+        {
+            int l = 2048;
+            if( l > kpf.datPos - i )
+                l = (int)( kpf.datPos - i );
+            alt.lese( byte, l );
+            neu.schreibe( byte, l );
+            i += l;
+        }
+        alt.setLPosition( kpf.datEnd, 0 );
+        for( __int64 i = alt.getLPosition(); i < alt.getSize(); )
+        {
+            int l = 2048;
+            if( l > alt.getSize() - i )
+                l = (int)( alt.getSize() - i );
+            alt.lese( byte, l );
+            neu.schreibe( byte, l );
+            i += l;
+        }
+        delete[] byte;
+        alt.close();
+    }
+    neu.close();
+    // Dateien Umbenennen und remove
+    alt.remove();
+    neu.umbenennen( *pfad );
+    leseDaten();
     cs.unlock();
-	return 1;
-}
-
-// Reference Counting
-GSLDateiV *GSLDatei::getThis()
-{
-	ref++;
-	return this;
-}
-
-GSLDateiV *GSLDatei::release()
-{
-	ref--;
-	if( !ref )
-		delete this;
-	return 0;
+    return 1;
 }

+ 36 - 40
GSL/GSLDatei.h

@@ -11,48 +11,44 @@ using namespace Framework;
 
 namespace GSL
 {
-	struct SoundKopf
-	{
-		Text name;
-		char channels;
-		unsigned int sampleRate;
-		__int64 datPos;
-		__int64 datEnd;
-		Text pfad;
-	};
+    struct SoundKopf
+    {
+        Text name;
+        char channels;
+        unsigned int sampleRate = 0;
+        __int64 datPos = 0;
+        __int64 datEnd = 0;
+        Text pfad;
+    };
 
-	class GSLDatei : public GSLDateiV
-	{
-	private:
-		Array< SoundKopf > *sounds;
-		Text *pfad;
-		Critical cs;
-		int ref;
+    class GSLDatei : public GSLDateiV
+    {
+    private:
+        Array< SoundKopf > *sounds;
+        Text *pfad;
+        Critical cs;
 
-	public:
-		// Konstruktor
-		GSLDatei();
-		// Destruktor
-		~GSLDatei();
-		// Datei open
-		void setDatei( Framework::Text *txt ) override;
-		void setDatei( char *txt ) override;
-		bool leseDaten() override;
-		int getSoundAnzahl() override;
-		Text *getSoundName( int num ) override;
-		// Laden
-		GSLSoundV *getSound( Framework::Text *name ) override;
-		GSLSoundV *getSound( char *name ) override;
-		// Speichern
-		bool speicherSound( GSLSoundV *zSound, Framework::Text *name ) override;
-		bool speicherSound( GSLSoundV *zSound, char *name ) override;
-		// Löschen
-		bool removeSound( Framework::Text *name ) override;
-		bool removeSound( char *name ) override;
-		// Reference Counting
-		GSLDateiV *getThis() override;
-		GSLDateiV *release() override;
-	};
+    public:
+        // Konstruktor
+        GSLDatei();
+        // Destruktor
+        ~GSLDatei();
+        // Datei open
+        void setDatei( Framework::Text *txt ) override;
+        void setDatei( char *txt ) override;
+        bool leseDaten() override;
+        int getSoundAnzahl() override;
+        Text *getSoundName( int num ) override;
+        // Laden
+        GSLSoundV *getSound( Framework::Text *name ) override;
+        GSLSoundV *getSound( char *name ) override;
+        // Speichern
+        bool speicherSound( GSLSoundV *zSound, Framework::Text *name ) override;
+        bool speicherSound( GSLSoundV *zSound, char *name ) override;
+        // Löschen
+        bool removeSound( Framework::Text *name ) override;
+        bool removeSound( char *name ) override;
+    };
 }
 
 #endif

+ 1 - 4
GSL/Include/GSLDateiV.h

@@ -6,7 +6,7 @@
 
 namespace GSL
 {
-    class GSLDateiV
+    class GSLDateiV : public virtual Framework::ReferenceCounter
     {
     public:
         virtual ~GSLDateiV()
@@ -25,9 +25,6 @@ namespace GSL
         // Löschen
         virtual bool removeSound( Framework::Text *name ) = 0;
         virtual bool removeSound( char *name ) = 0;
-        // Reference Counting
-        virtual GSLDateiV *getThis() = 0;
-        virtual GSLDateiV *release() = 0;
     };
 }
 

+ 0 - 3
GSL/Include/GSLSoundV.h

@@ -23,9 +23,6 @@ namespace GSL
         virtual bool istMono() const = 0;
         virtual int getSampleRate() const = 0;
         virtual __int64 getDatLength() const = 0;
-        // Reference Counting
-        virtual Thread *getThis() = 0;
-        virtual Thread *release() = 0;
     };
 }
 

+ 2 - 17
GSL/Sound.cpp

@@ -332,7 +332,7 @@ void GSLSound::msg( UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_P
     case WOM_DONE:
         pHeader = (WAVEHDR *)dwParam1;
         hAudioCs.lock();
-        InterlockedExchangeAdd( (unsigned __int64 *)& lAudioDone, (__int64)pHeader->dwBufferLength );
+        InterlockedExchangeAdd( (unsigned __int64 *)&lAudioDone, (__int64)pHeader->dwBufferLength );
         iDelta = (int)( uAudioPlay - pHeader->dwUser );
         if( iDelta < 0 )
             iDelta += uAudioCount;
@@ -431,19 +431,4 @@ HWAVEOUT GSLSound::getHandle() const
 {
     return hAudioId;
 }
-#endif
-
-// Reference Counting
-Thread *GSLSound::getThis()
-{
-    return Thread::getThis();
-}
-
-Thread *GSLSound::release()
-{
-#ifdef WIN32
-    if( ref == 2 && run )
-        stopSound();
-#endif
-    return Thread::release();
-}
+#endif

+ 50 - 53
GSL/Sound.h

@@ -12,69 +12,66 @@ using namespace Framework;
 
 namespace GSL
 {
-	class GSLSound : public GSLSoundV
-	{
-	private:
-		Datei *dat;
-		SoundKopf kpf;
+    class GSLSound : public GSLSoundV
+    {
+    private:
+        Datei *dat;
+        SoundKopf kpf;
 #ifdef WIN32
         int status;
-		HWAVEOUT hAudioId;
-		unsigned int uAudioDelay;
-		unsigned int uAudioCount;
-		WAVEHDR *aAudioHdr[ 16 ];
-		char *aAudioPtr[ 16 ];
-		unsigned int uAudioPlay;
-		Critical hAudioCs;
-		HANDLE hAudioEvent;
-		WAVEOUTCAPS sAudioCaps;
-		unsigned int uAudioWrite;
-		unsigned int uAudioStop;
-		int lAudioDone;
-		unsigned int uAudioWrOk;
-		volatile int iAudioThEnd;
-		unsigned int aAudioSize[ 8 ];
-		float linksV;
-		float rechtsV;
+        HWAVEOUT hAudioId;
+        unsigned int uAudioDelay;
+        unsigned int uAudioCount;
+        WAVEHDR *aAudioHdr[ 16 ];
+        char *aAudioPtr[ 16 ];
+        unsigned int uAudioPlay;
+        Critical hAudioCs;
+        HANDLE hAudioEvent;
+        WAVEOUTCAPS sAudioCaps;
+        unsigned int uAudioWrite;
+        unsigned int uAudioStop;
+        int lAudioDone;
+        unsigned int uAudioWrOk;
+        volatile int iAudioThEnd;
+        unsigned int aAudioSize[ 8 ];
+        float linksV;
+        float rechtsV;
 #endif
 
-		// privat
-		int audioOpen();
-		int audioClose();
-		int audioStop();
-		int audioSchreiben( unsigned int uCount );
-		int audioLesen( char *buff, int len );
+        // privat
+        int audioOpen();
+        int audioClose();
+        int audioStop();
+        int audioSchreiben( unsigned int uCount );
+        int audioLesen( char *buff, int len );
 
-	public:
-		// Konstruktor
-		GSLSound( const SoundKopf &skpf );
-		// Destruktor
-		virtual ~GSLSound();
-		// nicht constant
-		void playSound() override;
-		void setPause( bool p ) override;
-		void stopSound() override;
-		void warteAufSound( int zeit ) override;
-		void setVolume( unsigned int links, unsigned int rechts ) override;
+    public:
+        // Konstruktor
+        GSLSound( const SoundKopf &skpf );
+        // Destruktor
+        virtual ~GSLSound();
+        // nicht constant
+        void playSound() override;
+        void setPause( bool p ) override;
+        void stopSound() override;
+        void warteAufSound( int zeit ) override;
+        void setVolume( unsigned int links, unsigned int rechts ) override;
 #ifdef WIN32
-		void msg( UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 );
+        void msg( UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 );
 #endif
-		void thread() override;
-		// zum Speichern
-		void open() override;
-		int getDaten( char *buffer, int len ) override;
-		void close() override;
-		bool istMono() const override;
-		int getSampleRate() const override;
+        void thread() override;
+        // zum Speichern
+        void open() override;
+        int getDaten( char *buffer, int len ) override;
+        void close() override;
+        bool istMono() const override;
+        int getSampleRate() const override;
         __int64 getDatLength() const override;
-		// constant
+        // constant
 #ifdef WIN32
-		HWAVEOUT getHandle() const;
+        HWAVEOUT getHandle() const;
 #endif
-		// Reference Counting
-        Thread *getThis() override;
-        Thread *release() override;
-	};
+    };
 }
 
 #endif