Ejemplo n.º 1
0
int     sa_stream_write(sa_stream_t * s, const void * data, size_t nbytes)
{
  uint32_t        rc;
  size_t          cnt;
  PMCI_MIX_BUFFER pHW;

  if (!s)
    return os2_error(SA_ERROR_NO_INIT, "sa_stream_write", "s is null", 0);
  if (!data)
    return os2_error(SA_ERROR_INVALID, "sa_stream_write", "data is null", 0);

  /* exit if no data */
  if (!nbytes)
    return SA_SUCCESS;

  /* This should only loop on the last write before sa_stream_drain()
   * is called;  at other times, 'nbytes' won't exceed 'bufSize'. */
  while (nbytes) {
    size_t  offs;
    size_t  left;

    /* get the count of free buffers, wait until at least one
     * is available (in practice, this should never block) */
    if (os2_get_free_count(s, 1))
      return SA_ERROR_SYSTEM;

    /* copy as much as will fit into the buffer */
    pHW = &(s->bufList[s->freeNdx]);

    offs = pHW->ulBufferLength;
    left = s->bufSize - offs;
    cnt = (nbytes > left) ? left : nbytes;
    memcpy(&((char*)pHW->pBuffer)[offs], (char*)data, cnt);

    pHW->ulBufferLength += cnt;
    nbytes -= cnt;
    data = (char*)data + cnt;

    /* don't dispatch the buffer until it has bufMin bytes */
    if (pHW->ulBufferLength < s->bufMin)
      continue;

    /* write the buffer to the device */
    rc = s->hwWriteProc(s->hwMixHandle, pHW, 1);
    if (LOUSHORT(rc)) {
      pHW->ulBufferLength = 0;
      return os2_error(SA_ERROR_SYSTEM, "sa_stream_write",
                       "mixWrite - rc=", LOUSHORT(rc));
    }

    /* signal the event thread that a new buffer is now in use */
    __atomic_increment(&s->usedNew);
    s->playing = TRUE;

    s->freeCnt--;
    s->freeNdx = (s->freeNdx + 1) % s->bufCnt;
  }

  return SA_SUCCESS;
}
Ejemplo n.º 2
0
int     sa_stream_get_volume_abs(sa_stream_t *s, float *vol)
{
  int              status = SA_SUCCESS;
  uint32_t         rc;
  MCI_STATUS_PARMS StatusParms;

  if (!s || !vol)
    return os2_error(SA_ERROR_NO_INIT, "sa_stream_get_volume_abs",
                     "s or vol is null", 0);

  memset(&StatusParms, 0, sizeof(MCI_STATUS_PARMS));
  StatusParms.ulItem = MCI_STATUS_VOLUME;

  rc = _mciSendCommand(s->hwDeviceID, MCI_STATUS,
                      MCI_WAIT | MCI_STATUS_ITEM,
                      (void*)&StatusParms, 0);
  if (LOUSHORT(rc)) {
    /* if there's an error, return a reasonable value */
    StatusParms.ulReturn = (50 | 50 << 16);
    status = os2_error(SA_ERROR_SYSTEM, "sa_stream_get_volume_abs",
                       "MCI_STATUS_VOLUME - rc=", LOUSHORT(rc));
  }

  /* left channel is the low-order word, right channel is the
   * high-order word - convert the average of the channels from
   * an integer (range 0 - 100) to a floating point value */

  *vol = (LOUSHORT(StatusParms.ulReturn) +
          HIUSHORT(StatusParms.ulReturn)) / 200.0;

  return status;
}
Ejemplo n.º 3
0
int     sa_stream_resume(sa_stream_t *s)
{
  uint32_t          rc;
  MCI_GENERIC_PARMS GenericParms = { 0 };

  if (!s)
    return os2_error(SA_ERROR_NO_INIT, "sa_stream_resume",
                     "s is null", 0);

  rc = _mciSendCommand(s->hwDeviceID, MCI_ACQUIREDEVICE,
                      MCI_WAIT,
                      (void*)&GenericParms, 0);
  if (LOUSHORT(rc))
    return os2_error(SA_ERROR_SYSTEM, "sa_stream_resume",
                     "MCI_ACQUIREDEVICE - rc=", LOUSHORT(rc));

  /* this may produce a spurious error if the device
   * was just acquired, so report it but ignore it */
  rc = _mciSendCommand(s->hwDeviceID, MCI_RESUME,
                      MCI_WAIT,
                      (void*)&GenericParms, 0);
  if (LOUSHORT(rc))
    os2_error(SA_ERROR_SYSTEM, "sa_stream_resume",
              "MCI_RESUME - rc=", LOUSHORT(rc));

  /* reset the last write time so get_position() doesn't over-adjust */
  DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT,
                  (void*)&s->writeTime, sizeof(s->writeTime));
  s->playing = TRUE;

  return SA_SUCCESS;
}
Ejemplo n.º 4
0
/* Open CDAudio Device - Ready for MCI */
static int SDL_SYS_CDOpen(int drive)
{
MCI_OPEN_PARMS	mop;
MCI_SET_PARMS msp;
MCI_GENERIC_PARMS mgp;

/* Open the device */
mop.hwndCallback = (HWND)NULL;		// None
mop.usDeviceID = (USHORT)NULL;		// Will be returned.
mop.pszDeviceType = (PSZ)SDL_cdlist[drive];		// CDAudio Device
if (LOUSHORT(mciSendCommand(0,MCI_OPEN,MCI_WAIT,&mop, 0)) != MCIERR_SUCCESS) return(CD_ERROR);
/* Set time format */
msp.hwndCallback = (HWND)NULL;		// None
msp.ulTimeFormat = MCI_FORMAT_MSF;	// Minute : Second : Frame structure
msp.ulSpeedFormat = (ULONG)NULL;		// No change
msp.ulAudio = (ULONG)NULL;				// No Channel
msp.ulLevel = (ULONG)NULL;				// No Volume
msp.ulOver = (ULONG)NULL;				// No Delay
msp.ulItem = (ULONG)NULL;				// No item
msp.ulValue = (ULONG)NULL;				// No value for item flag
if (LOUSHORT(mciSendCommand(mop.usDeviceID,MCI_SET,MCI_WAIT | MCI_SET_TIME_FORMAT,&msp, 0)) == MCIERR_SUCCESS) return (mop.usDeviceID);
/* Error setting time format? - Close opened device */
mgp.hwndCallback = (HWND)NULL;		// None
mciSendCommand(mop.usDeviceID,MCI_CLOSE,MCI_WAIT,&mgp, 0);
return(CD_ERROR);
}
Ejemplo n.º 5
0
int main(int argc, char *argv[]) {
	MMIOINFO mmioinfo;
	HMMIO hmmio;
    MCI_OPEN_PARMS openParams;
    PSZ fileName = "test.ogg";
	ULONG ulFlags;
	int rc;
	
	printf("start\n");
    memset (&mmioinfo, 0, sizeof(MMIOINFO));
    mmioinfo.fccIOProc = FOURCC_Vorbis;
//    mmioinfo.fccIOProc = mmioFOURCC('W','A','V','E');
    ulFlags = MMIO_WRITE | MMIO_DENYNONE | MMIO_CREATE;
    mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER | MMIO_TRANSLATEDATA;
 
    hmmio = mmioOpen(fileName, &mmioinfo, ulFlags);
    if (!hmmio) {
       printf("Can't open %s:%ld.\n",fileName,mmioinfo.ulErrorRet);
       return -1;
    } 
    
    memset (&openParams, 0, sizeof(openParams));
    openParams.pszDeviceType = "WaveAudio";
    openParams.pszElementName = (PSZ)hmmio;
    rc = mciSendCommand (0, MCI_OPEN, MCI_WAIT | MCI_OPEN_MMIO,&openParams,0);
    
    if (LOUSHORT(rc) == MCIERR_SUCCESS) {
        USHORT usDeviceID = openParams.usDeviceID;
        MCI_RECORD_PARMS recParams;
  
        memset (&recParams, 0, sizeof(recParams));
        rc = mciSendCommand (usDeviceID, MCI_RECORD,0 , &recParams, 0);
        if (LOUSHORT(rc)== MCIERR_SUCCESS) {
            sleep(2);
            rc = mciSendCommand (usDeviceID, MCI_STOP, MCI_WAIT, 0, 0);
            if (LOUSHORT(rc) == MCIERR_SUCCESS) {
              MCI_SAVE_PARMS saveParams;

              memset (&saveParams, 0, sizeof(saveParams));
              rc = mciSendCommand (usDeviceID, MCI_SAVE, MCI_WAIT,&saveParams , 0);
              if (LOUSHORT(rc) != MCIERR_SUCCESS) {
               printf("save failed:%d.\n",rc);
              }
            } else {
               printf("stop failed:%d.\n",rc);
            }
        } else {
           printf("Can't record:%d.\n",rc);
        } /* endif */

        rc = mciSendCommand (usDeviceID, MCI_CLOSE, MCI_WAIT, 0, 0);
        if (LOUSHORT(rc) != MCIERR_SUCCESS) {
           printf("Can't close audioDevice:%d.\n",rc);
        } /* endif */
    } else {
       printf("Can't open audioDevice:%d.\n",rc);
    }    
    return mmioClose(hmmio, 0);
}
Ejemplo n.º 6
0
BOOL mwpLoad(HWND hWnd)
{
   ULONG          ulError = 0;
   MCI_LOAD_PARMS mciLoadParms;
   PSTRINGLIST    pEntry = (PSTRINGLIST)WinQueryWindowPtr(hWnd, QWP_CURRENTENTRY);
   USHORT         usDeviceID = WinQueryWindowUShort(hWnd, QWS_DEVICEID);
   BOOL           fSuccess = TRUE;

   WinSetPBValue(WinWindowFromID(hWnd, PB_PROGRESS), 0);

   memset((void*)&mciLoadParms, 0, sizeof(MCI_LOAD_PARMS));

   mciLoadParms.pszElementName = pEntry->pszString;
   ulError = mciSendCommand(usDeviceID, MCI_LOAD, MCI_WAIT | MCI_OPEN_ELEMENT | MCI_READONLY, (PVOID)&mciLoadParms, (USHORT)0);
   if(LOUSHORT(ulError) != MCIERR_SUCCESS)
      fSuccess = FALSE;

   if(fSuccess)
   {
      MCI_STATUS_PARMS   msp;

      memset((void*)&msp, 0, sizeof(msp));

      msp.ulItem = MCI_STATUS_LENGTH;

      ulError = mciSendCommand(usDeviceID, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (PVOID)&msp, (USHORT)0);
      if(LOUSHORT(ulError) == MCIERR_SUCCESS)
      {
         WinSetPBLimits(WinWindowFromID(hWnd, PB_PROGRESS), 0, msp.ulReturn);
      }
   }

   if(fSuccess)
   {
      MCI_POSITION_PARMS mppPos;

      memset((void*)&mppPos, 0, sizeof(mppPos));

      mppPos.hwndCallback = hWnd;
      mppPos.ulUnits = MSECTOMM(500);
      ulError = mciSendCommand(usDeviceID, MCI_SET_POSITION_ADVISE, MCI_NOTIFY | MCI_SET_POSITION_ADVISE_ON, (PVOID)&mppPos, (USHORT)0);
      if(LOUSHORT(ulError) != MCIERR_SUCCESS)
         fSuccess = FALSE;
   }

   if(fSuccess)
   {
      PSZ   pszTitle = new char[128];
      MakeWndTitleFromPathName(pszTitle, pEntry->pszString);
      WinSetWindowText(WinQueryWindow(hWnd, QW_PARENT), pszTitle);
      delete pszTitle;
   }

   return fSuccess;
}
Ejemplo n.º 7
0
/* Get CD-ROM status - Ready for MCI */
static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
{
CDstatus status;
MCI_STATUS_PARMS msp;

/* Get Status from MCI */
msp.hwndCallback = (HWND)NULL; /* None */
msp.ulReturn = (ULONG)NULL; /* We want this information */
msp.ulItem = MCI_STATUS_MODE;
msp.ulValue = (ULONG)NULL; /* No additional information */
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) status = CD_ERROR;
else
	{
	switch(msp.ulReturn)
		{
		case	MCI_MODE_NOT_READY:
			status = CD_TRAYEMPTY;
			break;
		case	MCI_MODE_PAUSE:
			status = CD_PAUSED;
			break;
		case	MCI_MODE_PLAY:
			status = CD_PLAYING;
			break;
		case	MCI_MODE_STOP:
			status = CD_STOPPED;
			break;
		/* These cases should not occour */
		case	MCI_MODE_RECORD:
		case	MCI_MODE_SEEK:
		default:
			status = CD_ERROR;
			break;
		}
	}

