Exemple #1
0
void gui_get_clipboard(char **buffer, size_t *length)
{
	struct ContextNode *cn;
	struct CollectionItem *ci = NULL;
	struct StoredProperty *sp = NULL;
	ULONG rlen=0,error;
	struct CSet *cset;
	LONG codeset = 0;

	if(OpenIFF(iffh,IFFF_READ)) return;
	
	if(CollectionChunk(iffh,ID_FTXT,ID_CHRS)) return;
	if(PropChunk(iffh,ID_FTXT,ID_CSET)) return;
	if(CollectionChunk(iffh,ID_FTXT,ID_UTF8)) return;
	if(StopOnExit(iffh, ID_FTXT, ID_FORM)) return;
	
	error = ParseIFF(iffh,IFFPARSE_SCAN);

	if(ci = FindCollection(iffh, ID_FTXT, ID_UTF8)) {
		*buffer = ami_clipboard_cat_collection(ci, 106, length);
	} else if(ci = FindCollection(iffh, ID_FTXT, ID_CHRS)) {
		if(sp = FindProp(iffh, ID_FTXT, ID_CSET)) {
			cset = (struct CSet *)sp->sp_Data;
			codeset = cset->CodeSet;
		}
		*buffer = ami_clipboard_cat_collection(ci, codeset, length);
	}

	CloseIFF(iffh);
}
Exemple #2
0
BOOL
ReadConfig ( struct AHIDevUnit *iounit,
             struct AHIBase *AHIBase )
{
  struct IFFHandle *iff;
  struct StoredProperty *prhd,*ahig;
  struct CollectionItem *ci;

  if(iounit)
  {
    /* Internal defaults for device unit */
    iounit->AudioMode       = AHI_INVALID_ID;   // See at the end of the function!
    iounit->Frequency       = 10000;
    iounit->Channels        = 4;
    iounit->MonitorVolume   = ~0;
    iounit->InputGain       = ~0;
    iounit->OutputVolume    = ~0;
    iounit->Input           = ~0;
    iounit->Output          = ~0;
  }
  else
  {
    /* Internal defaults for low-level mode */
    AHIBase->ahib_AudioMode       = AHI_INVALID_ID;
    AHIBase->ahib_Frequency       = 10000;
    AHIBase->ahib_MonitorVolume   = 0x00000;
    AHIBase->ahib_InputGain       = 0x10000;
    AHIBase->ahib_OutputVolume    = 0x10000;
    AHIBase->ahib_Input           = 0;
    AHIBase->ahib_Output          = 0;
  }

  if((iff=AllocIFF()))
  {
    iff->iff_Stream=Open("ENV:Sys/ahi.prefs", MODE_OLDFILE);
    if(iff->iff_Stream)
    {
      InitIFFasDOS(iff);
      if(!OpenIFF(iff,IFFF_READ))
      {
        if(!(PropChunk(iff,ID_PREF,ID_PRHD)
          || PropChunk(iff,ID_PREF,ID_AHIG)
          || CollectionChunk(iff,ID_PREF,ID_AHIU)
          || StopOnExit(iff,ID_PREF,ID_FORM)))
        {
          if(ParseIFF(iff,IFFPARSE_SCAN) == IFFERR_EOC)
          {
            prhd=FindProp(iff,ID_PREF,ID_PRHD);
            ahig=FindProp(iff,ID_PREF,ID_AHIG);
            
            if(ahig)
            {
              struct AHIGlobalPrefs *globalprefs;
              
              globalprefs = (struct AHIGlobalPrefs *)ahig->sp_Data;

              AHIBase->ahib_DebugLevel = globalprefs->ahigp_DebugLevel;

              AHIBase->ahib_Flags = 0;

              if(globalprefs->ahigp_DisableSurround)
                AHIBase->ahib_Flags |= AHIBF_NOSURROUND;

              if(globalprefs->ahigp_DisableEcho)
                AHIBase->ahib_Flags |= AHIBF_NOECHO;

              if(globalprefs->ahigp_FastEcho)
                AHIBase->ahib_Flags |= AHIBF_FASTECHO;
                
              if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs,
                                                    ahigp_MaxCPU) )
              {
                AHIBase->ahib_MaxCPU = globalprefs->ahigp_MaxCPU;
              }
              else
              {
                AHIBase->ahib_MaxCPU = 0x10000 * 90 / 100;
              }

              if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs, 
                                                    ahigp_ClipMasterVolume) )
              {
                if(globalprefs->ahigp_ClipMasterVolume)
                  AHIBase->ahib_Flags |= AHIBF_CLIPPING;
              }

              if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs, 
                                                    ahigp_AntiClickTime ) )
              {
                AHIBase->ahib_AntiClickTime = globalprefs->ahigp_AntiClickTime;
              }
              else
              {
                AHIBase->ahib_AntiClickTime = 0;
              }

            }
            ci=FindCollection(iff,ID_PREF,ID_AHIU);
            while(ci)
            {
              struct AHIUnitPrefs *unitprefs;

              unitprefs = (struct AHIUnitPrefs *)ci->ci_Data;

              if(iounit)
              {
                if(unitprefs->ahiup_Unit == iounit->UnitNum)
                {
                  iounit->AudioMode       = unitprefs->ahiup_AudioMode;
                  iounit->Frequency       = unitprefs->ahiup_Frequency;
                  iounit->Channels        = unitprefs->ahiup_Channels;
                  iounit->MonitorVolume   = unitprefs->ahiup_MonitorVolume;
                  iounit->InputGain       = unitprefs->ahiup_InputGain;
                  iounit->OutputVolume    = unitprefs->ahiup_OutputVolume;
                  iounit->Input           = unitprefs->ahiup_Input;
                  iounit->Output          = unitprefs->ahiup_Output;
                }
              }
              else
              {
                if(unitprefs->ahiup_Unit == AHI_NO_UNIT)
                {
                  AHIBase->ahib_AudioMode       = unitprefs->ahiup_AudioMode;
                  AHIBase->ahib_Frequency       = unitprefs->ahiup_Frequency;
                  AHIBase->ahib_MonitorVolume   = unitprefs->ahiup_MonitorVolume;
                  AHIBase->ahib_InputGain       = unitprefs->ahiup_InputGain;
                  AHIBase->ahib_OutputVolume    = unitprefs->ahiup_OutputVolume;
                  AHIBase->ahib_Input           = unitprefs->ahiup_Input;
                  AHIBase->ahib_Output          = unitprefs->ahiup_Output;
                }
              }

              ci=ci->ci_Next;
            }
          }
