home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pAudio / AudioInfo.c next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  5.6 KB  |  211 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 19 Dec 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>AudioInfo.c<<   26 Jan 1997    13:14:53 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/AudioInfo p:pLib/StartCode.o p:/pOS_RKRM/pAudio/AudioInfo.c p:pLib/StdIO.o -l pOSStub -l pOS
  10.  
  11. /***********************************************************
  12.   pOS programing example - Copyright (C) 1995-97 proDAD
  13.  
  14.   This code was written as an easy to understand example,
  15.   how to program pOS features. It is provided 'as-is',
  16.   without any express or implied warranty.
  17.  
  18.   Permission is hereby granted to use, copy and modify
  19.   this source code for any purpose, without fee, subject
  20.   to the following conditions:
  21.  
  22.     (1) This notice may not be removed or altered from any
  23.         source distribution.
  24.  
  25.     (2) Altered source versions must be plainly marked as
  26.         such, and must not be misrepresented as being
  27.         the original source code.
  28.  
  29.     (3) If only executable code is distributed, then the
  30.         accompanying documentation have to state that
  31.         "this software is based in part on examples of
  32.         the pOS developer packet".
  33.  
  34.     (4) Permission for use of this code is granted only
  35.         if the user accepts full responsibility for any
  36.         undesirable consequences. proDAD accept NO LIABILITY
  37.         for damages of any kind.
  38.  
  39.   ©proDAD
  40. ***********************************************************/
  41.  
  42. /*\
  43. *** Example:
  44. ***
  45. \*/
  46.  
  47.  
  48. #define __COMPUTER_AMIGA 1
  49. #define NOMYDEBUG
  50.  
  51. #include "p:pExec/Types.h"
  52. #include "p:pExec/MsgPort.h"
  53. #include "p:pDOS/ArgTags.h"
  54. #include "p:pDOS/DosSig.h"
  55. #include "p:pDOS/DosErrors.h"
  56. #include "p:Device/Audio.h"
  57. #include "p:pAudio/InfoData.h"
  58.  
  59. #include "p:proto/pLibExt.h"
  60. #include "p:proto/pExec2.h"
  61. #include "p:proto/pDOS2.h"
  62. #include "p:proto/pAudio2.h"
  63.  
  64. #ifdef _____ME_____
  65.   #include "grund/inc_string.h"
  66.   #include "grund/inc_stdio.h"
  67. #else
  68.  #ifdef __cplusplus
  69.  extern "C" {
  70.  #endif
  71.   #include <string.h>
  72.   #include <stdio.h>
  73.  #ifdef __cplusplus
  74.  }
  75.  #endif
  76. #endif
  77.  
  78.  
  79. const CHAR *HelpText=
  80. ""
  81. ;
  82.  
  83. const CHAR *PrgHeader=
  84. "";
  85.  
  86. const CHAR *PrgVerText=
  87. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
  88.  
  89.  
  90. struct pOS_AudioDevice *gb_AudioBase;
  91.  
  92. /*----------------------------------
  93. -----------------------------------*/
  94. #ifdef __cplusplus
  95. extern "C"
  96. #endif
  97.  
  98. VOID main()
  99. {
  100.   struct pOS_DosArgs* Args;
  101.   UWORD Err=0;
  102.   ULONG Ops[1]={0};
  103.  
  104.   Args=pOS_ReadDosArgs(
  105. //
  106. "",
  107. Ops,sizeof(Ops)/sizeof(ULONG),
  108.  
  109.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  110.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  111.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  112.     TAG_END);
  113.  
  114.   if(Args) {
  115.     pOS_MsgPort Port;
  116.     pOS_AudioIO *IO;
  117.  
  118.     if(pOS_ConstructMsgPort(&Port)) {
  119.       if(IO=(pOS_AudioIO*)pOS_CreateIORequest(&Port,sizeof(pOS_AudioIO))) {
  120.         pOS_OpenDevice("pAudio.device",~0,(pOS_IORequest*)IO,0,0);
  121.         if(IO->aio_Error==0) {
  122.           IO->aio_Command=AUDIOCMD_Info;
  123.           pOS_DoIO((pOS_IORequest*)IO);
  124.           printf(
  125. "aiio_FirstHwChannels =%ld\n"
  126. "aiio_NumHwChannels   =%ld\n"
  127. "aiio_FirstSwChannels =%ld\n"
  128. "aiio_NumSwChannels   =%ld\n",
  129.  IO->aio_U.aio_Info.aiio_FirstHwChannels,
  130.  IO->aio_U.aio_Info.aiio_NumHwChannels,
  131.  IO->aio_U.aio_Info.aiio_FirstSwChannels,
  132.  IO->aio_U.aio_Info.aiio_NumSwChannels
  133. );
  134.           {
  135.             ULONG FirstH=IO->aio_U.aio_Info.aiio_FirstHwChannels;
  136.             ULONG NumH  =IO->aio_U.aio_Info.aiio_NumHwChannels;
  137.             ULONG FirstS=IO->aio_U.aio_Info.aiio_FirstSwChannels;
  138.             ULONG NumS  =IO->aio_U.aio_Info.aiio_NumSwChannels;
  139.             ULONG Num;
  140.             pOS_AudioInfoData Data={sizeof(pOS_AudioInfoData)};
  141.  
  142.             IO->aio_Command=AUDIOCMD_ChannelInfo;
  143.             IO->aio_U.aio_ChInfo.acio_InfoSize=sizeof(pOS_AudioInfoData);
  144.             IO->aio_U.aio_ChInfo.acio_InfoData=&Data;
  145.  
  146.             printf("Hardware-Channel Info:\n");
  147.             for(Num=0; Num<NumH; ++Num) {
  148.               IO->aio_U.aio_ChInfo.acio_Channel=FirstH+Num;
  149.               pOS_DoIO((pOS_IORequest*)IO);
  150.               if(IO->aio_Error==0) {
  151.                 printf(
  152. "Channel = %ld\n"
  153. " ID           = <%.40s>\n"
  154. " AudioMapType = 0x%lx\n"
  155. " Flags        = 0x%lx\n"
  156. " Min. Freq.   = %ld Hz\n"
  157. " Max. Freq.   = %ld Hz\n"
  158. ,
  159. IO->aio_U.aio_ChInfo.acio_Channel,
  160. Data.aid_IDName,
  161. Data.aid_Type,
  162. Data.aid_Channel,
  163. Data.aid_MinFrequence,
  164. Data.aid_MaxFrequence
  165. );
  166.               }
  167.               else printf("AUDIOCMD_ChannelInfo error=%ld\n",IO->aio_Error);
  168.             }
  169.  
  170.  
  171.             printf("Software-Channel Info:\n");
  172.             for(Num=0; Num<NumS; ++Num) {
  173.               IO->aio_U.aio_ChInfo.acio_Channel=FirstS+Num;
  174.               pOS_DoIO((pOS_IORequest*)IO);
  175.               if(IO->aio_Error==0) {
  176.                 printf(
  177. "Channel = %ld\n"
  178. " ID           = <%.40s>\n"
  179. " AudioMapType = 0x%lx\n"
  180. " Flags        = 0x%lx\n"
  181. " Min. Freq.   = %ld Hz\n"
  182. " Max. Freq.   = %ld Hz\n"
  183. ,
  184. IO->aio_U.aio_ChInfo.acio_Channel,
  185. Data.aid_IDName,
  186. Data.aid_Type,
  187. Data.aid_Channel,
  188. Data.aid_MinFrequence,
  189. Data.aid_MaxFrequence
  190. );
  191.               }
  192.               else printf("AUDIOCMD_ChannelInfo error=%ld\n",IO->aio_Error);
  193.             }
  194.           }
  195.           pOS_CloseDevice((pOS_IORequest*)IO);
  196.         }
  197.         else printf("pOS_OpenDevice failed, error=%ld\n",IO->aio_Error);
  198.         pOS_DeleteIORequest((pOS_IORequest*)IO);
  199.       }
  200.       else printf("pOS_CreateIORequest failed\n");
  201.       pOS_DestructMsgPort(&Port);
  202.     }
  203.     else printf("pOS_ConstructMsgPort failed\n");
  204.  
  205.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  206.   }
  207.   else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  208.  
  209.   pOS_SetShellFail(Err);
  210. }
  211.