/* Determine position */
if (position != NULL) /* The SDL $&$&%# CDROM call sends NULL pointer here! */
	{
		if ((status == CD_PLAYING) || (status == CD_PAUSED))
		{
		/* Get Position */
		msp.hwndCallback = (HWND)NULL; /* None */
		msp.ulReturn = (ULONG)NULL; /* We want this information */
		msp.ulItem = MCI_STATUS_POSITION;
		msp.ulValue = (ULONG)NULL; /* No additiona info */
		if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) return (CD_ERROR);
		/* Convert from MSF (format selected in the Open process) to Frames (format that will be returned) */
		*position = MSF_TO_FRAMES(MSF_MINUTE(msp.ulReturn),MSF_SECOND(msp.ulReturn),MSF_FRAME(msp.ulReturn));
		}
	else *position = 0;
	}
return(status);
}
Ejemplo n.º 8
0
static void os2_stop_device(uint16_t hwDeviceID)
{
  uint32_t          rc;
  MCI_GENERIC_PARMS GenericParms = { 0 };

  rc = _mciSendCommand(hwDeviceID, MCI_STOP,
                      MCI_WAIT,
                      (void*)&GenericParms, 0);
  if (LOUSHORT(rc))
    os2_error(0, "os2_stop_device", "MCI_STOP - rc=", LOUSHORT(rc));

  return;
}
MRESULT EXPENTRY ClientWndProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    HPS     hps;
    BOOL    bHandled = TRUE;
    MRESULT mReturn  = 0;

    switch (msg)
    {
        case WM_PAINT:
            hps = WinBeginPaint (hWnd,0,0);
            WinEndPaint (hps);
            break;

        case WM_ERASEBACKGROUND:
            mReturn = MRFROMLONG(1L);
            break;

		  case WM_COMMAND:
		      switch (LOUSHORT(mp1))
            {
                case IDM_ABOUT:
                    DisplayAbout (hWnd, szTitle);
                    break;
            }

        default:
            bHandled = FALSE;
            break;
    }

    if (!bHandled)
        mReturn = WinDefWindowProc (hWnd,msg,mp1,mp2);

    return (mReturn);
}
Ejemplo n.º 10
0
BOOL PSMMRewindWave( USHORT usDevID )
{
    MCI_SEEK_PARMS      mseekp;
    MCI_GENERIC_PARMS   mgenp;
    ULONG               ulRC;
    char                pszErrBuf[ 128 ];

    if( !usDevID )
    {
        return( FALSE );
    }

    memset( &mseekp, 0, sizeof( mseekp ) );
    memset( &mgenp, 0, sizeof( mgenp ) );

    ulRC = mciSendCommand(  usDevID,
                            MCI_ACQUIREDEVICE,
                            MCI_WAIT,
                            &mgenp,
                            0 );

    ulRC = mciSendCommand(  usDevID,
                            MCI_SEEK,
                            MCI_WAIT | MCI_TO_START,
                            &mseekp,
                            0 );

    if( LOUSHORT( ulRC ) != MCIERR_SUCCESS )
    {
        mciGetErrorString( ulRC, pszErrBuf, sizeof( pszErrBuf ) );
        return( FALSE );
    }

    return( TRUE );
}
/**************************************************************************\
*                                                                          *
*       ROUTINE:    AlarmDlgProc ( )                                       *
*                                                                          *
*       COMMENT:    "Alarm..." dialog                                      *
*                                                                          *
*       RETURNS:    MRESULT, 0 or return value from WinDefDlgProc          *
*                                                                          *
\**************************************************************************/
MRESULT EXPENTRY AlarmDlgProc(HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2)
{
   switch (usMsg)
   {
   case WM_INITDLG:
      hAlarmTime = hwnd; /* Put in a global variable so all functions know
                             we have already have an opened dialog box.  */
      InitAlarm(hwnd);
      break;

   case WM_COMMAND:
      switch (LOUSHORT(mp1))
      {
      case DID_OK:
         AlarmSet(hwnd);

      case DID_CANCEL:
         hAlarmTime = NULLHANDLE;
         WinDismissDlg(hwnd, TRUE);
      }
      return NULL;

   case WM_CONTROL:
      break;

   case WM_VSCROLL:
      AlarmVScrolls(hwnd, HIUSHORT(mp2), mp1);
      break;
   }
   return WinDefDlgProc(hwnd, usMsg, mp1, mp2);
}
Ejemplo n.º 12
0
/*------------------------------------------------------------------------*/
MRESULT EXPENTRY ClientDlgProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
   SWP   swp;
  
   switch(msg)
   {
      case WM_INITDLG:
         WinQueryWindowPos(hwnd, (PSWP)&swp);
         WinSetWindowPos(hwnd, HWND_TOP,
		       ((WinQuerySysValue(HWND_DESKTOP,	SV_CXSCREEN) - swp.cx) / 2),
		       ((WinQuerySysValue(HWND_DESKTOP,	SV_CYSCREEN) - swp.cy) / 2),
		       0, 0, SWP_MOVE);
         return (MRESULT)0;

      case WM_COMMAND:
         switch(LOUSHORT(mp1))
         {
            case DID_OK:
               WinDismissDlg( hwnd, DID_OK);
               break;
            case ID_SPLHLP: /* Tell them how to register this version */
               ShowDlgHelp(hwnd);
               break;
         }
         return (MRESULT)0;
   }
   return( WinDefDlgProc(hwnd, msg, mp1, mp2) );
}
Ejemplo n.º 13
0
MRESULT APIENTRY wpDlg (
    HWND hwnd,
    MSG_TYPE msg,
    MPARAM mp1,
    MPARAM mp2)
{ /* wpDlg Start */
    MRESULT Result = 0;

    switch (msg)
    { /* switch (msg) START */
    case WM_INITDLG:
        { /* WM_INITDLG Start */
            HWND hwndMenu;
            ULONG id;

            /* load the menu, since currently it seems to be impossible
            ** to get the menu otherwise during startup of the dialog
            */
            id = WinQueryWindowUShort (hwnd, (ULONG) QWS_ID);
            hwndMenu = WinLoadMenu (hwnd, (HMODULE) 0, id);
        } /* WM_INITDLG End */
        break;

    case WM_COMMAND:
        { /* WM_COMMAND Start */
            switch (LOUSHORT(mp1))
            {
            case ID_MENU_1:
                {
                    WinAlarm (HWND_DESKTOP, (ULONG) WA_ERROR);
                    WinAlarm (HWND_DESKTOP, (ULONG) WA_NOTE);
                    WinAlarm (HWND_DESKTOP, (ULONG) WA_ERROR);
                    WinAlarm (HWND_DESKTOP, (ULONG) WA_NOTE);
                }
                break;

            case DID_OK:
                { /* do anything... */
                }
                break;

            default:
                Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 );
                break;
            }
        } /* WM_COMMAND End */
        break;

    case WM_CLOSE:
    default:
        /* any other message will be handled here,
        ** also the button problem...
        */
        Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 );
        break;
    } /* switch (msg) END */

    return (Result);
} /* wpDlg End */
Ejemplo n.º 14
0
/* Resume play - Ready for MCI */
static int SDL_SYS_CDResume(SDL_CD *cdrom)
{
MCI_GENERIC_PARMS mgp;

mgp.hwndCallback = (HWND)NULL;		// None
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_RESUME,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0;
return(CD_ERROR);
}
Ejemplo n.º 15
0
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   HPS      hps;
   RECTL    rcl;
   static ULONG    i = 1;
   ULONG    ulMem;
   char     szBuf[200];

   switch (msg) {
      case WM_CREATE:
         /* use smaller text */
         WinSetPresParam(hwnd, PP_FONTNAMESIZE, 7, (PVOID)"8.Helv");
         /* start the timer (ticks each 0.5 sec.) */
         AddFloat(WinQueryWindow(hwnd, QW_PARENT));
         WinStartTimer(hab, hwnd, ID_TIMER, 500);
         break;

      /* make window always stay on top (if desired) */
      case WM_VRNENABLED:
         if (bFloat)
            WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
         break;

      case WM_COMMAND:  /* why doesn't WM_SYSCOMMAND work? */
         if (LOUSHORT(mp1) == IDM_FLOAT) {
            bFloat = !bFloat;
            WinCheckMenuItem(hwndSysSubmenu, IDM_FLOAT, bFloat);
         }
         break;

      case WM_TIMER:
         if (++i > 13)
            i = 1;
         WinInvalidateRect(hwnd, NULL, FALSE);
         return FALSE;

      case WM_PAINT:
         hps = WinBeginPaint(hwnd, NULLHANDLE, &rcl);
         /* necessary to avoid incorrectly repainting window */
         WinQueryWindowRect(hwnd, &rcl);

/*         sprintf(szBuf, " Current use %dK  Maximum ever used %dK  Errors %d",
                 meminfo->used / 1024,
                 meminfo->maxused / 1024, meminfo->num_err);*/
         sprintf(szBuf, " Current use %dB  Maximum ever used %dK  Errors %d",
                 meminfo->used,
                 meminfo->maxused / 1024, meminfo->num_err);
         WinDrawText(hps, -1, szBuf, &rcl, CLR_BLACK, CLR_WHITE,
                     DT_CENTER | DT_VCENTER | DT_ERASERECT);

         WinEndPaint(hps);
         break;
   }

   return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Ejemplo n.º 16
