Avoid playing data tracks.

This commit is contained in:
Waldeck Schutzer 2003-02-19 22:08:03 +00:00 committed by Alexandre Julliard
parent fab11ed0b9
commit a639d834fe
1 changed files with 58 additions and 19 deletions

View File

@ -187,10 +187,10 @@ static DWORD MCICDA_CalcFrame(WINE_MCICDAUDIO* wmcda, DWORD dwTime)
MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime)); MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
addr = toc.TrackData[wTrack - toc.FirstTrack].Address; addr = toc.TrackData[wTrack - toc.FirstTrack].Address;
TRACE("TMSF trackpos[%u]=%d:%d:%d\n", TRACE("TMSF trackpos[%u]=%d:%d:%d\n",
wTrack, addr[0], addr[1], addr[2]); wTrack, addr[1], addr[2], addr[3]);
dwFrame = CDFRAMES_PERMIN * (addr[0] + MCI_TMSF_MINUTE(dwTime)) + dwFrame = CDFRAMES_PERMIN * (addr[1] + MCI_TMSF_MINUTE(dwTime)) +
CDFRAMES_PERSEC * (addr[1] + MCI_TMSF_SECOND(dwTime)) + CDFRAMES_PERSEC * (addr[2] + MCI_TMSF_SECOND(dwTime)) +
addr[2] + MCI_TMSF_FRAME(dwTime); addr[3] + MCI_TMSF_FRAME(dwTime);
break; break;
} }
return dwFrame; return dwFrame;
@ -677,6 +677,40 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
return ret; return ret;
} }
/**************************************************************************
* MCICDA_SkipDataTracks [internal]
*/
static DWORD MCICDA_SkipDataTracks(WINE_MCICDAUDIO* wmcda,DWORD *frame)
{
int i;
DWORD br;
CDROM_TOC toc;
if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
&toc, sizeof(toc), &br, NULL)) {
WARN("error reading TOC !\n");
return MCICDA_GetError(wmcda);
}
/* Locate first track whose starting frame is bigger than frame */
for(i=toc.FirstTrack;i<=toc.LastTrack+1;i++)
if ( FRAME_OF_TOC(toc, i) > *frame ) break;
if (i <= toc.FirstTrack && i>toc.LastTrack+1) {
i = 0; /* requested address is out of range: go back to start */
*frame = FRAME_OF_TOC(toc,toc.FirstTrack);
}
else
i--;
/* i points to last track whose start address is not greater than frame.
* Now skip non-audio tracks */
for(;i<=toc.LastTrack+1;i++)
if ( ! (toc.TrackData[i-toc.FirstTrack].Control & 4) )
break;
/* The frame will be an address in the next audio track or
* address of lead-out. */
if ( FRAME_OF_TOC(toc, i) > *frame )
*frame = FRAME_OF_TOC(toc, i);
return 0;
}
/************************************************************************** /**************************************************************************
* MCICDA_Play [internal] * MCICDA_Play [internal]
*/ */
@ -684,11 +718,11 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
{ {
WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID); WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID);
DWORD ret = 0, start, end; DWORD ret = 0, start, end;
CDROM_TOC toc;
DWORD br; DWORD br;
CDROM_PLAY_AUDIO_MSF play; CDROM_PLAY_AUDIO_MSF play;
CDROM_SUB_Q_DATA_FORMAT fmt; CDROM_SUB_Q_DATA_FORMAT fmt;
SUB_Q_CHANNEL_DATA data; SUB_Q_CHANNEL_DATA data;
CDROM_TOC toc;
TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
@ -700,6 +734,8 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
if (dwFlags & MCI_FROM) { if (dwFlags & MCI_FROM) {
start = MCICDA_CalcFrame(wmcda, lpParms->dwFrom); start = MCICDA_CalcFrame(wmcda, lpParms->dwFrom);
if ( (ret=MCICDA_SkipDataTracks(wmcda, &start)) )
return ret;
TRACE("MCI_FROM=%08lX -> %lu \n", lpParms->dwFrom, start); TRACE("MCI_FROM=%08lX -> %lu \n", lpParms->dwFrom, start);
} else { } else {
fmt.Format = IOCTL_CDROM_CURRENT_POSITION; fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
@ -708,6 +744,8 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
return MCICDA_GetError(wmcda); return MCICDA_GetError(wmcda);
} }
start = FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress); start = FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress);
if ( (ret=MCICDA_SkipDataTracks(wmcda, &start)) )
return ret;
} }
if (dwFlags & MCI_TO) { if (dwFlags & MCI_TO) {
end = MCICDA_CalcFrame(wmcda, lpParms->dwTo); end = MCICDA_CalcFrame(wmcda, lpParms->dwTo);
@ -817,36 +855,37 @@ static DWORD MCICDA_Seek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
DWORD at; DWORD at;
WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID); WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID);
CDROM_SEEK_AUDIO_MSF seek; CDROM_SEEK_AUDIO_MSF seek;
CDROM_TOC toc; DWORD br, ret;
DWORD br; CDROM_TOC toc;
TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (wmcda == NULL) return MCIERR_INVALID_DEVICE_ID; if (wmcda == NULL) return MCIERR_INVALID_DEVICE_ID;
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
&toc, sizeof(toc), &br, NULL)) {
WARN("error reading TOC !\n");
return MCICDA_GetError(wmcda);
}
switch (dwFlags & ~(MCI_NOTIFY|MCI_WAIT)) { switch (dwFlags & ~(MCI_NOTIFY|MCI_WAIT)) {
case MCI_SEEK_TO_START: case MCI_SEEK_TO_START:
TRACE("Seeking to start\n"); TRACE("Seeking to start\n");
if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0, at = FRAME_OF_TOC(toc,toc.FirstTrack);
&toc, sizeof(toc), &br, NULL)) { if ( (ret=MCICDA_SkipDataTracks(wmcda, &at)) )
WARN("error reading TOC !\n"); return ret;
return MCICDA_GetError(wmcda);
}
at = FRAME_OF_TOC(toc, toc.FirstTrack);
break; break;
case MCI_SEEK_TO_END: case MCI_SEEK_TO_END:
TRACE("Seeking to end\n"); TRACE("Seeking to end\n");
if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
&toc, sizeof(toc), &br, NULL)) {
WARN("error reading TOC !\n");
return MCICDA_GetError(wmcda);
}
at = FRAME_OF_TOC(toc, toc.LastTrack + 1) - 1; at = FRAME_OF_TOC(toc, toc.LastTrack + 1) - 1;
if ( (ret=MCICDA_SkipDataTracks(wmcda, &at)) )
return ret;
break; break;
case MCI_TO: case MCI_TO:
TRACE("Seeking to %lu\n", lpParms->dwTo); TRACE("Seeking to %lu\n", lpParms->dwTo);
at = lpParms->dwTo; at = MCICDA_CalcFrame(wmcda, lpParms->dwTo);
if ( (ret=MCICDA_SkipDataTracks(wmcda, &at)) )
return ret;
break; break;
default: default:
TRACE("Unknown seek action %08lX\n", TRACE("Unknown seek action %08lX\n",