int main(int argc, char *argv[])
{
  struct IFFHandle *iff;
  struct StoredProperty *ahig;
  struct CollectionItem *ci;
  LONG unit = 0;
  int rc = RETURN_OK;

  if(argc != 3) {
    Printf("Usage: %s FILE UNIT\n", argv[0]);
    return RETURN_FAIL;
  }

  StrToLong(argv[2], &unit);

  if(iff = AllocIFF())
  {
    iff->iff_Stream = Open(argv[1], MODE_OLDFILE);
    if(iff->iff_Stream)
    {
      InitIFFasDOS(iff);
      if(!OpenIFF(iff, IFFF_READ))
      {
        if(!(PropChunk(iff,ID_PREF,ID_AHIG)
          || CollectionChunk(iff,ID_PREF,ID_AHIU)
          || StopOnExit(iff,ID_PREF,ID_FORM)))
        {
          if(ParseIFF(iff, IFFPARSE_SCAN) == IFFERR_EOC)
          {

            ahig = FindProp(iff,ID_PREF,ID_AHIG);
            if(ahig)
            {
              struct AHIGlobalPrefs *globalprefs;
              globalprefs = (struct AHIGlobalPrefs *)ahig->sp_Data;

              if(globalprefs->ahigp_DebugLevel != AHI_DEBUG_NONE)
              {
                Printf("Debugging is turned on.\n");
                rc = RETURN_WARN;
              }
            }

            ci = FindCollection(iff,ID_PREF,ID_AHIU);
            while(ci)
            {
              struct AHIUnitPrefs *unitprefs;
              unitprefs = (struct AHIUnitPrefs *)ci->ci_Data;

              if(unitprefs->ahiup_Unit == unit)
              {
                if(unitprefs->ahiup_Channels < 2)
                {
                  Printf("There are less than 2 channels selected for unit %ld.\n", unit);
                  rc = RETURN_WARN;
                }
              }
              ci=ci->ci_Next;
            }

          }
        }
        CloseIFF(iff);
      }
      Close(iff->iff_Stream);
    }
    FreeIFF(iff);
  }

  return rc;
}
Exemple #4
0
struct List *GetUnits(char *name) {
  struct List *list;
  struct IFFHandle *iff;
  BOOL devnodes[UNITNODES] = { FALSE, FALSE, FALSE, FALSE } ;
  BOOL lownode = FALSE;
  int i;

  globalprefs.ahigp_MaxCPU = (90 << 16) / 100;

  list = AllocVec(sizeof(struct List), MEMF_CLEAR);
  