0
static int  os2_pause_device(uint16_t hwDeviceID, uint32_t release)
{
  uint32_t          rc;
  MCI_GENERIC_PARMS GenericParms = { 0 };

  rc = _mciSendCommand(hwDeviceID, MCI_PAUSE,
                      MCI_WAIT,
                      (void*)&GenericParms, 0);
  if (LOUSHORT(rc))
    return os2_error(SA_ERROR_SYSTEM, "os2_pause_device",
                     "MCI_PAUSE - rc=", LOUSHORT(rc));

  if (release)
    _mciSendCommand(hwDeviceID, MCI_RELEASEDEVICE,
                   MCI_WAIT,
                   (void*)&GenericParms, 0);

  return SA_SUCCESS;
}
Ejemplo n.º 17
0
/* Start play - Ready for MCI */
static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
{
MCI_GENERIC_PARMS mgp;
MCI_STATUS_PARMS msp;
MCI_PLAY_PARMS	mpp;
ULONG min,sec,frm;

/* Start MSF */
FRAMES_TO_MSF(start, &min, &sec, &frm);
MSF_MINUTE(mpp.ulFrom) = min;
MSF_SECOND(mpp.ulFrom) = sec;
MSF_FRAME(mpp.ulFrom) = frm;
/* End MSF */
FRAMES_TO_MSF(start+length, &min, &sec, &frm);
MSF_MINUTE(mpp.ulTo) = min;
MSF_SECOND(mpp.ulTo) = sec;
MSF_FRAME(mpp.ulTo) = frm;
#ifdef DEBUG_CDROM
	fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
	playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
	playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
#endif
/* Verifies if it is paused first... and if it is, unpause before stopping it. */
msp.hwndCallback = (HWND)NULL; /* None */
msp.ulReturn = (ULONG)NULL; /* We want this information */
msp.ulItem = MCI_STATUS_MODE;
msp.ulValue = (ULONG)NULL; /* No additional information */
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS)
	{
	if (msp.ulReturn == MCI_MODE_PAUSE)
		{
		mgp.hwndCallback = (HWND)NULL;		// None
		mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0);
		}
	}
