/* Audio File Library Copyright (C) 1998, Michael Pruett 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* track.c This file contains functions for dealing with tracks within an audio file. */ #include "config.h" #include "Track.h" #include #include #include #include #include "audiofile.h" #include "afinternal.h" #include "util.h" #include "Marker.h" #include "PacketTable.h" #include "modules/Module.h" #include "modules/ModuleState.h" void afInitTrackIDs (AFfilesetup file, const int *trackids, int trackCount) { assert(file); assert(trackids); assert(trackCount == 1); assert(trackids[0] == AF_DEFAULT_TRACK); } int afGetTrackIDs (AFfilehandle file, int *trackids) { assert(file); if (trackids != NULL) trackids[0] = AF_DEFAULT_TRACK; return 1; } Track::Track() { id = AF_DEFAULT_TRACK; f.compressionParams = NULL; v.compressionParams = NULL; channelMatrix = NULL; markerCount = 0; markers = NULL; hasAESData = false; memset(aesData, 0, 24); totalfframes = 0; nextfframe = 0; frames2ignore = 0; fpos_first_frame = 0; fpos_next_frame = 0; fpos_after_data = 0; totalvframes = 0; nextvframe = 0; data_size = 0; } Track::~Track() { if (f.compressionParams) { AUpvfree(f.compressionParams); f.compressionParams = NULL; } if (v.compressionParams) { AUpvfree(v.compressionParams); v.compressionParams = NULL; } free(channelMatrix); channelMatrix = NULL; if (markers) { for (int j=0; jmarkerCount) == 0) { markers = NULL; return AF_SUCCEED; } markers = _af_marker_new(markerCount); if (!markers) return AF_FAIL; for (int i=0; imarkers[i].id; markers[i].name = _af_strdup(setup->markers[i].name); if (!markers[i].name) return AF_FAIL; markers[i].comment = _af_strdup(setup->markers[i].comment); if (!markers[i].comment) return AF_FAIL; markers[i].position = 0; } return AF_SUCCEED; } void Track::computeTotalFileFrames() { if (f.bytesPerPacket && f.framesPerPacket) totalfframes = (data_size / f.bytesPerPacket) * f.framesPerPacket; }