|
a/mpd2src/openaudio.cpp |
|
b/mpd2src/openaudio.cpp |
|
... |
|
... |
19 |
|
19 |
|
20 |
#include <string>
|
20 |
#include <string>
|
21 |
#include <unistd.h>
|
21 |
#include <unistd.h>
|
22 |
#include <sys/stat.h>
|
22 |
#include <sys/stat.h>
|
23 |
#include <errno.h>
|
23 |
#include <errno.h>
|
|
|
24 |
#include <byteswap.h>
|
24 |
|
25 |
|
25 |
#include <iostream>
|
26 |
#include <iostream>
|
26 |
#include <vector>
|
27 |
#include <vector>
|
27 |
|
28 |
|
28 |
#include "audioreader.h"
|
29 |
#include "audioreader.h"
|
|
... |
|
... |
112 |
// Convert sample endianness
|
113 |
// Convert sample endianness
|
113 |
void swapSamples(unsigned char *data, int bytesPerSamp, int scount)
|
114 |
void swapSamples(unsigned char *data, int bytesPerSamp, int scount)
|
114 |
{
|
115 |
{
|
115 |
//LOGDEB("swapSamples: bps " << bytesPerSamp << " count " << scount << endl);
|
116 |
//LOGDEB("swapSamples: bps " << bytesPerSamp << " count " << scount << endl);
|
116 |
if (bytesPerSamp == 2) {
|
117 |
if (bytesPerSamp == 2) {
|
117 |
swab(data, data, scount * 2);
|
118 |
// Swab would need non-overlapping buffers.
|
|
|
119 |
unsigned short *sp = (unsigned short *)data;
|
|
|
120 |
for (int i = 0; i < scount; i++) {
|
|
|
121 |
sp[i] = bswap_16(sp[i]);
|
|
|
122 |
}
|
118 |
} else {
|
123 |
} else {
|
119 |
unsigned char sample[4];
|
124 |
unsigned char sample[4];
|
120 |
// Byte index in data buffer
|
125 |
// Byte index in data buffer
|
121 |
unsigned int pindex = 0;
|
126 |
unsigned int pindex = 0;
|
122 |
|
127 |
|