/* Now play it. */
mpp.hwndCallback = (HWND)NULL;		// We do not want the info. temp
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_PLAY,MCI_FROM | MCI_TO,&mpp, 0)) == MCIERR_SUCCESS) return 0;
return (CD_ERROR);
}
Ejemplo n.º 18
0
USHORT usCopyEAS(PVOLINFO pVolInfo, ULONG ulSrcDirCluster, PSZ pszSrcFile, ULONG ulTarDirCluster, PSZ pszTarFile)
{
    USHORT rc;
    ULONG ulSrcCluster, ulTarCluster;
    PSZ   pszSrcEAName = NULL,
          pszTarEAName = NULL;
    DIRENTRY SrcEntry, TarEntry;

    rc = GetEASName(pVolInfo, ulSrcDirCluster, pszSrcFile, &pszSrcEAName);
    if (rc)
        goto usCopyEASExit;
    rc = GetEASName(pVolInfo, ulTarDirCluster, pszTarFile, &pszTarEAName);
    if (rc)
        goto usCopyEASExit;

    ulSrcCluster = FindPathCluster(pVolInfo, ulSrcDirCluster, pszSrcEAName, &SrcEntry, NULL);
    ulTarCluster = FindPathCluster(pVolInfo, ulTarDirCluster, pszTarEAName, &TarEntry, NULL);
    if (ulTarCluster != FAT_EOF)
    {
        rc = ModifyDirectory(pVolInfo, ulTarDirCluster, MODIFY_DIR_DELETE, &TarEntry, NULL, NULL, 0);
        if (rc)
            goto usCopyEASExit;
        DeleteFatChain(pVolInfo, ulTarCluster);
    }

    if (ulSrcCluster == FAT_EOF)
        goto usCopyEASExit;

    rc = CopyChain(pVolInfo, ulSrcCluster, &ulTarCluster);
    if (rc)
        goto usCopyEASExit;

    SrcEntry.wCluster = LOUSHORT(ulTarCluster);
    SrcEntry.wClusterHigh = HIUSHORT(ulTarCluster);

    /*
       Make new direntry
    */
    rc = ModifyDirectory(pVolInfo, ulTarDirCluster, MODIFY_DIR_INSERT, NULL, &SrcEntry, pszTarEAName, 0);


usCopyEASExit:
    if (pszSrcEAName)
        free(pszSrcEAName);
    if (pszTarEAName)
        free(pszTarEAName);

    if (f32Parms.fMessageActive & LOG_EAS)
        Message("usCopyEAS for returned %d", rc);

    return rc;
}
Ejemplo n.º 19
0
int     sa_stream_destroy(sa_stream_t *s)
{
  int               status = SA_SUCCESS;
  uint32_t          rc;
  MCI_GENERIC_PARMS GenericParms = { 0 };
  MCI_BUFFER_PARMS  BufferParms;

  if (!s)
    return os2_error(SA_ERROR_NO_INIT, "sa_stream_destroy", "s is null", 0);

  /* if the device was opened, close it */
  if (s->hwDeviceID) {

    /* prevent os2_mixer_event() from reacting to a buffer under-run */
    s->bufMin = 0;
    s->playing = FALSE;

    /* If another instance has already acquired the device the
     * MCI commands below will fail, so re-acquire it temporarily.
     * MCI_CLOSE will release the device to the previous owner. */
    rc = _mciSendCommand(s->hwDeviceID, MCI_ACQUIREDEVICE,
                         MCI_WAIT,
                         (void*)&GenericParms, 0);
    if (LOUSHORT(rc))
      os2_error(0, "sa_stream_destroy",
                "MCI_ACQUIREDEVICE - rc=", LOUSHORT(rc));

    /* stop the device (which may not actually be playing) */
    os2_stop_device(s->hwDeviceID);

    /* if hardware buffers were allocated, free them */
    if (s->bufCnt) {
      BufferParms.hwndCallback   = 0;
      BufferParms.ulStructLength = sizeof(MCI_BUFFER_PARMS);
      BufferParms.ulNumBuffers   = s->bufCnt;
      BufferParms.ulBufferSize   = s->bufSize;
      BufferParms.pBufList       = s->bufList;

      rc = _mciSendCommand(s->hwDeviceID, MCI_BUFFER,
                          MCI_WAIT | MCI_DEALLOCATE_MEMORY,
                          (void*)&BufferParms, 0);
      if (LOUSHORT(rc))
        status = os2_error(SA_ERROR_SYSTEM, "sa_stream_destroy",
                           "MCI_DEALLOCATE_MEMORY - rc=", LOUSHORT(rc));
    }

    rc = _mciSendCommand(s->hwDeviceID, MCI_CLOSE,
                        MCI_WAIT,
                        (void*)&GenericParms, 0);
    if (LOUSHORT(rc))
      status = os2_error(SA_ERROR_SYSTEM, "sa_stream_destroy",
                         "MCI_CLOSE - rc=", LOUSHORT(rc));
  }

  /* free other resources we allocated */
  DosFreeMem(s);

  return status;
}
Ejemplo n.º 20
0
/* Stop play - Ready for MCI */
static int SDL_SYS_CDStop(SDL_CD *cdrom)
{
MCI_GENERIC_PARMS mgp;
MCI_STATUS_PARMS msp;

/* Verifies if it is paused first... and if it is, unpause before stopping it. */
msp.hwndCallback = (HWND)NULL; /* None */
msp.ulReturn = (ULONG)NULL; /* We want this information */
msp.ulItem = MCI_STATUS_MODE;
msp.ulValue = (ULONG)NULL; /* No additional information */
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS)
	{
	if (msp.ulReturn == MCI_MODE_PAUSE)
		{
		mgp.hwndCallback = (HWND)NULL;		// None
		mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0);
		}
	}
