34# ifdef HAVE_COREAUDIO_COREAUDIO_H
35# include <CoreFoundation/CoreFoundation.h>
36# include <CoreAudio/CoreAudio.h>
38# ifdef HAVE_AUDIOTOOLBOX_AUDIOCONVERTER_H
39# include <AudioToolbox/AudioConverter.h>
68 {1, 8, 8000}, {2, 8, 8000}, {1, 16, 8000}, {2, 16, 8000},
69 {1, 8, 11025}, {2, 8, 11025}, {1, 16, 11025}, {2, 16, 11025},
70 {1, 8, 12000}, {2, 8, 12000}, {1, 16, 12000}, {2, 16, 12000},
71 {1, 8, 16000}, {2, 8, 16000}, {1, 16, 16000}, {2, 16, 16000},
72 {1, 8, 22050}, {2, 8, 22050}, {1, 16, 22050}, {2, 16, 22050},
73 {1, 8, 24000}, {2, 8, 24000}, {1, 16, 24000}, {2, 16, 24000},
74 {1, 8, 32000}, {2, 8, 32000}, {1, 16, 32000}, {2, 16, 32000},
75 {1, 8, 44100}, {2, 8, 44100}, {1, 16, 44100}, {2, 16, 44100},
76 {1, 8, 48000}, {2, 8, 48000}, {1, 16, 48000}, {2, 16, 48000}
81 {1, 0, 8000}, {2, 0, 8000},
82 {1, 0, 11025}, {2, 0, 11025},
83 {1, 0, 12000}, {2, 0, 12000},
84 {1, 0, 16000}, {2, 0, 16000},
85 {1, 0, 22050}, {2, 0, 22050},
86 {1, 0, 24000}, {2, 0, 24000},
87 {1, 0, 32000}, {2, 0, 32000},
88 {1, 0, 44100}, {2, 0, 44100},
89 {1, 0, 48000}, {2, 0, 48000}
115 for (
i = 0;
i < hi;
i++)
128typedef struct tagAcmMpeg3Data
158 AcmMpeg3Data* amd = (AcmMpeg3Data*)adsi->
dwDriver;
169 ERR(
"Error feeding data\n");
180 FIXME(
"Error occurred during decoding!\n");
190 TRACE(
"New format: %li Hz, %i channels, encoding value %i\n",
rate,
channels, enc);
193 if (dpos >= *ndst)
break;
258 aad->convert = mp3_horse;
262#if MPG123_API_VERSION >= 31
275 WARN(
"Encoding to MPEG is not supported\n");
279 MPEG3_Reset(adsi, aad);
301#elif defined(HAVE_AUDIOTOOLBOX_AUDIOCONVERTER_H)
303static const unsigned short Mp3BitRates[2][16] =
305 {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0},
306 {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}
309static const unsigned short Mp3SampleRates[2][4] =
311 {44100, 48000, 32000, 0},
312 {22050, 24000, 16000, 0}
315typedef struct tagAcmMpeg3Data
319 AudioConverterRef acr;
320 AudioStreamBasicDescription
in,
out;
323 AudioBuffer inBuffer;
328 AudioStreamPacketDescription *PacketDescriptions;
352static OSStatus Mp3AudioConverterComplexInputDataProc(
353 AudioConverterRef inAudioConverter,
354 UInt32 *ioNumberDataPackets,
355 AudioBufferList *ioData,
356 AudioStreamPacketDescription **outDataPacketDescription,
360 AcmMpeg3Data *amd = (AcmMpeg3Data*)inUserData;
362 if (amd->inBuffer.mDataByteSize > 0)
364 *ioNumberDataPackets = amd->NumberPackets;
365 ioData->mNumberBuffers = 1;
366 ioData->mBuffers[0] = amd->inBuffer;
367 amd->inBuffer.mDataByteSize = 0;
368 if (outDataPacketDescription)
369 *outDataPacketDescription = amd->PacketDescriptions;
374 *ioNumberDataPackets = 0;
383static SInt32 Mp3GetPacketLength(
const unsigned char*
src)
386 unsigned short brate, srate;
393 if (
src[0] == 0xff &&
src[1] >> 1 == 0x7d) mpegv = 0;
394 else if (
src[0] == 0xff &&
src[1] >> 1 == 0x79) mpegv = 1;
398 brate = Mp3BitRates[mpegv][(
src[2] & 0xf0) >> 4];
399 srate = Mp3SampleRates[mpegv][(
src[2] & 0xc) >> 2];
402 if (brate == 0 || srate == 0)
return -1;
405 size = 72 * (2 - mpegv) * brate * 1000 / srate;
408 if (
src[2] & 0x2)
return size + 1;
428 const unsigned char* psrc;
429 AcmMpeg3Data* amd = (AcmMpeg3Data*)adsi->
dwDriver;
431 TRACE(
"ndst %u %p <- %u %p\n", *ndst,
dst, *nsrc,
src);
436 if (!
memcmp(
src,
"ID3", 3) && amd->tagBytesLeft == -1)
438 amd->tagBytesLeft = (
src[6] << 21) + (
src[7] << 14) + (
src[8] << 7) +
src[9];
439 if (
src[5] & 0x10) amd->tagBytesLeft += 20;
440 else amd->tagBytesLeft += 10;
444 if (amd->tagBytesLeft >= (SInt32)*nsrc)
447 amd->tagBytesLeft -= *nsrc;
449 TRACE(
"All %d bytes of source data is ID3 tag\n", *nsrc);
452 else if (amd->tagBytesLeft > 0)
454 src += amd->tagBytesLeft;
455 *nsrc -= amd->tagBytesLeft;
456 TRACE(
"Skipping %ld for ID3 tag\n", amd->tagBytesLeft);
465 for (psrc =
src; psrc <=
src + *nsrc - 4 && psrc <
src + 1440; psrc++)
469 synci < 4 && psrc + framelen[synci-1] <
src + *nsrc - 4;
472 framelen[synci] = Mp3GetPacketLength(psrc + framelen[synci-1]);
473 if (framelen[synci] == -1)
478 framelen[synci] += framelen[synci-1];
484 syncSkip = psrc -
src;
487 TRACE(
"Skipping %ld for frame sync\n", syncSkip);
493 if (Mp3GetPacketLength(
src) == -1)
496 ERR(
"Frame sync failed. Cannot play file.\n");
505 amd->NumberPackets = 25;
506 amd->PacketDescriptions =
HeapAlloc(
GetProcessHeap(), 0, amd->NumberPackets *
sizeof(AudioStreamPacketDescription));
509 for (aspdi = 0, psrc =
src;
510 psrc <=
src + *nsrc - 4;
511 psrc += amd->PacketDescriptions[aspdi].mDataByteSize, aspdi++)
514 if (Mp3GetPacketLength(psrc) == -1)
517 ERR(
"Invalid header at %p.\n", psrc);
523 if (aspdi >= amd->NumberPackets)
525 amd->NumberPackets *= 2;
526 amd->PacketDescriptions =
HeapReAlloc(
GetProcessHeap(), 0, amd->PacketDescriptions, amd->NumberPackets *
sizeof(AudioStreamPacketDescription));
531 amd->PacketDescriptions[aspdi].mStartOffset = psrc -
src;
532 amd->PacketDescriptions[aspdi].mVariableFramesInPacket = 0;
533 amd->PacketDescriptions[aspdi].mDataByteSize = Mp3GetPacketLength(psrc);
536 if (psrc + amd->PacketDescriptions[aspdi].mDataByteSize >
src + *nsrc)
break;
540 amd->NumberPackets = aspdi;
545 amd->inBuffer.mDataByteSize = *nsrc;
546 amd->inBuffer.mData =
src;
547 amd->inBuffer.mNumberChannels = amd->in.mChannelsPerFrame;
549 amd->outBuffer.mNumberBuffers = 1;
550 amd->outBuffer.mBuffers[0].mDataByteSize = *ndst;
551 amd->outBuffer.mBuffers[0].mData =
dst;
552 amd->outBuffer.mBuffers[0].mNumberChannels = amd->out.mChannelsPerFrame;
555 size = amd->outBuffer.mBuffers[0].mDataByteSize / amd->out.mBytesPerPacket;
556 err = AudioConverterFillComplexBuffer(amd->acr, Mp3AudioConverterComplexInputDataProc, amd, &
size, &amd->outBuffer, 0);
561 if (amd->tagBytesLeft > 0)
563 *nsrc += amd->tagBytesLeft;
564 amd->tagBytesLeft = 0;
568 if (
err != noErr &&
err != -74)
571 ERR(
"Feed Error: %ld\n",
err);
575 *ndst = amd->outBuffer.mBuffers[0].mDataByteSize;
577 TRACE(
"convert %d -> %d\n", *nsrc, *ndst);
588 AudioConverterReset(aad->acr);
620 aad->in.mFormatID = kAudioFormatMPEGLayer3;
621 aad->out.mFormatID = kAudioFormatLinearPCM;
624 aad->in.mFormatFlags = 0;
625 aad->out.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
626 aad->in.mBytesPerFrame = 0;
627 aad->out.mBytesPerFrame = (aad->out.mBitsPerChannel * aad->out.mChannelsPerFrame) / 8;
628 aad->in.mBytesPerPacket = 0;
629 aad->out.mBytesPerPacket = aad->out.mBytesPerFrame;
630 aad->in.mFramesPerPacket = 0;
631 aad->out.mFramesPerPacket = 1;
632 aad->in.mReserved = aad->out.mReserved = 0;
634 aad->tagBytesLeft = -1;
636 aad->convert = mp3_leopard_horse;
638 err = AudioConverterNew(&aad->in, &aad->out, &aad->acr);
641 ERR(
"Create failed: %ld\n",
err);
645 MPEG3_Reset(adsi, aad);
663 AcmMpeg3Data* amd = (AcmMpeg3Data*)adsi->
dwDriver;
665 AudioConverterDispose(amd->acr);
710 static const WCHAR szPcm[]={
'P',
'C',
'M',0};
711 static const WCHAR szMpeg3[]={
'M',
'P',
'e',
'g',
'3',0};
712 static const WCHAR szMpeg[]={
'M',
'P',
'e',
'g',0};
736 WARN(
"Unsupported query %08x\n", dwQuery);
795 WARN(
"Encoding to MPEG is not supported\n");
803 WARN(
"Unsupported query %08x\n", dwQuery);
835 WARN(
"Encoding to MPEG is not supported\n");
854 WARN(
"Encoding to MPEG is not supported\n");
944 AcmMpeg3Data* aad = (AcmMpeg3Data*)adsi->
dwDriver;
953 FIXME(
"Unsupported fdwConvert (%08x), ignoring it\n", adsh->
fdwConvert);
962 MPEG3_Reset(adsi, aad);
965 aad->convert(adsi, adsh->
pbSrc, &nsrc, adsh->
pbDst, &ndst);
978 TRACE(
"(%08lx %p %04x %08lx %08lx);\n",
979 dwDevID, hDriv, wMsg, dwParam1, dwParam2);
986 case DRV_CLOSE:
return MPEG3_drvClose(dwDevID);
1037 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
const char * wine_dbgstr_an(const char *str, int n)
#define HeapFree(x, y, z)
#define MultiByteToWideChar
LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
MPG123_EXPORT void mpg123_delete(mpg123_handle *mh)
MPG123_EXPORT void mpg123_exit(void)
MPG123_EXPORT int mpg123_param(mpg123_handle *mh, enum mpg123_parms type, long value, double fvalue)
MPG123_EXPORT int mpg123_init(void)
MPG123_EXPORT mpg123_handle * mpg123_new(const char *decoder, int *error)
@ MPG123_IGNORE_INFOFRAME
MPG123_EXPORT int mpg123_getformat(mpg123_handle *mh, long *rate, int *channels, int *encoding)
MPG123_EXPORT off_t mpg123_feedseek(mpg123_handle *mh, off_t sampleoff, int whence, off_t *input_offset)
#define MM_FRAUNHOFER_IIS
#define WAVE_FORMAT_UNKNOWN
#define MPEGLAYER3_ID_MPEG
#define MPEGLAYER3_WFX_EXTRA_BYTES
#define WAVE_FORMAT_MPEGLAYER3
struct mpeglayer3waveformat_tag MPEGLAYER3WAVEFORMAT
struct mpeg1waveformat_tag MPEG1WAVEFORMAT
#define MM_FHGIIS_MPEGLAYER3_DECODE
#define DRV_QUERYCONFIGURE
#define MMSYSERR_NOTSUPPORTED
struct pcmwaveformat_tag PCMWAVEFORMAT
#define MMSYSERR_INVALPARAM
static LRESULT MPEG3_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh)
static DWORD MPEG3_GetFormatIndex(LPWAVEFORMATEX wfx)
static LRESULT MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
LRESULT CALLBACK MPEG3_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, LPARAM dwParam1, LPARAM dwParam2)
static LRESULT MPEG3_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
static LRESULT MPEG3_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss)
static LRESULT MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
static const Format MPEG3_Formats[]
static LRESULT MPEG3_DriverDetails(PACMDRIVERDETAILSW add)
static const Format PCM_Formats[]
#define ACM_STREAMCONVERTF_START
#define ACM_FORMATTAGDETAILSF_FORMATTAG
#define ACM_STREAMCONVERTF_BLOCKALIGN
#define ACM_STREAMOPENF_ASYNC
#define ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
#define ACM_FORMATSUGGESTF_WFORMATTAG
#define ACM_FORMATSUGGESTF_NCHANNELS
#define ACMERR_NOTPOSSIBLE
#define ACM_FORMATDETAILSF_FORMAT
#define ACM_STREAMSIZEF_SOURCE
#define ACM_FORMATTAGDETAILSF_LARGESTSIZE
#define ACM_STREAMSIZEF_DESTINATION
#define ACM_FORMATDETAILSF_INDEX
#define ACM_FORMATTAGDETAILSF_INDEX
#define ACM_FORMATSUGGESTF_WBITSPERSAMPLE
#define ACM_STREAMCONVERTF_END
#define ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
#define ACMDRIVERDETAILS_SUPPORTF_CODEC
#define ACM_FORMATSUGGESTF_NSAMPLESPERSEC
#define ACMDM_STREAM_PREPARE
#define ACMDM_STREAM_CLOSE
#define ACMDM_STREAM_CONVERT
#define ACMDM_FORMAT_SUGGEST
#define ACMDM_FILTER_DETAILS
#define ACMDM_HARDWARE_WAVE_CAPS_INPUT
#define ACMDM_DRIVER_NOTIFY
#define ACMDM_FORMAT_DETAILS
#define ACMDM_STREAM_SIZE
#define ACMDM_FILTERTAG_DETAILS
#define ACMDM_HARDWARE_WAVE_CAPS_OUTPUT
#define ACMDM_FORMATTAG_DETAILS
#define ACMDM_STREAM_UNPREPARE
#define ACMDM_STREAM_OPEN
#define ACMDM_DRIVER_DETAILS
#define ACMDM_STREAM_RESET
PFIXED_SENSE_DATA outBuffer
WCHAR szCopyright[ACMDRIVERDETAILS_COPYRIGHT_CHARS]
WCHAR szLongName[ACMDRIVERDETAILS_LONGNAME_CHARS]
WCHAR szShortName[ACMDRIVERDETAILS_SHORTNAME_CHARS]
WCHAR szLicensing[ACMDRIVERDETAILS_LICENSING_CHARS]
WCHAR szFeatures[ACMDRIVERDETAILS_FEATURES_CHARS]
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)