  if(list) {
    NewList(list);
    
    if(name && (iff = AllocIFF())) {
      iff->iff_Stream = Open(name, MODE_OLDFILE);
      if(iff->iff_Stream) {
        InitIFFasDOS(iff);
        if(!OpenIFF(iff, IFFF_READ)) {
          if(!(PropChunk      (iff, ID_PREF, ID_AHIG) ||
               CollectionChunk(iff, ID_PREF, ID_AHIU) ||
               StopOnExit     (iff, ID_PREF, ID_FORM))) {
            if(ParseIFF(iff, IFFPARSE_SCAN) == IFFERR_EOC) {
              struct StoredProperty *global = FindProp(iff, ID_PREF, ID_AHIG);
              struct CollectionItem *ci = FindCollection(iff, ID_PREF, ID_AHIU);

              if(global != NULL) {
                CopyMem(global->sp_Data, &globalprefs, 
                    min( sizeof(struct AHIGlobalPrefs), global->sp_Size ));
              }

              while(ci) {
                struct AHIUnitPrefs *p = ci->ci_Data;
                struct UnitNode     *u;

                u = AllocVec(sizeof(struct UnitNode), MEMF_CLEAR);
                if(u == NULL)
                  break;
                CopyMem(p, &u->prefs, 
                    min( sizeof(struct AHIUnitPrefs), ci->ci_Size ));

                FillUnitName(u);
                
                u->node.ln_Pri = -(u->prefs.ahiup_Unit);
                Enqueue(list, (struct Node *) u);
                
                if(u->prefs.ahiup_Unit == AHI_NO_UNIT) {
                  lownode = TRUE;
                }
                else if(u->prefs.ahiup_Unit < UNITNODES) {
                  devnodes[u->prefs.ahiup_Unit] = TRUE;
                }
                
                ci=ci->ci_Next;
              }
            }
          }
          CloseIFF(iff);
        }
        Close(iff->iff_Stream);
      }
      FreeIFF(iff);
    }


    // Fill up to lowlevel + UNITNODES device nodes, if not found in prefs file

    if(!lownode) AddUnit(list, AHI_NO_UNIT);
    for(i = 0; i < UNITNODES; i++) {
      if(!devnodes[i]) AddUnit(list, i);
    }

  }

  return list;
}
Exemple #5
0
BOOL
ReadConfig ( struct AHIDevUnit *iounit,
             struct AHIBase *AHIBase )
{
    struct IFFHandle *iff;
    struct StoredProperty *prhd,*ahig;
    struct CollectionItem *ci;
    ULONG *mode;

    if(iounit)
    {
        /* Internal defaults for device unit */
        iounit->AudioMode       = AHI_INVALID_ID;   // See at the end of the function!
        iounit->Frequency       = 10000;
        iounit->Channels        = 4;
        iounit->MonitorVolume   = ~0;
        iounit->InputGain       = ~0;
        iounit->OutputVolume    = ~0;
        iounit->Input           = ~0;
        iounit->Output          = ~0;
    }
    else
    {
        /* Internal defaults for low-level mode */
        AHIBase->ahib_AudioMode       = AHI_INVALID_ID;
        AHIBase->ahib_Frequency       = 10000;
        AHIBase->ahib_MonitorVolume   = 0x00000;
        AHIBase->ahib_InputGain       = 0x10000;
        AHIBase->ahib_OutputVolume    = 0x10000;
        AHIBase->ahib_Input           = 0;
        AHIBase->ahib_Output          = 0;
    }