/* Now stops the media */
mgp.hwndCallback = (HWND)NULL;		// None
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STOP,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0;
return(CD_ERROR);
}
Ejemplo n.º 21
0
int     sa_stream_set_volume_abs(sa_stream_t *s, float vol)
{
  uint32_t      rc;
  MCI_SET_PARMS SetParms;

  if (!s)
    return os2_error(SA_ERROR_NO_INIT, "sa_stream_set_volume_abs",
                     "s is null", 0);

  /* convert f.p. value to an integer value ranging
   * from 0 to 100 and apply to both channels */
  SetParms.ulLevel = (vol * 100);
  SetParms.ulAudio = MCI_SET_AUDIO_ALL;

  rc = _mciSendCommand(s->hwDeviceID, MCI_SET,
                      MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME,
                      (void*)&SetParms, 0);
  if (LOUSHORT(rc))
    return os2_error(SA_ERROR_SYSTEM, "sa_stream_set_volume_abs",
                     "MCI_SET_VOLUME - rc=", LOUSHORT(rc));

  return SA_SUCCESS;
}
Ejemplo n.º 22
0
/* Eject the CD-ROM - Ready for MCI */
static int SDL_SYS_CDEject(SDL_CD *cdrom)
{
MCI_SET_PARMS msp;

msp.hwndCallback = (HWND)NULL;		// None
msp.ulTimeFormat = (ULONG)NULL;		// No change
msp.ulSpeedFormat = (ULONG)NULL;		// No change
msp.ulAudio = (ULONG)NULL;				// No Channel
msp.ulLevel = (ULONG)NULL;				// No Volume
msp.ulOver = (ULONG)NULL;				// No Delay
msp.ulItem = (ULONG)NULL;					// No item
msp.ulValue = (ULONG)NULL;					// No value for item flag
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_SET,MCI_WAIT | MCI_SET_DOOR_OPEN,&msp, 0)) == MCIERR_SUCCESS) return 0;
return(CD_ERROR);
}
Ejemplo n.º 23
0
/**
 * Probes and initializes.
 */
