=== modified file 'mixxx/src/soundsourcem4a.cpp' --- mixxx/src/soundsourcem4a.cpp 2009-09-22 20:13:30 +0000 +++ mixxx/src/soundsourcem4a.cpp 2010-01-10 21:07:42 +0000 @@ -47,11 +47,11 @@ int mp4_open_status = mp4_open(&ipd); if (mp4_open_status != 0) { - // The file was loading and failing iratically because + // The file was loading and failing erratically because // ipd.remote was an in an uninitialized state, it needed to be // set to false. - qDebug() << "SSM4A: failed to open MP4 file '" - << qFileName << "' w/ status:" << mp4_open_status << " FIXME."; + qDebug() << "SSM4A: failed to open MP4 file " + << qFileName << " with status:" << mp4_open_status; return; } @@ -103,16 +103,14 @@ // We want to read a total of "size" samples, and the mp4_read() // function wants to know how many bytes we want to decode. One - // sample is 16-bits = 2 bytes here, so we multiply size by 2 to + // sample is 16-bits = 2 bytes here, so we multiply size by channels to // get the number of bytes we want to decode. - // rryan 2/2009 Can M4A files be non-stereo? If so, we need to - // replicate logic here similar to in other areas. - - int total_bytes_to_decode = size * 2; + int total_bytes_to_decode = size * channels; int total_bytes_decoded = 0; int num_bytes_req = 4096; char* buffer = (char*)destination; + SAMPLE * as_buffer = (SAMPLE*) destination; //pointer for mono->stereo filling. do { if (total_bytes_decoded + num_bytes_req > total_bytes_to_decode) num_bytes_req = total_bytes_to_decode - total_bytes_decoded; @@ -122,21 +120,30 @@ buffer, num_bytes_req); if(numRead <= 0) { - qDebug() << "EOF"; + qDebug() << "SSM4A::read: EOF"; break; } buffer += numRead; total_bytes_decoded += numRead; } while (total_bytes_decoded < total_bytes_to_decode); + //at this point *destination should be filled; + if (channels==1) { //if mono : double all samples (L => R) + for(int i=((total_bytes_decoded>>1)-1); i>=0; i=i--) { // as_buffer[i] is an audio sample (s16) + as_buffer[(i<<1)+1] = as_buffer[i]; //scroll through , copying L->R & expanding buffer + as_buffer[i<<1] = as_buffer[i]; + } + } + // Tell us about it only if we end up decoding a different value // then what we expect. - if (total_bytes_decoded % (size * 2)) - qDebug() << "MP4READ: total_bytes_decoded:" + if (total_bytes_decoded % (size * 2)) { + qDebug() << "SSM4A::read : total_bytes_decoded:" << total_bytes_decoded << "size:" << size; + } //There are two bytes in a 16-bit sample, so divide by 2. return total_bytes_decoded / 2; @@ -150,19 +157,16 @@ } int SoundSourceM4A::ParseHeader( TrackInfoObject * Track){ - if (Track->getHeaderParsed()) - return OK; - QString mp4FileName = Track->getLocation(); MP4FileHandle mp4file = MP4Read(mp4FileName); if (mp4file == MP4_INVALID_FILE_HANDLE) { - qDebug() << "mp4: " << mp4FileName + qDebug() << "SSM4A::ParseHeader : " << mp4FileName << "could not be opened using the MP4 decoder."; - Track->setHeaderParsed(false); return ERR; } + Track->setType("m4a"); char* value = NULL; if (MP4GetMetadataName(mp4file, &value) && value != NULL) { Track->setTitle(value); @@ -194,7 +198,7 @@ int track_id = MP4FindTrackId(mp4file, 0, MP4_AUDIO_TRACK_TYPE); if (track_id == MP4_INVALID_TRACK_ID) { - qDebug() << "Could not find any audio tracks in " << mp4FileName; + qDebug() << "SSM4A::ParseHeader: Could not find any audio tracks in " << mp4FileName; } // Get the track duration in time scale units of the mp4 @@ -209,7 +213,6 @@ MP4Close(mp4file); Track->setHeaderParsed(true); - Track->setType("m4a"); // FIXME: hard-coded to 2 channels - real value is not available until // faacDecInit2 is called Track->setChannels(2);