    if((iff=AllocIFF()))
    {
        iff->iff_Stream=(ULONG) Open("ENV:Sys/ahi.prefs", MODE_OLDFILE);
        if(iff->iff_Stream)
        {
            InitIFFasDOS(iff);
            if(!OpenIFF(iff,IFFF_READ))
            {
                if(!(PropChunk(iff,ID_PREF,ID_PRHD)
                        || PropChunk(iff,ID_PREF,ID_AHIG)
                        || CollectionChunk(iff,ID_PREF,ID_AHIU)
                        || StopOnExit(iff,ID_PREF,ID_FORM)))
                {
                    if(ParseIFF(iff,IFFPARSE_SCAN) == IFFERR_EOC)
                    {
                        prhd=FindProp(iff,ID_PREF,ID_PRHD);
                        ahig=FindProp(iff,ID_PREF,ID_AHIG);

                        if(ahig)
                        {
                            struct AHIGlobalPrefs *globalprefs;
                            UWORD debug_level;

                            globalprefs = (struct AHIGlobalPrefs *)ahig->sp_Data;

                            debug_level = globalprefs->ahigp_DebugLevel;
                            EndianSwap( sizeof (UWORD), &debug_level );
                            AHIBase->ahib_DebugLevel = debug_level;

                            AHIBase->ahib_Flags = 0;

                            /* Not used in version 5:
                             *
                             * if(globalprefs->ahigp_DisableSurround)
                             *   AHIBase->ahib_Flags |= AHIBF_NOSURROUND;
                             *
                             * if(globalprefs->ahigp_DisableEcho)
                                 *   AHIBase->ahib_Flags |= AHIBF_NOECHO;
                             *
                             * if(globalprefs->ahigp_FastEcho)
                                 *   AHIBase->ahib_Flags |= AHIBF_FASTECHO;
                             *
                             */

                            if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs,
                                                                  ahigp_MaxCPU) )
                            {
                                AHIBase->ahib_MaxCPU = globalprefs->ahigp_MaxCPU;
                                EndianSwap( sizeof (Fixed), &AHIBase->ahib_MaxCPU );
                            }
                            else
                            {
                                AHIBase->ahib_MaxCPU = 0x10000 * 90 / 100;
                            }

                            /* In version 5: Clipping is always used
                             *
                                 * if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs,
                                 *                                       ahigp_ClipMasterVolume) )
                                 * {
                                 *   if(globalprefs->ahigp_ClipMasterVolume)
                                 *     AHIBase->ahib_Flags |= AHIBF_CLIPPING;
                                 * }
                             */

                            if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs,
                                                                  ahigp_AntiClickTime ) )
                            {
                                AHIBase->ahib_AntiClickTime = globalprefs->ahigp_AntiClickTime;
                                EndianSwap( sizeof (Fixed), &AHIBase->ahib_AntiClickTime );
                            }
                            else
                            {
                                AHIBase->ahib_AntiClickTime = 0;
                            }

                            if( (ULONG) ahig->sp_Size > offsetof( struct AHIGlobalPrefs,
                                                                  ahigp_ScaleMode ) )
                            {
                                AHIBase->ahib_ScaleMode = globalprefs->ahigp_ScaleMode;
                                EndianSwap( sizeof (UWORD), &AHIBase->ahib_ScaleMode );
                            }
                            else
                            {
                                AHIBase->ahib_ScaleMode = AHI_SCALE_FIXED_0_DB;
                            }
                        }
Exemple #6
0
static ULONG
AddModeFile ( UBYTE *filename )
{
  struct IFFHandle *iff;
  struct StoredProperty *name,*data;
  struct CollectionItem *ci;
  struct TagItem *tag,*tstate;
  struct TagItem extratags[]=
  {
    { AHIDB_Driver, NULL },
    { AHIDB_Data, NULL },
    { TAG_MORE,   NULL }
  };
  ULONG rc=FALSE;

  iff = AllocIFF();

  if(iff != NULL)
  {

    iff->iff_Stream = Open(filename, MODE_OLDFILE);

    if(iff->iff_Stream != NULL)
    {
      InitIFFasDOS(iff);

      if(!OpenIFF(iff, IFFF_READ))
      {

        if(!(PropChunk(iff,       ID_AHIM, ID_AUDN)
          || PropChunk(iff,       ID_AHIM, ID_AUDD)
          || CollectionChunk(iff, ID_AHIM, ID_AUDM)
          || StopOnExit(iff,      ID_AHIM, ID_FORM)))
        {
          if(ParseIFF(iff, IFFPARSE_SCAN) == IFFERR_EOC)
          {
            name = FindProp(iff,       ID_AHIM, ID_AUDN);
            data = FindProp(iff,       ID_AHIM, ID_AUDD);
            ci   = FindCollection(iff, ID_AHIM, ID_AUDM);

            if(name != NULL)
            {
              extratags[0].ti_Data = (ULONG) name->sp_Data;
            }

            if(data != NULL)
            {
              extratags[1].ti_Data = (ULONG) data->sp_Data;
            }

            rc = TRUE;

            while(ci != NULL)
            {
              // Relocate loaded taglist

              tstate = (struct TagItem *) ci->ci_Data;
              while((tag = NextTagItem(&tstate)) != NULL )
              {
                if(tag->ti_Tag & (AHI_TagBaseR ^ AHI_TagBase))
                {
                  tag->ti_Data += (ULONG) ci->ci_Data;
                }
              }

              // Link taglists

              extratags[2].ti_Data = (ULONG) ci->ci_Data;

              rc = AHI_AddAudioMode(extratags);

              ci = ci->ci_Next;
            }
          }
        }
        CloseIFF(iff);
      }
      Close(iff->iff_Stream);
    }
    FreeIFF(iff);
  }

  return rc;
}