static int Open (vlc_object_t *obj)
{
    services_discovery_t *sd = (services_discovery_t *)obj;

    HFILE hcd2;
    ULONG ulAction;
    ULONG ulParamLen;
    ULONG ulData;
    ULONG ulDataLen;
    ULONG rc;

    sd->description = _("Discs");

    if (DosOpen ((PSZ)"CD-ROM2$", (PHFILE)&hcd2, &ulAction, 0, FILE_NORMAL,
                 OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
                 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL))
        return VLC_EGENERIC;

    rc = DosDevIOCtl (hcd2, IOCTL_CDROMDISK2, CDROMDISK2_DRIVELETTERS,
                      NULL, 0, &ulParamLen, &ulData, sizeof(ulData), &ulDataLen);
    if (!rc)
    {
        char mrl[] = "file:///A:/", name[] = "A:";

        int count = LOUSHORT(ulData);
        int drive = HIUSHORT(ulData);

        input_item_t *item;
        char          letter;

        for (; count; --count, ++drive)
        {
            letter = 'A' + drive;

            mrl[8] = name[0] = letter;
            item = input_item_NewDisc (mrl, name, -1);
            msg_Dbg (sd, "adding %s (%s)", mrl, name);
            if (item == NULL)
                break;

            services_discovery_AddItem (sd, item);
        }
    }

    DosClose (hcd2);

    return rc ? VLC_EGENERIC : VLC_SUCCESS;
}
Ejemplo n.º 24
0
BOOL mwpPlay(HWND hWnd)
{
   ULONG          ulError = 0;
   MCI_PLAY_PARMS mciPlayParms;
   USHORT         usDeviceID = WinQueryWindowUShort(hWnd, QWS_DEVICEID);
   BOOL           fSuccess = TRUE;

   memset((void*)&mciPlayParms, 0, sizeof(mciPlayParms));

   mciPlayParms.hwndCallback = hWnd;
   ulError = mciSendCommand(usDeviceID, MCI_PLAY, MCI_NOTIFY, (PVOID)&mciPlayParms, MMUP_PLAY);
   if(LOUSHORT(ulError) != MCIERR_SUCCESS)
      fSuccess = FALSE;

   return fSuccess;
}
Ejemplo n.º 25
0
/* Ready for MCI CDAudio Devices */
int  SDL_SYS_CDInit(void)
{
int i; /* generig counter */
MCI_SYSINFO_PARMS		msp;	/* Structure to MCI SysInfo parameters */
CHAR 						SysInfoRet[MCI_CMDRETBUFSIZE];	/* Buffer for MCI Command result */

/* Fill in our driver capabilities */
SDL_CDcaps.Name = SDL_SYS_CDName;
SDL_CDcaps.Open = SDL_SYS_CDOpen;
SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
SDL_CDcaps.Status = SDL_SYS_CDStatus;
SDL_CDcaps.Play = SDL_SYS_CDPlay;
SDL_CDcaps.Pause = SDL_SYS_CDPause;
SDL_CDcaps.Resume = SDL_SYS_CDResume;
SDL_CDcaps.Stop = SDL_SYS_CDStop;
SDL_CDcaps.Eject = SDL_SYS_CDEject;
SDL_CDcaps.Close = SDL_SYS_CDClose;

/* Get the number of CD ROMs in the System */
/* Clean SysInfo structure */
SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS));
/* Prepare structure to Ask Numer of Audio CDs */
msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO;	/* CD Audio Type */
msp.pszReturn = (PSZ)&SysInfoRet; 	/* Return Structure */
msp.ulRetSize = MCI_CMDRETBUFSIZE; 	/* Size of ret struct */
if (LOUSHORT(mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID)&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR);
SDL_numcds = atoi(SysInfoRet);
if (SDL_numcds > MAX_DRIVES) SDL_numcds = MAX_DRIVES; /* Limit maximum CD number */

