1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/* --------------------------------------------------------------------------
MusicBrainz -- The Internet music metadatabase
Copyright (C) 2000 Robert Kaye
Portions Copyright (C) 2000 Emusic.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: mb_win32.cpp,v 1.9 2002/09/13 00:59:18 neil Exp $
----------------------------------------------------------------------------*/
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include "mmsystem.h"
#include "mb_win32.h" // can't assume symlink mb.h to cdi_win32.h
#include "diskid.h"
#include "../config_win32.h" // a copy of a Cygwin generated config.h
MUSICBRAINZ_DEVICE DEFAULT_DEVICE = "0";
int
ReadTOCHeader(int fd, int &first, int &last)
{
return 0;
}
int
ReadTOCEntry(int fd, int track, int &lba)
{
return 0;
}
bool DiskId::ReadTOC(MUSICBRAINZ_DEVICE cd_desc, MUSICBRAINZ_CDINFO & disc)
{
int readtracks, ret, numTracks;
char mciCommand[128];
char mciReturn[128];
char buf[256], alias[128], temp[128];
if (cd_desc == NULL || strlen(cd_desc) == 0 || strcmp(cd_desc, "cdaudio") == 0)
cd_desc = "cdaudio";
else
{
sprintf(temp, "%s type cdaudio", cd_desc);
cd_desc = temp;
}
sprintf(alias, "mb_client_%u_%u", GetTickCount(), GetCurrentThreadId());
memset(&disc, 0, sizeof(disc));
sprintf(mciCommand, "sysinfo cdaudio quantity wait", cd_desc);
mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
if (atoi(mciReturn) <= 0)
return false;
sprintf(mciCommand, "open %s shareable alias %s wait", cd_desc, alias);
ret = mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
if (ret != 0)
return false;
cd_desc = alias;
sprintf(mciCommand, "status %s number of tracks wait", cd_desc);
ret = mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
mciGetErrorString(ret, buf, sizeof(buf));
if (ret != 0)
return false;
numTracks = atoi(mciReturn);
disc.FirstTrack = 1;
disc.LastTrack = numTracks;
sprintf(mciCommand, "set %s time format msf wait", cd_desc);
mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
for (readtracks = 1; readtracks <= disc.LastTrack; readtracks++)
{
sprintf(mciCommand, "status %s position track %d wait",
cd_desc, readtracks);
mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
disc.FrameOffset[readtracks] = atoi(mciReturn) * 4500 +
atoi(mciReturn + 3) * 75 +
atoi(mciReturn + 6);
}
sprintf(mciCommand, "status %s length track %d wait",
cd_desc, disc.LastTrack);
mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
disc.FrameOffset[0] = atoi(mciReturn) * 4500 +
atoi(mciReturn + 3) * 75 +
atoi(mciReturn + 6) +
disc.FrameOffset[disc.LastTrack] + 1;
sprintf(mciCommand, "close %s wait", cd_desc);
mciSendString(mciCommand, mciReturn, sizeof(mciReturn), NULL);
return true;
}
|