$NetBSD: patch-af,v 1.4 1998/12/14 02:17:11 tv Exp $ --- multimedia/mcicda.c.orig Thu Dec 10 04:03:00 1998 +++ multimedia/mcicda.c Sun Dec 13 11:00:34 1998 @@ -18,6 +18,10 @@ #include "debug.h" #include "multimedia.h" +#ifdef __NetBSD__ +#include +#include +#else #ifdef HAVE_LINUX_CDROM_H # include #endif @@ -30,12 +34,17 @@ #ifdef HAVE_SYS_CDIO_H # include #endif +#endif +#ifdef __NetBSD__ +#define CDAUDIO_DEV "/dev/rcd0d" +#else #ifdef __FreeBSD__ # define CDAUDIO_DEV "/dev/rcd0c" #else # define CDAUDIO_DEV "/dev/cdrom" #endif +#endif #ifdef SOUND_VERSION # define IOCTL(a,b,c) ioctl(a,b,&c) @@ -50,7 +59,7 @@ #define CDFRAMES_PERMIN 4500 #define SECONDS_PERMIN 60 -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) typedef struct { int nUseCount; /* Incremented for each shared open */ BOOL16 fShareable; /* TRUE if first open was shareable */ @@ -61,7 +70,7 @@ int unixdev; #ifdef linux struct cdrom_subchnl sc; -#elif defined(__FreeBSD__) +#else struct cd_sub_channel_info sc; #endif int cdMode; @@ -103,27 +112,25 @@ */ static UINT16 CDAUDIO_GetNumberOfTracks(WINE_CDAUDIO* wcda) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) #ifdef linux struct cdrom_tochdr hdr; -#elif defined(__FreeBSD__) +#else struct ioc_toc_header hdr; #endif if (wcda->nTracks == 0) { - if (ioctl(wcda->unixdev, #ifdef linux - CDROMREADTOCHDR -#elif defined(__FreeBSD__) - CDIOREADTOCHEADER + if (ioctl(wcda->unixdev, CDROMREADTOCHDR, &hdr)) { +#else + if (ioctl(wcda->unixdev, CDIOREADTOCHEADER, &hdr)) { #endif - , &hdr)) { WARN(cdaudio, "(%p) -- Error occured !\n", wcda); return (WORD)-1; } #ifdef linux wcda->nTracks = hdr.cdth_trk1; -#elif defined(__FreeBSD__) +#else wcda->nTracks = hdr.ending_track - hdr.starting_track + 1; #endif } @@ -139,13 +146,13 @@ */ static BOOL32 CDAUDIO_GetTracksInfo(WINE_CDAUDIO* wcda) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) int i, length; int start, last_start = 0; int total_length = 0; #ifdef linux struct cdrom_tocentry entry; -#elif defined(__FreeBSD__) +#else struct ioc_read_toc_entry entry; struct cd_toc_entry toc_buffer; #endif @@ -177,31 +184,29 @@ if (i == wcda->nTracks) #ifdef linux entry.cdte_track = CDROM_LEADOUT; -#elif defined(__FreeBSD__) +#else #define LEADOUT 0xaa entry.starting_track = LEADOUT; /* XXX */ #endif else #ifdef linux entry.cdte_track = i + 1; -#elif defined(__FreeBSD__) +#else entry.starting_track = i + 1; #endif #ifdef linux entry.cdte_format = CDROM_MSF; -#elif defined(__FreeBSD__) +#else bzero((char *)&toc_buffer, sizeof(toc_buffer)); entry.address_format = CD_MSF_FORMAT; entry.data_len = sizeof(toc_buffer); entry.data = &toc_buffer; #endif - if (ioctl(wcda->unixdev, #ifdef linux - CDROMREADTOCENTRY -#elif defined(__FreeBSD__) - CDIOREADTOCENTRYS + if (ioctl(wcda->unixdev, CDROMREADTOCENTRY, &entry)) { +#else + if (ioctl(wcda->unixdev, CDIOREADTOCENTRYS, &entry)) { #endif - , &entry)) { WARN(cdaudio, "error read entry\n"); return FALSE; } @@ -209,7 +214,7 @@ start = CDFRAMES_PERSEC * (SECONDS_PERMIN * entry.cdte_addr.msf.minute + entry.cdte_addr.msf.second) + entry.cdte_addr.msf.frame; -#elif defined(__FreeBSD__) +#else start = CDFRAMES_PERSEC * (SECONDS_PERMIN * toc_buffer.addr.msf.minute + toc_buffer.addr.msf.second) + toc_buffer.addr.msf.frame; @@ -230,7 +235,7 @@ wcda->lpbTrackFlags[i] = #ifdef linux (entry.cdte_adr << 4) | (entry.cdte_ctrl & 0x0f); -#elif defined(__FreeBSD__) +#else (toc_buffer.addr_type << 4) | (toc_buffer.control & 0x0f); #endif TRACE(cdaudio, "track #%u flags=%02x\n", i + 1, wcda->lpbTrackFlags[i]); @@ -248,7 +253,7 @@ */ static DWORD CDAUDIO_mciOpen(UINT16 wDevID, DWORD dwFlags, LPMCI_OPEN_PARMS32A lpOpenParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) DWORD dwDeviceID; WINE_CDAUDIO* wcda; @@ -328,7 +333,7 @@ */ static DWORD CDAUDIO_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwParam, lpParms); @@ -351,7 +356,7 @@ static DWORD CDAUDIO_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; @@ -403,7 +408,7 @@ */ static DWORD CDAUDIO_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) DWORD ret = 0; LPSTR str = 0; WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); @@ -445,7 +450,7 @@ static DWORD CDAUDIO_CalcFrame(WINE_CDAUDIO* wcda, DWORD dwTime) { DWORD dwFrame = 0; -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) UINT16 wTrack; TRACE(cdaudio,"(%p, %08lX, %lu);\n", wcda, wcda->dwTimeFormat, dwTime); @@ -487,9 +492,9 @@ */ static BOOL32 CDAUDIO_GetCDStatus(WINE_CDAUDIO* wcda) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) int oldmode = wcda->cdMode; -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) struct ioc_read_subchannel read_sc; read_sc.address_format = CD_MSF_FORMAT; @@ -500,13 +505,11 @@ #elif linux wcda->sc.cdsc_format = CDROM_MSF; #endif - if (ioctl(wcda->unixdev, #ifdef linux - CDROMSUBCHNL, &wcda->sc -#elif defined(__FreeBSD__) - CDIOCREADSUBCHANNEL, &read_sc + if (ioctl(wcda->unixdev, CDROMSUBCHNL, &wcda->sc)) { +#else + if (ioctl(wcda->unixdev, CDIOCREADSUBCHANNEL, &read_sc)) { #endif - )) { TRACE(cdaudio,"opened or no_media !\n"); wcda->cdMode = MCI_MODE_OPEN; /* was NOT_READY */ return TRUE; @@ -514,13 +517,13 @@ switch ( #ifdef linux wcda->sc.cdsc_audiostatus -#elif defined(__FreeBSD__) +#else wcda->sc.header.audio_status #endif ) { #ifdef linux case CDROM_AUDIO_INVALID: -#elif defined(__FreeBSD__) +#else case CD_AS_AUDIO_INVALID: #endif WARN(cdaudio, "device doesn't support status, using MCI status.\n"); @@ -528,7 +531,7 @@ break; #ifdef linux case CDROM_AUDIO_NO_STATUS: -#elif defined(__FreeBSD__) +#else case CD_AS_NO_STATUS: #endif wcda->cdMode = MCI_MODE_STOP; @@ -536,7 +539,7 @@ break; #ifdef linux case CDROM_AUDIO_PLAY: -#elif defined(__FreeBSD__) +#else case CD_AS_PLAY_IN_PROGRESS: #endif wcda->cdMode = MCI_MODE_PLAY; @@ -544,7 +547,7 @@ break; #ifdef linux case CDROM_AUDIO_PAUSED: -#elif defined(__FreeBSD__) +#else case CD_AS_PLAY_PAUSED: #endif wcda->cdMode = MCI_MODE_PAUSE; @@ -554,7 +557,7 @@ #ifdef linux TRACE(cdaudio,"status=%02X !\n", wcda->sc.cdsc_audiostatus); -#elif defined(__FreeBSD__) +#else TRACE(cdaudio,"status=%02X !\n", wcda->sc.header.audio_status); #endif @@ -565,7 +568,7 @@ CDFRAMES_PERMIN * wcda->sc.cdsc_absaddr.msf.minute + CDFRAMES_PERSEC * wcda->sc.cdsc_absaddr.msf.second + wcda->sc.cdsc_absaddr.msf.frame; -#elif defined(__FreeBSD__) +#else wcda->nCurTrack = wcda->sc.what.position.track_number; wcda->dwCurFrame = CDFRAMES_PERMIN * wcda->sc.what.position.absaddr.msf.minute + @@ -578,7 +581,7 @@ wcda->sc.cdsc_absaddr.msf.minute, wcda->sc.cdsc_absaddr.msf.second, wcda->sc.cdsc_absaddr.msf.frame); -#elif defined(__FreeBSD__) +#else TRACE(cdaudio,"%02u-%02u:%02u:%02u \n", wcda->sc.what.position.track_number, wcda->sc.what.position.absaddr.msf.minute, @@ -605,7 +608,7 @@ static DWORD CDAUDIO_CalcTime(WINE_CDAUDIO* wcda, DWORD dwFrame) { DWORD dwTime = 0; -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) UINT16 wTrack; UINT16 wMinutes; UINT16 wSeconds; @@ -651,7 +654,7 @@ */ static DWORD CDAUDIO_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); DWORD ret = 0; @@ -759,13 +762,13 @@ */ static DWORD CDAUDIO_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) int start, end; WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); DWORD ret = 0; #ifdef linux struct cdrom_msf msf; -#elif defined(__FreeBSD__) +#else struct ioc_play_msf msf; #endif @@ -796,7 +799,7 @@ msf.cdmsf_min1 = end / CDFRAMES_PERMIN; msf.cdmsf_sec1 = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC; msf.cdmsf_frame1 = end % CDFRAMES_PERSEC; -#elif defined(__FreeBSD__) +#else msf.start_m = start / CDFRAMES_PERMIN; msf.start_s = (start % CDFRAMES_PERMIN) / CDFRAMES_PERSEC; msf.start_f = start % CDFRAMES_PERSEC; @@ -804,23 +807,19 @@ msf.end_s = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC; msf.end_f = end % CDFRAMES_PERSEC; #endif - if (ioctl(wcda->unixdev, #ifdef linux - CDROMSTART -#elif defined(__FreeBSD__) - CDIOCSTART + if (ioctl(wcda->unixdev, CDROMSTART)) { +#else + if (ioctl(wcda->unixdev, CDIOCSTART, NULL)) { #endif - )) { WARN(cdaudio, "motor doesn't start !\n"); return MCIERR_HARDWARE; } - if (ioctl(wcda->unixdev, #ifdef linux - CDROMPLAYMSF -#elif defined(__FreeBSD__) - CDIOCPLAYMSF + if (ioctl(wcda->unixdev, CDROMPLAYMSF, &msf)) { +#else + if (ioctl(wcda->unixdev, CDIOCPLAYMSF, &msf)) { #endif - , &msf)) { WARN(cdaudio, "device doesn't play !\n"); return MCIERR_HARDWARE; } @@ -828,7 +827,7 @@ TRACE(cdaudio,"msf = %d:%d:%d %d:%d:%d\n", msf.cdmsf_min0, msf.cdmsf_sec0, msf.cdmsf_frame0, msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1); -#elif defined(__FreeBSD__) +#else TRACE(cdaudio,"msf = %d:%d:%d %d:%d:%d\n", msf.start_m, msf.start_s, msf.start_f, msf.end_m, msf.end_s, msf.end_f); @@ -854,20 +853,19 @@ */ static DWORD CDAUDIO_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wcda == NULL) return MCIERR_INVALID_DEVICE_ID; - if (ioctl(wcda->unixdev, #ifdef linux - CDROMSTOP -#elif defined(__FreeBSD__) - CDIOCSTOP + if (ioctl(wcda->unixdev, CDROMSTOP)) +#else + if (ioctl(wcda->unixdev, CDIOCSTOP, NULL)) #endif - )) return MCIERR_HARDWARE; + return MCIERR_HARDWARE; wcda->mciMode = MCI_MODE_STOP; if (lpParms && (dwFlags & MCI_NOTIFY)) { TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback); @@ -885,20 +883,19 @@ */ static DWORD CDAUDIO_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wcda == NULL) return MCIERR_INVALID_DEVICE_ID; - if (ioctl(wcda->unixdev, #ifdef linux - CDROMPAUSE -#elif defined(__FreeBSD__) - CDIOCPAUSE + if (ioctl(wcda->unixdev, CDROMPAUSE)) +#else + if (ioctl(wcda->unixdev, CDIOCPAUSE, NULL)) #endif - )) return MCIERR_HARDWARE; + return MCIERR_HARDWARE; wcda->mciMode = MCI_MODE_PAUSE; if (lpParms && (dwFlags & MCI_NOTIFY)) { TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback); @@ -916,20 +913,19 @@ */ static DWORD CDAUDIO_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wcda == NULL) return MCIERR_INVALID_DEVICE_ID; - if (ioctl(wcda->unixdev, #ifdef linux - CDROMRESUME -#elif defined(__FreeBSD__) - CDIOCRESUME + if (ioctl(wcda->unixdev, CDROMRESUME)) +#else + if (ioctl(wcda->unixdev, CDIOCRESUME, NULL)) #endif - )) return MCIERR_HARDWARE; + return MCIERR_HARDWARE; wcda->mciMode = MCI_MODE_STOP; if (lpParms && (dwFlags & MCI_NOTIFY)) { TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback); @@ -947,7 +943,7 @@ */ static DWORD CDAUDIO_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) DWORD dwRet; MCI_PLAY_PARMS PlayParms; WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); @@ -957,13 +953,11 @@ if (wcda == NULL) return MCIERR_INVALID_DEVICE_ID; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; - if (ioctl(wcda->unixdev, #ifdef linux - CDROMRESUME -#elif defined(__FreeBSD__) - CDIOCRESUME + if (ioctl(wcda->unixdev, CDROMRESUME)) { +#else + if (ioctl(wcda->unixdev, CDIOCRESUME, NULL)) { #endif - )) { perror("ioctl CDROMRESUME"); return MCIERR_HARDWARE; } @@ -1004,16 +998,16 @@ if (wcda == NULL) return MCIERR_INVALID_DEVICE_ID; -#ifdef __FreeBSD__ - if (ioctl(wcda->unixdev, CDIOCALLOW)) return MCIERR_HARDWARE; + #if defined(__FreeBSD__) || defined(__NetBSD__) + if (ioctl(wcda->unixdev, CDIOCALLOW, NULL)) return MCIERR_HARDWARE; if (open) { - if (ioctl(wcda->unixdev, CDIOCEJECT)) return MCIERR_HARDWARE; + if (ioctl(wcda->unixdev, CDIOCEJECT, NULL)) return MCIERR_HARDWARE; wcda->mciMode = MCI_MODE_OPEN; } else { - if (ioctl(wcda->unixdev, CDIOCCLOSE)) return MCIERR_HARDWARE; + if (ioctl(wcda->unixdev, CDIOCCLOSE, NULL)) return MCIERR_HARDWARE; wcda->mciMode = MCI_MODE_STOP; } - if (ioctl(wcda->unixdev, CDIOCPREVENT)) return MCIERR_HARDWARE; + if (ioctl(wcda->unixdev, CDIOCPREVENT, NULL)) return MCIERR_HARDWARE; #elif linux if (open) { if (ioctl(wcda->unixdev, CDROMEJECT)) return MCIERR_HARDWARE; @@ -1032,7 +1026,7 @@ */ static DWORD CDAUDIO_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) WINE_CDAUDIO* wcda = CDAUDIO_mciGetOpenDrv(wDevID); TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms); @@ -1087,7 +1081,7 @@ LONG MCICDAUDIO_DriverProc32(DWORD dwDevID, HDRVR16 hDriv, DWORD wMsg, DWORD dwParam1, DWORD dwParam2) { -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) switch(wMsg) { case DRV_LOAD: return 1; case DRV_FREE: return 1;