/* Get and Add their system name to the SDL_cdlist */
msp.pszReturn = (PSZ)&SysInfoRet; 				/* Return Structure */
msp.ulRetSize = MCI_CMDRETBUFSIZE; 			/* Size of ret struct */
msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO;		/* CD Audio Type */
for (i=0; i<SDL_numcds; i++)
	{
	msp.ulNumber = i+1;
	mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0);
	SDL_cdlist[i] = SDL_strdup(SysInfoRet);
	if ( SDL_cdlist[i] == NULL )
		{
		SDL_OutOfMemory();
		return(-1);
		}
	}
return(0);
}
MRESULT EXPENTRY DrivesDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    BOOL    bHandled = TRUE;
    MRESULT mReturn  = 0;

    switch (msg)
    {           
        case WM_INITDLG:
            QueryDrives (hWnd);
            break;

        case WM_CONTROL:
            switch (LOUSHORT(mp1))
            {
                case IDC_DRIVELIST:
                    if (HIUSHORT(mp1) == CBN_EFCHANGE)
                    {
                        DisplayDriveInfo (hWnd,
                            (ULONG)WinSendDlgItemMsg (hWnd, IDC_DRIVELIST, 
                                LM_QUERYSELECTION, (MPARAM)LIT_FIRST, 0L));
                    }
                    break;
            }
            break;

        case WM_SYSCOMMAND:
		      switch (SHORT1FROMMP(mp1))
            {
				    case SC_CLOSE:
                    WinDismissDlg (hWnd, FALSE);
                    bHandled = TRUE;
                    break;
            }
            break;

        default:
            bHandled = FALSE;
            break;
    }

    if (!bHandled)
        mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);

    return (mReturn);
}
Ejemplo n.º 27
0
BOOL WndSize(HWND hwnd,MPARAM mp2)
{
    RECTL rcl;

    usWndDepth = HIUSHORT(mp2)/ stCell.cy;
    usWndWidth = LOUSHORT(mp2)/ stCell.cx;

    /************************************************************************/
    /* The test below caters for the first instance of WM_SIZE that invokes */
    /* this function BEFORE window creation is complete and the Frame handle*/
    /* has been set.                                                        */
    /************************************************************************/

    hwndFrame = (hwndFrame != (HWND)0) ? hwndFrame : WinQueryWindow(hwnd,QW_PARENT);
    WinQueryWindowRect(hwndClient,&rcl);
    ulWindowWidth = rcl.xRight;
    ulWindowHeight = rcl.yTop;
    WinInvalidateRect(hwnd,(PRECTL)0,FALSE);
    return(TRUE);
}
Ejemplo n.º 28
0
MRESULT EXPENTRY GenDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PPREF_GEN pgen;

   switch (msg) {

      case WM_INITDLG:
         pgen = (PPREF_GEN)PVOIDFROMMP(mp2);
         InitGeneralPage(hwnd, pgen);
         break;
      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == CBOX_DEF_LEN &&
             SHORT2FROMMP(mp1) == BN_CLICKED)
            WinEnableControl(hwnd, SPIN_SUBJ_LEN,
                         !WinQueryButtonCheckstate(hwnd, CBOX_DEF_LEN));
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
         case BTN_FONT: {
            char achFont[FACESIZE];  // buffer usato per i dati del nuovo font
            if (ShowFontDlg(hwnd, achFont))
               WinSetDlgItemText(hwnd, TXT_FONT, achFont);
            }
            break;
         case BTTN_UNDO:
            InitGeneralPage(hwnd, pgen);
            break;
         case BTTN_DEFAULT:
            SetGeneralDefault(hwnd, pgen);
            break;
         default:
           break;
         } /* endswitch */
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
         break;
   } /* endswitch */
   return (MRESULT) FALSE;
}
Ejemplo n.º 29
0
MRESULT EXPENTRY SelDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PPREF_SEL psel;

   switch (msg) {
      case WM_INITDLG:
         psel = (PPREF_SEL)PVOIDFROMMP(mp2);
         InitSelectionPage(hwnd, psel);
         break;
      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == CBOX_EXT_SEL &&
             SHORT2FROMMP(mp1) == BN_CLICKED) {
            WinEnableControl(hwnd, CBOX_SEL_ALL_INDIR,
                         WinQueryButtonCheckstate(hwnd, CBOX_EXT_SEL));
         } else if (SHORT1FROMMP(mp1) == CBOX_FILE_WIN &&
                    SHORT2FROMMP(mp1) == BN_CLICKED) {
            WinEnableControl(hwnd, CBOX_ONLY_DIR,
                         WinQueryButtonCheckstate(hwnd, CBOX_FILE_WIN));
         } /* endif */
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
            case BTTN_UNDO:
               InitSelectionPage(hwnd, psel);
               break;
            case BTTN_DEFAULT:
               SetSelectionDefault(hwnd);
               break;  
            default:
               break;
         } /* endswitch */
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
         break;
   } /* endswitch */
   return (MRESULT) FALSE;
}
Ejemplo n.º 30
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static SHORT cxClient, cyClient ;
     HPS          hps ;

     switch (msg)
	  {
          case WM_SIZE:
               cxClient = LOUSHORT (mp2) ;
               cyClient = HIUSHORT (mp2) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;

               GpiErase (hps) ;

               PaintClient (hps, cxClient, cyClient) ;

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }